diff --git a/src/rest_vol.c b/src/rest_vol.c index dae24aa0..8aab3c40 100644 --- a/src/rest_vol.c +++ b/src/rest_vol.c @@ -168,7 +168,7 @@ static size_t H5_rest_curl_write_data_callback(char *buffer, size_t size, size_t static char *H5_rest_url_encode_path(const char *path); /* Helper function to parse an object's type from server response */ -herr_t RV_parse_type(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_parse_object_class(char *HTTP_response, const void *callback_data_in, void *callback_data_out); /* Helper function to parse an object's creation properties from server response */ herr_t RV_parse_creation_properties_callback(yajl_val parse_tree, char **GCPL_buf); @@ -1574,7 +1574,8 @@ H5_rest_url_encode_path(const char *_path) if (!_path) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "path was NULL"); - path = (char *)_path; + /* Silence compiler const warnings */ + memcpy(&path, &_path, sizeof(char *)); /* Retrieve the length of the possible path prefix, which could be something like '/', '.', etc. */ cur_pos = path; @@ -1701,7 +1702,7 @@ H5_rest_url_encode_path(const char *_path) /* Helper function to parse an object's type from server response */ herr_t -RV_parse_type(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_parse_object_class(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, key_obj; char *parsed_object_string; @@ -1750,7 +1751,7 @@ RV_parse_type(char *HTTP_response, void *callback_data_in, void *callback_data_o yajl_tree_free(parse_tree); return ret_value; -} /* end RV_parse_type */ +} /* end RV_parse_object_class */ /*--------------------------------------------------------------------------- * Function: H5_rest_get_conn_cls @@ -1839,8 +1840,8 @@ H5_rest_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, uint64_t *flags) * */ herr_t -RV_parse_response(char *HTTP_response, void *callback_data_in, void *callback_data_out, - herr_t (*parse_callback)(char *, void *, void *)) +RV_parse_response(char *HTTP_response, const void *callback_data_in, void *callback_data_out, + herr_t (*parse_callback)(char *, const void *, void *)) { herr_t ret_value = SUCCEED; @@ -1872,7 +1873,7 @@ RV_parse_response(char *HTTP_response, void *callback_data_in, void *callback_da * July, 2017 */ herr_t -RV_copy_object_URI_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_copy_object_URI_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, key_obj; char *parsed_string; @@ -2024,7 +2025,7 @@ RV_copy_object_URI_callback(char *HTTP_response, void *callback_data_in, void *c */ htri_t RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t *target_object_type, - herr_t (*obj_found_callback)(char *, void *, void *), void *callback_data_in, + herr_t (*obj_found_callback)(char *, const void *, void *), void *callback_data_in, void *callback_data_out) { RV_object_t *external_file = NULL; @@ -2266,7 +2267,7 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t if (SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 0)) { - if (0 > RV_parse_response(response_buffer.buffer, NULL, target_object_type, RV_parse_type)) + if (0 > RV_parse_response(response_buffer.buffer, NULL, target_object_type, RV_parse_object_class)) FUNC_GOTO_ERROR(H5E_OBJECT, H5E_CANTGET, FAIL, "failed to get type from URI"); } else { @@ -2296,14 +2297,20 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t H5L_TYPE_SOFT == link_info.type ? "soft" : "external"); #endif - if (RV_parse_response(response_buffer.buffer, &link_val_len, NULL, RV_get_link_val_callback) < - 0) + get_link_val_out get_link_val_args; + get_link_val_args.in_buf_size = &link_val_len; + get_link_val_args.buf = NULL; + + if (RV_parse_response(response_buffer.buffer, NULL, &get_link_val_args, + RV_get_link_val_callback) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve size of link's value"); if (NULL == (tmp_link_val = RV_malloc(link_val_len))) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTALLOC, FAIL, "can't allocate space for link's value"); - if (RV_parse_response(response_buffer.buffer, &link_val_len, tmp_link_val, + get_link_val_args.buf = tmp_link_val; + + if (RV_parse_response(response_buffer.buffer, NULL, &get_link_val_args, RV_get_link_val_callback) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link's value"); @@ -2443,7 +2450,7 @@ RV_parse_creation_properties_callback(yajl_val parse_tree, char **GCPL_buf_out) * May, 2023 */ herr_t -RV_copy_object_loc_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_copy_object_loc_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, key_obj; char *parsed_string; @@ -2537,7 +2544,7 @@ RV_copy_object_loc_info_callback(char *HTTP_response, void *callback_data_in, vo /* Allocate root "path" on heap for consistency with other RV_object_t types */ if ((new_domain->handle_path = RV_malloc(2)) == NULL) - FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "can't allocate space for filepath"); + FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate space for filepath"); strncpy(new_domain->handle_path, "/", 2); @@ -2581,16 +2588,16 @@ RV_copy_object_loc_info_callback(char *HTTP_response, void *callback_data_in, vo * May, 2023 */ herr_t -RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_copy_link_name_by_index(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { - yajl_val parse_tree = NULL, key_obj = NULL, link_obj = NULL; - const char *parsed_link_name = NULL; - char *parsed_link_buffer = NULL; - H5VL_loc_by_idx_t *idx_params = (H5VL_loc_by_idx_t *)callback_data_in; - hsize_t index = 0; - char **link_name = (char **)callback_data_out; - const char *curr_key = NULL; - herr_t ret_value = SUCCEED; + yajl_val parse_tree = NULL, key_obj = NULL, link_obj = NULL; + const char *parsed_link_name = NULL; + char *parsed_link_buffer = NULL; + const H5VL_loc_by_idx_t *idx_params = (const H5VL_loc_by_idx_t *)callback_data_in; + hsize_t index = 0; + char **link_name = (char **)callback_data_out; + const char *curr_key = NULL; + herr_t ret_value = SUCCEED; if (!idx_params) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "given index params ptr was NULL"); @@ -2677,15 +2684,15 @@ RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, void *ca * May, 2023 */ herr_t -RV_copy_attribute_name_by_index(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_copy_attribute_name_by_index(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { - yajl_val parse_tree = NULL, key_obj; - const char *parsed_string = NULL; - char *parsed_string_buffer = NULL; - H5VL_loc_by_idx_t *idx_params = (H5VL_loc_by_idx_t *)callback_data_in; - hsize_t index = 0; - char **attr_name = (char **)callback_data_out; - herr_t ret_value = SUCCEED; + yajl_val parse_tree = NULL, key_obj; + const char *parsed_string = NULL; + char *parsed_string_buffer = NULL; + const H5VL_loc_by_idx_t *idx_params = (const H5VL_loc_by_idx_t *)callback_data_in; + hsize_t index = 0; + char **attr_name = (char **)callback_data_out; + herr_t ret_value = SUCCEED; if (!attr_name) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "given attr_name was NULL"); @@ -3342,7 +3349,7 @@ RV_base64_decode(const char *in, size_t in_size, char **out, size_t *out_size) /* Helper function to store the version of the external HSDS server */ herr_t -RV_parse_server_version(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_parse_server_version(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, key_obj; herr_t ret_value = SUCCEED; @@ -3410,7 +3417,7 @@ RV_parse_server_version(char *HTTP_response, void *callback_data_in, void *callb /* Helper function to parse an object's allocated size from server response */ herr_t -RV_parse_allocated_size_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_parse_allocated_size_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, key_obj = NULL; herr_t ret_value = SUCCEED; @@ -3526,9 +3533,7 @@ RV_get_index_of_matching_handle(dataset_transfer_info *transfer_info, size_t cou } herr_t -RV_curl_multi_perform(CURL *curl_multi_handle, dataset_transfer_info *transfer_info, size_t count, - herr_t(success_callback)(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, - void *buf, struct response_buffer resp_buffer)) +RV_curl_multi_perform(CURL *curl_multi_handle, dataset_transfer_info *transfer_info, size_t count) { herr_t ret_value = SUCCEED; @@ -3657,12 +3662,23 @@ RV_curl_multi_perform(CURL *curl_multi_handle, dataset_transfer_info *transfer_i FUNC_GOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't get handle information for retry"); - if (success_callback( - transfer_info[handle_index].mem_type_id, transfer_info[handle_index].mem_space_id, - transfer_info[handle_index].file_space_id, transfer_info[handle_index].buf, - transfer_info[handle_index].resp_buffer) < 0) - FUNC_GOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, - "failed to post-process data read from dataset"); + switch (transfer_info[handle_index].transfer_type) { + case (READ): + if (RV_dataset_read_cb(transfer_info[handle_index].mem_type_id, + transfer_info[handle_index].mem_space_id, + transfer_info[handle_index].file_space_id, + transfer_info[handle_index].u.read_info.buf, + transfer_info[handle_index].resp_buffer) < 0) + FUNC_GOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, + "failed to post-process data read from dataset"); + break; + case (WRITE): + /* No post-processing necessary */ + break; + case (UNINIT): + FUNC_GOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "invalid transfer type"); + break; + } /* Clean up */ if (CURLM_OK != curl_multi_remove_handle(curl_multi_handle, curl_multi_msg->easy_handle)) diff --git a/src/rest_vol.h b/src/rest_vol.h index 1b6391cd..8228a4e9 100644 --- a/src/rest_vol.h +++ b/src/rest_vol.h @@ -557,11 +557,13 @@ typedef struct dataset_write_info { char *base64_encoded_values; curl_off_t write_len; upload_info uinfo; + const void *buf; } dataset_write_info; typedef struct dataset_read_info { H5S_sel_type sel_type; curl_off_t post_len; + void *buf; } dataset_read_info; typedef enum transfer_type_t { UNINIT = 0, READ = 1, WRITE = 2 } transfer_type_t; @@ -576,7 +578,6 @@ typedef struct dataset_transfer_info { struct response_buffer resp_buffer; RV_object_t *dataset; - void *buf; char *request_url; hid_t mem_type_id; hid_t mem_space_id; @@ -643,6 +644,10 @@ typedef struct loc_info { RV_object_t *domain; } loc_info; +typedef struct get_link_val_out { + size_t *in_buf_size; + void *buf; +} get_link_val_out; /**************************** * * * Prototypes * @@ -663,29 +668,32 @@ const char *H5_rest_basename(const char *path); char *H5_rest_dirname(const char *path); /* Helper function to parse an HTTP response according to the given parse callback function */ -herr_t RV_parse_response(char *HTTP_response, void *callback_data_in, void *callback_data_out, - herr_t (*parse_callback)(char *, void *, void *)); +herr_t RV_parse_response(char *HTTP_response, const void *callback_data_in, void *callback_data_out, + herr_t (*parse_callback)(char *, const void *, void *)); /* Callback for RV_parse_response() to capture an object's URI */ -herr_t RV_copy_object_URI_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_copy_object_URI_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); /* Callback for RV_parse_response() to capture an object's creation properties */ -herr_t RV_copy_object_loc_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_copy_object_loc_info_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); /* Callback for RV_parse_response() to access the name of the n-th returned attribute */ -herr_t RV_copy_attribute_name_by_index(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_copy_attribute_name_by_index(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); /* Callback for RV_parse_response() to access the name of the n-th returned link */ -herr_t RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_copy_link_name_by_index(char *HTTP_response, const void *callback_data_in, void *callback_data_out); /* Callback for RV_parse_response() to capture the version of the server api */ -herr_t RV_parse_server_version(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_parse_server_version(char *HTTP_response, const void *callback_data_in, void *callback_data_out); /* Helper function to find an object given a starting object to search from and a path */ htri_t RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t *target_object_type, - herr_t (*obj_found_callback)(char *, void *, void *), void *callback_data_in, - void *callback_data_out); + herr_t (*obj_found_callback)(char *, const void *, void *), + void *callback_data_in, void *callback_data_out); /* Helper function to parse a JSON string representing an HDF5 Dataspace and * setup an hid_t for the Dataspace */ @@ -710,16 +718,18 @@ size_t H5_rest_curl_write_data_callback_no_global(char *buffer, size_t size, siz herr_t RV_set_object_type_header(H5I_type_t parent_obj_type, const char **parent_obj_type_header); /* Helper function to parse an object's allocated size from server response */ -herr_t RV_parse_allocated_size_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_parse_allocated_size_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); void RV_free_visited_link_hash_table_key(rv_hash_table_key_t value); /* Counterpart of CURL_PERFORM that takes a curl multi handle, * and waits until all requests on it have finished before returning. */ -herr_t RV_curl_multi_perform(CURL *curl_multi_ptr, dataset_transfer_info *transfer_info, size_t count, - herr_t(success_callback)(hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, void *buf, - struct response_buffer resp_buffer)); +herr_t RV_curl_multi_perform(CURL *curl_multi_ptr, dataset_transfer_info *transfer_info, size_t count); + +/* Callbacks used for post-processing after a curl request succeeds */ +herr_t RV_dataset_read_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, void *buf, + struct response_buffer resp_buffer); #define SERVER_VERSION_MATCHES_OR_EXCEEDS(version, major_needed, minor_needed, patch_needed) \ (version.major > major_needed) || (version.major == major_needed && version.minor > minor_needed) || \ diff --git a/src/rest_vol_attr.c b/src/rest_vol_attr.c index 902f958b..75f20957 100644 --- a/src/rest_vol_attr.c +++ b/src/rest_vol_attr.c @@ -18,14 +18,17 @@ #include "rest_vol_attr.h" /* Set of callbacks for RV_parse_response() */ -static herr_t RV_get_attr_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); -static herr_t RV_attr_iter_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +static herr_t RV_get_attr_info_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); +static herr_t RV_attr_iter_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); /* Helper functions to work with a table of attributes for attribute iteration */ static herr_t RV_build_attr_table(char *HTTP_response, hbool_t sort, int (*sort_func)(const void *, const void *), attr_table_entry **attr_table, size_t *num_entries); -static herr_t RV_traverse_attr_table(attr_table_entry *attr_table, size_t num_entries, iter_data *iter_data); +static herr_t RV_traverse_attr_table(attr_table_entry *attr_table, size_t num_entries, + const iter_data *iter_data); /* Qsort callback to sort attributes by creation order */ static int cmp_attributes_by_creation_order(const void *attr1, const void *attr2); @@ -2804,7 +2807,7 @@ RV_attr_close(void *attr, hid_t dxpl_id, void **req) * December, 2017 */ static herr_t -RV_get_attr_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_attr_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { H5A_info_t *attr_info = (H5A_info_t *)callback_data_out; herr_t ret_value = SUCCEED; @@ -2842,10 +2845,10 @@ RV_get_attr_info_callback(char *HTTP_response, void *callback_data_in, void *cal * January, 2018 */ static herr_t -RV_attr_iter_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_attr_iter_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { attr_table_entry *attr_table = NULL; - iter_data *attr_iter_data = (iter_data *)callback_data_in; + const iter_data *attr_iter_data = (const iter_data *)callback_data_in; size_t attr_table_num_entries; herr_t ret_value = SUCCEED; @@ -3043,7 +3046,7 @@ RV_build_attr_table(char *HTTP_response, hbool_t sort, int (*sort_func)(const vo * January, 2018 */ static herr_t -RV_traverse_attr_table(attr_table_entry *attr_table, size_t num_entries, iter_data *attr_iter_data) +RV_traverse_attr_table(attr_table_entry *attr_table, size_t num_entries, const iter_data *attr_iter_data) { size_t last_idx; herr_t callback_ret; diff --git a/src/rest_vol_dataset.c b/src/rest_vol_dataset.c index d55f84cc..9cfe15ee 100644 --- a/src/rest_vol_dataset.c +++ b/src/rest_vol_dataset.c @@ -18,10 +18,10 @@ #include "rest_vol_dataset.h" /* Set of callbacks for RV_parse_response() */ -static herr_t RV_parse_dataset_creation_properties_callback(char *HTTP_response, void *callback_data_in, +static herr_t RV_parse_dataset_creation_properties_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); -static herr_t RV_json_values_to_binary_callback(char *HTTP_response, void *callback_data_in, +static herr_t RV_json_values_to_binary_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); /* Helper functions for creating a Dataset */ @@ -48,12 +48,6 @@ static herr_t RV_convert_buffer_to_obj_refs(char *ref_buf, size_t ref_buf_len, size_t *buf_out_len); static hssize_t RV_convert_start_to_offset(hid_t space_id); -/* Callbacks used for post-processing after a curl request succeeds */ -static herr_t rv_dataset_read_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, void *buf, - struct response_buffer resp_buffer); -static herr_t rv_dataset_write_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, void *buf, - struct response_buffer resp_buffer); - /* Struct for H5Dscatter's callback that allows it to scatter from a non-global response buffer */ struct response_read_info { void *buffer; @@ -514,7 +508,7 @@ RV_dataset_read(size_t count, void *dset[], hid_t mem_type_id[], hid_t _mem_spac transfer_info[i].u.read_info.sel_type = H5S_SEL_ALL; transfer_info[i].transfer_type = READ; transfer_info[i].dataset = (RV_object_t *)dset[i]; - transfer_info[i].buf = buf[i]; + transfer_info[i].u.read_info.buf = buf[i]; transfer_info[i].mem_space_id = _mem_space_id[i]; transfer_info[i].file_space_id = _file_space_id[i]; transfer_info[i].mem_type_id = mem_type_id[i]; @@ -758,7 +752,7 @@ RV_dataset_read(size_t count, void *dset[], hid_t mem_type_id[], hid_t _mem_spac FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "failed to set max concurrent streams for curl multi handle"); - if (RV_curl_multi_perform(curl_multi_handle, transfer_info, count, rv_dataset_read_cb) < 0) + if (RV_curl_multi_perform(curl_multi_handle, transfer_info, count) < 0) FUNC_GOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "failed to perform dataset write"); done: @@ -874,7 +868,7 @@ RV_dataset_write(size_t count, void *dset[], hid_t mem_type_id[], hid_t _mem_spa transfer_info[i].u.write_info.write_body = NULL; transfer_info[i].u.write_info.base64_encoded_values = NULL; transfer_info[i].dataset = (RV_object_t *)dset[i]; - transfer_info[i].buf = (void *)buf[i]; + transfer_info[i].u.write_info.buf = buf[i]; transfer_info[i].transfer_type = WRITE; transfer_info[i].mem_space_id = _mem_space_id[i]; @@ -1177,7 +1171,7 @@ RV_dataset_write(size_t count, void *dset[], hid_t mem_type_id[], hid_t _mem_spa FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "failed to set max concurrent streams in curl multi handle"); - if (RV_curl_multi_perform(curl_multi_handle, transfer_info, count, rv_dataset_write_cb) < 0) + if (RV_curl_multi_perform(curl_multi_handle, transfer_info, count) < 0) FUNC_GOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "failed to perform dataset write"); done: @@ -1518,7 +1512,7 @@ RV_dataset_close(void *dset, hid_t dxpl_id, void **req) * November, 2017 */ static herr_t -RV_parse_dataset_creation_properties_callback(char *HTTP_response, void *callback_data_in, +RV_parse_dataset_creation_properties_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, creation_properties_obj, key_obj; @@ -4119,8 +4113,8 @@ dataset_read_scatter_op(const void **src_buf, size_t *src_buf_bytes_used, void * } /* end dataset_read_scatter_op() */ /* Callback to be passed to rv_curl_multi_perform, for execution upon successful cURL request */ -static herr_t -rv_dataset_read_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, void *buf, +herr_t +RV_dataset_read_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, void *buf, struct response_buffer resp_buffer) { herr_t ret_value = SUCCEED; @@ -4204,15 +4198,6 @@ rv_dataset_read_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, v return ret_value; } -/* Callback to be passed to rv_curl_multi_perform, for execution upon successful cURL request */ -static herr_t -rv_dataset_write_cb(hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, void *buf, - struct response_buffer resp_buffer) -{ - herr_t ret_value = SUCCEED; - return SUCCEED; -} - /*------------------------------------------------------------------------- * Function: RV_dataspace_selection_is_contiguous * @@ -4434,11 +4419,11 @@ RV_convert_start_to_offset(hid_t space_id) * Return: Non-negative on success/Negative on failure */ static herr_t -RV_json_values_to_binary_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_json_values_to_binary_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { void **out_buf = (void **)callback_data_out; - hid_t dtype_id = *(hid_t *)callback_data_in; + const hid_t dtype_id = *(const hid_t *)callback_data_in; yajl_val parse_tree = NULL, key_obj; char *parsed_string; herr_t ret_value = SUCCEED; diff --git a/src/rest_vol_file.c b/src/rest_vol_file.c index 0707fede..23c03b7f 100644 --- a/src/rest_vol_file.c +++ b/src/rest_vol_file.c @@ -890,7 +890,7 @@ RV_iterate_copy_hid_cb(hid_t obj_id, void *udata) herr_t ret_value = H5_ITER_CONT; get_obj_ids_udata_t *iterate_cb_args = (get_obj_ids_udata_t *)udata; char *containing_filename = NULL; - size_t containing_filename_len = 0; + ssize_t containing_filename_len = 0; H5I_type_t id_type = H5I_UNINIT; htri_t is_committed = FALSE; @@ -916,11 +916,11 @@ RV_iterate_copy_hid_cb(hid_t obj_id, void *udata) if ((containing_filename_len = H5Fget_name(obj_id, NULL, 0)) < 0) FUNC_GOTO_ERROR(H5E_CALLBACK, H5E_CANTGET, FAIL, "unable to get length of filename"); - if ((containing_filename = RV_malloc(containing_filename_len + 1)) == NULL) + if ((containing_filename = RV_malloc((size_t)containing_filename_len + 1)) == NULL) FUNC_GOTO_ERROR(H5E_CALLBACK, H5E_CANTALLOC, FAIL, "can't allocate space for filename"); /* Get name */ - if (H5Fget_name(obj_id, containing_filename, containing_filename_len + 1) < 0) + if (H5Fget_name(obj_id, containing_filename, (size_t)containing_filename_len + 1) < 0) FUNC_GOTO_ERROR(H5E_CALLBACK, H5E_CANTGET, FAIL, "unable to get filename"); if (!strcmp(iterate_cb_args->local_filename, containing_filename)) { diff --git a/src/rest_vol_group.c b/src/rest_vol_group.c index 0367ae7d..f4cffdd1 100644 --- a/src/rest_vol_group.c +++ b/src/rest_vol_group.c @@ -18,7 +18,7 @@ #include "rest_vol_group.h" /* Set of callbacks for RV_parse_response() */ -static herr_t RV_get_group_info_callback(char *HTTP_response, void *callback_data_in, +static herr_t RV_get_group_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); /* JSON keys to retrieve the number of links in a group */ @@ -743,7 +743,7 @@ RV_group_close(void *grp, hid_t dxpl_id, void **req) * November, 2017 */ static herr_t -RV_get_group_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_group_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { H5G_info_t *group_info = (H5G_info_t *)callback_data_out; yajl_val parse_tree = NULL, key_obj; diff --git a/src/rest_vol_link.c b/src/rest_vol_link.c index 2ee54e45..70b1c05d 100644 --- a/src/rest_vol_link.c +++ b/src/rest_vol_link.c @@ -24,17 +24,18 @@ #define H5L_EXT_FLAGS_ALL 0 /* Set of callbacks for RV_parse_response() */ -static herr_t RV_get_link_name_by_idx_callback(char *HTTP_response, void *callback_data_in, +static herr_t RV_get_link_name_by_idx_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); -static herr_t RV_link_iter_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +static herr_t RV_link_iter_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); /* Helper functions to work with a table of links for link iteration */ static herr_t RV_build_link_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func)(const void *, const void *), link_table_entry **link_table, size_t *num_entries, rv_hash_table_t *visited_link_table); static void RV_free_link_table(link_table_entry *link_table, size_t num_entries); -static herr_t RV_traverse_link_table(link_table_entry *link_table, size_t num_entries, iter_data *iter_data, - const char *cur_link_rel_path); +static herr_t RV_traverse_link_table(link_table_entry *link_table, size_t num_entries, + const iter_data *iter_data, const char *cur_link_rel_path); /* Qsort callbacks to sort links by name or creation order */ static int H5_rest_cmp_links_by_creation_order_inc(const void *link1, const void *link2); @@ -599,6 +600,7 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t htri_t search_ret; char *link_name_buf = args->args.get_name.name; size_t link_name_buf_size = args->args.get_name.name_size; + size_t idx_p = 0; size_t *ret_size = args->args.get_name.name_len; /* @@ -615,10 +617,12 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t by_idx_data.is_recursive = FALSE; by_idx_data.index_type = loc_params->loc_data.loc_by_idx.idx_type; by_idx_data.iter_order = loc_params->loc_data.loc_by_idx.order; - by_idx_data.idx_p = &loc_params->loc_data.loc_by_idx.n; by_idx_data.iter_function.link_iter_op = NULL; by_idx_data.op_data = NULL; + idx_p = loc_params->loc_data.loc_by_idx.n; + by_idx_data.idx_p = &idx_p; + /* * Setup information to be passed back from link name retrieval callback */ @@ -792,7 +796,12 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t CURL_PERFORM(curl, H5E_LINK, H5E_CANTGET, FAIL); /* Retrieve the link value */ - if (RV_parse_response(response_buffer.buffer, &buf_size, out_buf, RV_get_link_val_callback) < 0) + get_link_val_out get_link_val_args; + get_link_val_args.in_buf_size = &buf_size; + get_link_val_args.buf = out_buf; + + if (RV_parse_response(response_buffer.buffer, NULL, &get_link_val_args, + RV_get_link_val_callback) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value"); break; @@ -1243,7 +1252,7 @@ RV_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_speci * December, 2017 */ herr_t -RV_get_link_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_link_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { H5L_info2_t *link_info = (H5L_info2_t *)callback_data_out; yajl_val parse_tree = NULL, key_obj; @@ -1293,7 +1302,11 @@ RV_get_link_info_callback(char *HTTP_response, void *callback_data_in, void *cal * to the size of a soft, external or user-defined link's value, including the NULL terminator */ if (strcmp(parsed_string, "H5L_TYPE_HARD")) { - if (RV_parse_response(HTTP_response, &link_info->u.val_size, NULL, RV_get_link_val_callback) < 0) + get_link_val_out get_link_val_args; + get_link_val_args.in_buf_size = &link_info->u.val_size; + get_link_val_args.buf = NULL; + + if (RV_parse_response(HTTP_response, NULL, &get_link_val_args, RV_get_link_val_callback) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value size"); #ifdef RV_CONNECTOR_DEBUG @@ -1341,14 +1354,15 @@ RV_get_link_info_callback(char *HTTP_response, void *callback_data_in, void *cal * December, 2017 */ herr_t -RV_get_link_val_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_link_val_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { - yajl_val parse_tree = NULL, key_obj; - size_t *in_buf_size = (size_t *)callback_data_in; - char *link_path; - char *link_class; - char *out_buf = (char *)callback_data_out; - herr_t ret_value = SUCCEED; + yajl_val parse_tree = NULL, key_obj; + get_link_val_out *get_link_val_args = (get_link_val_out *)callback_data_out; + size_t *in_buf_size = get_link_val_args->in_buf_size; + char *link_path; + char *link_class; + char *out_buf = get_link_val_args->buf; + herr_t ret_value = SUCCEED; #ifdef RV_CONNECTOR_DEBUG printf("-> Retrieving link's value from server's HTTP response\n\n"); @@ -1490,7 +1504,7 @@ RV_get_link_val_callback(char *HTTP_response, void *callback_data_in, void *call * September, 2017 */ herr_t -RV_get_link_obj_type_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_link_obj_type_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { H5I_type_t *obj_type = (H5I_type_t *)callback_data_out; yajl_val parse_tree = NULL, key_obj; @@ -1583,11 +1597,11 @@ RV_get_link_obj_type_callback(char *HTTP_response, void *callback_data_in, void * November, 2018 */ static herr_t -RV_get_link_name_by_idx_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_link_name_by_idx_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { link_name_by_idx_data *link_name_data = (link_name_by_idx_data *)callback_data_out; link_table_entry *link_table = NULL; - iter_data *by_idx_data = (iter_data *)callback_data_in; + const iter_data *by_idx_data = (const iter_data *)callback_data_in; size_t link_table_num_entries; int (*link_table_sort_func)(const void *, const void *); herr_t ret_value = SUCCEED; @@ -1684,11 +1698,11 @@ RV_get_link_name_by_idx_callback(char *HTTP_response, void *callback_data_in, vo * December, 2017 */ static herr_t -RV_link_iter_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_link_iter_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { link_table_entry *link_table = NULL; rv_hash_table_t *visited_link_table = NULL; - iter_data *link_iter_data = (iter_data *)callback_data_in; + const iter_data *link_iter_data = (const iter_data *)callback_data_in; size_t link_table_num_entries; herr_t ret_value = SUCCEED; @@ -2065,7 +2079,7 @@ RV_free_link_table(link_table_entry *link_table, size_t num_entries) * January, 2018 */ static herr_t -RV_traverse_link_table(link_table_entry *link_table, size_t num_entries, iter_data *link_iter_data, +RV_traverse_link_table(link_table_entry *link_table, size_t num_entries, const iter_data *link_iter_data, const char *cur_link_rel_path) { static size_t depth = 0; diff --git a/src/rest_vol_link.h b/src/rest_vol_link.h index 06cb6eec..76fba345 100644 --- a/src/rest_vol_link.h +++ b/src/rest_vol_link.h @@ -32,9 +32,10 @@ herr_t RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get herr_t RV_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req); -herr_t RV_get_link_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); -herr_t RV_get_link_val_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); -herr_t RV_get_link_obj_type_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +herr_t RV_get_link_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); +herr_t RV_get_link_val_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); +herr_t RV_get_link_obj_type_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); #ifdef __cplusplus } diff --git a/src/rest_vol_object.c b/src/rest_vol_object.c index e4ea4af6..cfd0f169 100644 --- a/src/rest_vol_object.c +++ b/src/rest_vol_object.c @@ -18,22 +18,23 @@ #include "rest_vol_object.h" /* Set of callbacks for RV_parse_response() */ -static herr_t RV_get_object_info_callback(char *HTTP_response, void *callback_data_in, +static herr_t RV_get_object_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out); /* Callback to iterate over objects given in HTTP response */ -static herr_t RV_object_iter_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out); +static herr_t RV_object_iter_callback(char *HTTP_response, const void *callback_data_in, + void *callback_data_out); /* Helper functions to work with a table of objects for object iteration */ static herr_t RV_build_object_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func)(const void *, const void *), object_table_entry **object_table, size_t *num_entries, - iter_data *object_iter_data, rv_hash_table_t *visited_link_table); + const iter_data *object_iter_data, rv_hash_table_t *visited_link_table); /* Function to go through each object in table and perform an operation */ static herr_t RV_traverse_object_table(object_table_entry *object_table, rv_hash_table_t *visited_object_table, size_t num_entries, - iter_data *iter_data, const char *cur_object_rel_path); + const iter_data *iter_data, const char *cur_object_rel_path); static void RV_free_object_table(object_table_entry *object_table, size_t num_entries); @@ -593,8 +594,8 @@ RV_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_ar CURL_PERFORM(curl, H5E_LINK, H5E_CANTGET, FAIL); if (0 > RV_parse_response(response_buffer.buffer, - (void *)&loc_params->loc_data.loc_by_idx, &found_object_name, - RV_copy_link_name_by_index)) + (const void *)&loc_params->loc_data.loc_by_idx, + &found_object_name, RV_copy_link_name_by_index)) FUNC_GOTO_ERROR(H5E_LINK, H5E_PARSEERROR, FAIL, "failed to retrieve link names"); if (host_header) { @@ -1214,7 +1215,7 @@ RV_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_s * November, 2017 */ static herr_t -RV_get_object_info_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_get_object_info_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { H5O_info2_t *obj_info = (H5O_info2_t *)callback_data_out; yajl_val parse_tree = NULL, key_obj; @@ -1381,12 +1382,12 @@ H5_rest_cmp_objects_by_creation_order_inc(const void *object1, const void *objec * May, 2023 */ herr_t -RV_object_iter_callback(char *HTTP_response, void *callback_data_in, void *callback_data_out) +RV_object_iter_callback(char *HTTP_response, const void *callback_data_in, void *callback_data_out) { object_table_entry *object_table = NULL; rv_hash_table_t *visited_link_table = NULL; rv_hash_table_t *visited_object_table = NULL; - iter_data *object_iter_data = (iter_data *)callback_data_in; + const iter_data *object_iter_data = (const iter_data *)callback_data_in; size_t object_table_num_entries = 0; herr_t ret_value = SUCCEED; char URL[URL_MAX_LENGTH]; @@ -1501,8 +1502,8 @@ RV_object_iter_callback(char *HTTP_response, void *callback_data_in, void *callb */ herr_t RV_build_object_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func)(const void *, const void *), - object_table_entry **object_table, size_t *num_entries, iter_data *object_iter_data, - rv_hash_table_t *visited_link_table) + object_table_entry **object_table, size_t *num_entries, + const iter_data *object_iter_data, rv_hash_table_t *visited_link_table) { object_table_entry *table = NULL; yajl_val parse_tree = NULL, key_obj; @@ -1920,7 +1921,8 @@ RV_free_object_table(object_table_entry *object_table, size_t num_entries) */ static herr_t RV_traverse_object_table(object_table_entry *object_table, rv_hash_table_t *visited_object_table, - size_t num_entries, iter_data *object_iter_data, const char *cur_object_rel_path) + size_t num_entries, const iter_data *object_iter_data, + const char *cur_object_rel_path) { herr_t ret_value = SUCCEED; static size_t depth = 0;