From d6560486c708e4a8426edfcfb66e923404a586a8 Mon Sep 17 00:00:00 2001 From: Matthew Larson Date: Mon, 3 Jul 2023 13:55:37 -0500 Subject: [PATCH] Update based on comments; fix warnings --- examples/rv_attribute.c | 4 +- examples/rv_compound.c | 2 +- examples/rv_extlink.c | 2 +- examples/rv_select.c | 2 +- src/rest_vol.c | 143 +++++++++++++--------------------------- src/rest_vol.h | 5 +- src/rest_vol_attr.c | 10 +-- src/rest_vol_dataset.c | 4 +- src/rest_vol_group.c | 4 +- src/rest_vol_link.c | 2 +- src/rest_vol_object.c | 33 ++++------ 11 files changed, 73 insertions(+), 138 deletions(-) diff --git a/examples/rv_attribute.c b/examples/rv_attribute.c index 0ba33fad..87d0d80f 100644 --- a/examples/rv_attribute.c +++ b/examples/rv_attribute.c @@ -289,8 +289,8 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata) if (H5T_FLOAT == H5Tget_class(atype)) { printf("Type : FLOAT \n"); - npoints = H5Sget_simple_extent_npoints(aspace); - float_array = (float *)malloc(sizeof(float) * (int)npoints); + npoints = (size_t) H5Sget_simple_extent_npoints(aspace); + float_array = (float *)malloc(sizeof(float) * (size_t)npoints); ret = H5Aread(attr, atype, float_array); printf("Values : "); for (i = 0; i < (int)npoints; i++) diff --git a/examples/rv_compound.c b/examples/rv_compound.c index 39ba9c39..7cedbdd6 100644 --- a/examples/rv_compound.c +++ b/examples/rv_compound.c @@ -67,7 +67,7 @@ main(void) */ for (i = 0; i < LENGTH; i++) { s1[i].a = i; - s1[i].b = i * i; + s1[i].b = (float) (i * i); s1[i].c = 1. / (i + 1); } diff --git a/examples/rv_extlink.c b/examples/rv_extlink.c index 8f6577fc..ee32e60d 100644 --- a/examples/rv_extlink.c +++ b/examples/rv_extlink.c @@ -530,7 +530,7 @@ plist_link_example(void) hid_t file_id; hid_t group_id, group2_id; hid_t gapl_id; - char *path = NULL; + const char *path = NULL; /* Define the link class that we'll use to register "plist * links" using the callback we defined above. diff --git a/examples/rv_select.c b/examples/rv_select.c index d226b5bd..62db300a 100644 --- a/examples/rv_select.c +++ b/examples/rv_select.c @@ -103,7 +103,7 @@ main(void) */ vector[0] = vector[MSPACE1_DIM - 1] = -1; for (i = 1; i < MSPACE1_DIM - 1; i++) - vector[i] = i; + vector[i] = (int) i; username = getenv("HSDS_USERNAME"); diff --git a/src/rest_vol.c b/src/rest_vol.c index 816e4f0e..1ad36f6b 100644 --- a/src/rest_vol.c +++ b/src/rest_vol.c @@ -542,6 +542,12 @@ H5rest_term(void) if (H5_rest_attr_table_iter_err_min_g >= 0 && H5Eclose_msg(H5_rest_attr_table_iter_err_min_g) < 0) FUNC_DONE_ERROR(H5E_VOL, H5E_CLOSEERROR, FAIL, "can't unregister error message for iterating over attribute table"); + if (H5_rest_attr_table_iter_err_min_g >= 0 && H5Eclose_msg(H5_rest_object_table_err_min_g) < 0) + FUNC_DONE_ERROR(H5E_VOL, H5E_CLOSEERROR, FAIL, + "can't unregister error message for build object table"); + if (H5_rest_attr_table_iter_err_min_g >= 0 && H5Eclose_msg(H5_rest_object_table_iter_err_min_g) < 0) + FUNC_DONE_ERROR(H5E_VOL, H5E_CLOSEERROR, FAIL, + "can't unregister error message for iterating over object table"); if (H5Eunregister_class(H5_rest_err_class_g) < 0) FUNC_DONE_ERROR(H5E_VOL, H5E_CLOSEERROR, FAIL, "can't unregister from HDF5 error API"); @@ -1482,7 +1488,7 @@ H5_rest_dirname(const char *path) * January, 2018 */ static char * -H5_rest_url_encode_path(const char *path) +H5_rest_url_encode_path(const char *_path) { ptrdiff_t buf_ptrdiff; size_t bytes_nalloc; @@ -1492,14 +1498,20 @@ H5_rest_url_encode_path(const char *path) char *url_encoded_path_component = NULL; char *token; char *cur_pos; + char *path = NULL; _path; char *tmp_buffer = NULL; char *ret_value = NULL; - if (!path) + if (!_path) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "path was NULL"); + if ((path = RV_malloc(strlen(_path) + 1)) == NULL) + FUNC_GOTO_ERROR(H5E_PATH, H5E_CANTALLOC, NULL, "can't allocate memory for path copy"); + + strncpy(path, _path, strlen(_path) + 1); + /* Retrieve the length of the possible path prefix, which could be something like '/', '.', etc. */ - cur_pos = (char *)path; + cur_pos = path; while (*cur_pos && !isalnum(*cur_pos)) cur_pos++; path_prefix_len = (size_t)(cur_pos - path); @@ -1617,6 +1629,8 @@ H5_rest_url_encode_path(const char *path) RV_free(tmp_buffer); if (path_copy) RV_free(path_copy); + if (path) + RV_free(path); return ret_value; } /* end H5_rest_url_encode_path() */ @@ -1958,12 +1972,12 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t char *path_dirname = NULL; char *tmp_link_val = NULL; char *url_encoded_path_name = NULL; - char *ext_filename = NULL; - char *ext_obj_path = NULL; + const char *ext_filename = NULL; + const char *ext_obj_path = NULL; char request_url[URL_MAX_LENGTH]; long http_response; int url_len = 0; - server_api_version version = parent_obj->domain->u.file.server_version; + server_api_version version; htri_t ret_value = FAIL; @@ -1982,6 +1996,8 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t object_type_to_string(parent_obj->obj_type), parent_obj->URI); #endif + version = parent_obj->domain->u.file.server_version; + /* In order to not confuse the server, make sure the path has no leading spaces */ while (*obj_path == ' ') obj_path++; @@ -2049,8 +2065,6 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t if (H5I_UNINIT == *target_object_type) { /* Set up intermediate request to get information about object type via link */ - const char *ext_filename = NULL; - const char *ext_obj_path = NULL; hbool_t empty_dirname; htri_t search_ret; char *pobj_URI = parent_obj->URI; @@ -2100,7 +2114,7 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t /* Craft the request URL based on the type of the object we're looking for and whether or not * the path given is a relative path or not. */ - char *parent_obj_type_header = NULL; + const char *parent_obj_type_header = NULL; if (RV_set_object_type_header(*target_object_type, &parent_obj_type_header) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -2231,7 +2245,7 @@ RV_find_object_by_path(RV_object_t *parent_obj, const char *obj_path, H5I_type_t if (H5L_TYPE_EXTERNAL == link_info.type) { /* Unpack the external link's value buffer */ - if (H5Lunpack_elink_val(tmp_link_val, link_val_len, NULL, &ext_filename, &ext_obj_path) < + if (H5Lunpack_elink_val(tmp_link_val, link_val_len, NULL, &ext_filename, (const char **) &ext_obj_path) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't unpack external link's value buffer"); @@ -2335,15 +2349,14 @@ RV_parse_creation_properties_callback(yajl_val parse_tree, char **GCPL_buf_out) if (NULL == (GCPL_buf_local = RV_malloc(strlen(parsed_string) + 1))) FUNC_GOTO_ERROR(H5E_OBJECT, H5E_CANTALLOC, FAIL, "failed to allocate memory for creationProperties"); - if (NULL == (memcpy(GCPL_buf_local, parsed_string, strlen(parsed_string) + 1))) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_SYSERRSTR, FAIL, "failed to copy creationProperties"); + memcpy(GCPL_buf_local, parsed_string, strlen(parsed_string) + 1); *GCPL_buf_out = GCPL_buf_local; done: if (ret_value < 0) { - free(GCPL_buf_local); + RV_free(GCPL_buf_local); GCPL_buf_local = NULL; } @@ -2464,7 +2477,7 @@ RV_copy_object_loc_info_callback(char *HTTP_response, void *callback_data_in, vo sizeof(server_api_version)); if (RV_file_close(loc_info_out->domain, H5P_DEFAULT, NULL) < 0) - FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, + FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "failed to allocate memory for new domain path"); loc_info_out->domain = new_domain; @@ -2504,17 +2517,22 @@ RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, void *ca 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 = idx_params->n; + 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"); + if (!link_name) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "given link_name ptr was NULL"); if (!HTTP_response) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HTTP response buffer was NULL"); + index = idx_params->n; + if (NULL == (parse_tree = yajl_tree_parse(HTTP_response, NULL, 0))) FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "parsing JSON failed"); @@ -2549,7 +2567,6 @@ RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, void *ca /* Iterate through key/value pairs in link response to find name */ for (size_t i = 0; i < link_obj->u.object.len; i++) { curr_key = link_obj->u.object.keys[i]; - if (!strcmp(curr_key, "title")) if (NULL == (parsed_link_name = YAJL_GET_STRING(link_obj->u.object.values[i]))) FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "failed to get link name"); @@ -2570,88 +2587,14 @@ RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, void *ca yajl_tree_free(parse_tree); if (ret_value < 0) { - RV_free(*link_name); - *link_name = NULL; + RV_free(parsed_link_buffer); + parsed_link_buffer = NULL; } return ret_value; } /* end RV_copy_link_name_by_index() */ -/*------------------------------------------------------------------------- - * Function: RV_copy_link_URI_by_index - * - * Purpose: This callback is used to copy the URI of an link - * in the server's response by index, to a provided buffer. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Matthew Larson - * May, 2023 - */ -herr_t -RV_copy_link_URI_by_index(char *HTTP_response, void *callback_data_in, void *callback_data_out) -{ - yajl_val parse_tree = NULL, key_obj = NULL, link_obj = NULL; - const char *parsed_link_URI = NULL; - H5VL_loc_by_idx_t *idx_params = (H5VL_loc_by_idx_t *)callback_data_in; - hsize_t index = idx_params->n; - char **link_URI = (char **)callback_data_out; - const char *curr_key = NULL; - herr_t ret_value = SUCCEED; - - if (!HTTP_response) - FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HTTP response buffer was NULL"); - - if (NULL == (parse_tree = yajl_tree_parse(HTTP_response, NULL, 0))) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "parsing JSON failed"); - - if (NULL == (key_obj = yajl_tree_get(parse_tree, links_keys, yajl_t_array))) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "failed to parse links"); - - if (key_obj->u.array.len == 0) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "parsed link array was empty"); - - if (index >= key_obj->u.array.len) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "requested link index was out of bounds"); - - switch (idx_params->order) { - case (H5_ITER_DEC): - if (NULL == (link_obj = key_obj->u.array.values[key_obj->u.object.len - 1 - index])) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "selected link was NULL"); - break; - - case (H5_ITER_NATIVE): - case (H5_ITER_INC): - case (H5_ITER_N): - case (H5_ITER_UNKNOWN): - default: { - if (NULL == (link_obj = key_obj->u.array.values[index])) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "selected link was NULL"); - break; - } - } - - /* Iterate through key/value pairs in link response to find URI */ - for (size_t i = 0; i < link_obj->u.object.len; i++) { - curr_key = link_obj->u.object.keys[i]; - - if (!strcmp(curr_key, "id")) - if (NULL == (parsed_link_URI = YAJL_GET_STRING(link_obj->u.object.values[i]))) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "failed to get link URI"); - } - - if (NULL == parsed_link_URI) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "server response didn't contain link URI"); - - if (NULL == (memcpy(*link_URI, parsed_link_URI, strlen(parsed_link_URI) + 1))) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "failed to copy link URI"); -done: - if (parse_tree) - yajl_tree_free(parse_tree); - - return ret_value; -} /* end RV_copy_link_URI_by_index() */ /*------------------------------------------------------------------------- * Function: RV_copy_attribute_name_by_index @@ -2669,7 +2612,7 @@ herr_t RV_copy_attribute_name_by_index(char *HTTP_response, void *callback_data_in, void *callback_data_out) { yajl_val parse_tree = NULL, key_obj; - char *parsed_string = NULL; + 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 = idx_params->n; @@ -2695,20 +2638,26 @@ RV_copy_attribute_name_by_index(char *HTTP_response, void *callback_data_in, voi FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "requested attribute index was out of bounds"); switch (idx_params->order) { + case (H5_ITER_DEC): if (NULL == (parsed_string = key_obj->u.object.keys[key_obj->u.object.len - 1 - index])) FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "selected attribute had NULL name"); break; case (H5_ITER_NATIVE): - case (H5_ITER_INC): + case (H5_ITER_INC): { + if (NULL == (parsed_string = key_obj->u.object.keys[index])) + FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "selected attribute had NULL name"); + break; + } + case (H5_ITER_N): case (H5_ITER_UNKNOWN): default: { - if (NULL == (parsed_string = key_obj->u.object.keys[index])) - FUNC_GOTO_ERROR(H5E_OBJECT, H5E_PARSEERROR, FAIL, "selected attribute had NULL name"); + FUNC_GOTO_ERROR(H5E_OBJECT, H5E_BADVALUE, FAIL, "invalid iteration order"); break; } + } if (NULL == (parsed_string_buffer = RV_malloc(strlen(parsed_string) + 1))) @@ -3442,7 +3391,7 @@ RV_free_visited_link_hash_table_key(rv_hash_table_key_t value) * May, 2023 */ herr_t -RV_set_object_type_header(H5I_type_t parent_obj_type, char **parent_obj_type_header) +RV_set_object_type_header(H5I_type_t parent_obj_type, const char **parent_obj_type_header) { herr_t ret_value = SUCCEED; diff --git a/src/rest_vol.h b/src/rest_vol.h index a2280241..4adc8d69 100644 --- a/src/rest_vol.h +++ b/src/rest_vol.h @@ -606,9 +606,6 @@ herr_t RV_copy_link_name_by_index(char *HTTP_response, void *callback_data_in, v /* 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); -/* Callback for RV_parse_response() to copy the id of a hard link to a buffer */ -herr_t RV_copy_link_URI_by_index(char *HTTP_response, 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, @@ -633,7 +630,7 @@ int H5_rest_compare_string_keys(void *value1, void *value2); void RV_free_visited_link_hash_table_key(rv_hash_table_key_t value); /* Helper to turn an object type into a string for a server request */ -herr_t RV_set_object_type_header(H5I_type_t parent_obj_type, char **parent_obj_type_header); +herr_t RV_set_object_type_header(H5I_type_t parent_obj_type, const char **parent_obj_type_header); #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 57393950..504c1ad1 100644 --- a/src/rest_vol_attr.c +++ b/src/rest_vol_attr.c @@ -393,7 +393,7 @@ RV_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_na size_t attr_name_len = 0; size_t host_header_len = 0; char *host_header = NULL; - const char *found_attr_name = NULL; + char *found_attr_name = NULL; char request_url[URL_MAX_LENGTH]; char *url_encoded_attr_name = NULL; const char *parent_obj_type_header = NULL; @@ -573,7 +573,7 @@ RV_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_na CURL_PERFORM(curl, H5E_ATTR, H5E_CANTGET, NULL); - if (0 > RV_parse_response(response_buffer.buffer, (void *)&loc_params->loc_data.loc_by_idx, + if (0 > RV_parse_response(response_buffer.buffer, (const void *) &loc_params->loc_data.loc_by_idx, &found_attr_name, RV_copy_attribute_name_by_index)) FUNC_GOTO_ERROR(H5E_ATTR, H5E_PARSEERROR, NULL, "failed to retrieve attribute names"); @@ -620,7 +620,7 @@ RV_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_na * operation contains no illegal characters */ - char *target_attr_name = found_attr_name ? found_attr_name : attr_name; + const char *target_attr_name = found_attr_name ? (const char *) found_attr_name : attr_name; attr_name_len = strlen(target_attr_name); if (NULL == (url_encoded_attr_name = curl_easy_escape(curl, target_attr_name, (int)attr_name_len))) @@ -1368,7 +1368,7 @@ RV_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req) request_idx_type = "&CreateOrder=1"; } else { - FUNC_GOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, + FUNC_GOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "indexing by creation order not supported by server versions " "before 0.8.0"); } @@ -1558,7 +1558,7 @@ RV_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req) request_idx_type = "&CreateOrder=1"; } else { - FUNC_GOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, + FUNC_GOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "indexing by creation order not supported by server versions " "before 0.8.0"); } diff --git a/src/rest_vol_dataset.c b/src/rest_vol_dataset.c index 656284bb..105c94d0 100644 --- a/src/rest_vol_dataset.c +++ b/src/rest_vol_dataset.c @@ -871,7 +871,7 @@ RV_dataset_write(size_t count, void *dset[], hid_t mem_type_id[], hid_t mem_spac * go ahead and allocate a buffer 4/3 the size of the given write buffer * in order to try and avoid reallocations inside the encoding function. */ - value_body_len = ((double)4.0 / 3.0) * write_body_len; + value_body_len = (size_t) ((4.0 / 3.0) * (double) write_body_len); if (NULL == (base64_encoded_value = RV_malloc(value_body_len))) FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate temporary buffer for base64-encoded write buffer"); @@ -3346,7 +3346,7 @@ RV_convert_dataspace_selection_to_string(hid_t space_id, char **selection_string FUNC_GOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate space for hyperslab selection 'block' values"); - size_t body_size = (size_t)ndims * MAX_NUM_LENGTH + ndims; + size_t body_size = (size_t) ndims * MAX_NUM_LENGTH + (size_t) ndims; if (NULL == (start_body = (char *)RV_calloc(body_size))) FUNC_GOTO_ERROR( diff --git a/src/rest_vol_group.c b/src/rest_vol_group.c index 3107e983..4903f9ff 100644 --- a/src/rest_vol_group.c +++ b/src/rest_vol_group.c @@ -388,8 +388,8 @@ RV_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, "failed to retrieve creation properties from response"); } - if (RV_base64_decode(loc_info_out.GCPL_base64, strlen(loc_info_out.GCPL_base64), &binary_gcpl, - &binary_gcpl_size) < 0) + if (RV_base64_decode(loc_info_out.GCPL_base64, strlen(loc_info_out.GCPL_base64), (char **) &binary_gcpl, + binary_gcpl_size) < 0) FUNC_GOTO_ERROR(H5E_OBJECT, H5E_CANTDECODE, NULL, "can't decode gcpl from base64"); /* Set up a GCPL for the group, so that API calls like H5Gget_create_plist() will work */ diff --git a/src/rest_vol_link.c b/src/rest_vol_link.c index 418d157b..a9122915 100644 --- a/src/rest_vol_link.c +++ b/src/rest_vol_link.c @@ -664,7 +664,7 @@ RV_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_args_t RV_get_link_name_by_idx_callback) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link name by index"); - *ret_size = (ssize_t)link_name_data.link_name_len; + *ret_size = (size_t)link_name_data.link_name_len; break; } /* H5VL_LINK_GET_NAME */ diff --git a/src/rest_vol_object.c b/src/rest_vol_object.c index 50fcf732..9c7532a6 100644 --- a/src/rest_vol_object.c +++ b/src/rest_vol_object.c @@ -495,7 +495,7 @@ RV_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_ar request_idx_type = "&CreateOrder=1"; } else { - FUNC_GOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, + FUNC_GOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "indexing by creation order not supported by server versions " "before 0.8.0"); } @@ -705,7 +705,8 @@ RV_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_s size_t host_header_len = 0; hid_t iter_object_id = H5I_INVALID_HID; char visit_by_name_URI[URI_MAX_LENGTH]; - char *target_object_name = NULL; + const char *target_object_name = NULL; + H5O_info2_t oinfo; #ifdef RV_CONNECTOR_DEBUG printf("-> Received object-specific call with following parameters:\n"); @@ -734,9 +735,8 @@ RV_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_s /* H5Ovisit(_by_name) */ case H5VL_OBJECT_VISIT: { - char *parent_object_header = NULL; + const char *parent_object_header = NULL; iter_data object_iter_data; - H5O_info2_t oinfo; hsize_t idx_p = 0; object_iter_data.index_type = args->args.visit.idx_type; @@ -844,8 +844,8 @@ RV_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_s } /* end H5Ovisit H5VL_OBJECT_BY_SELF */ case (H5VL_OBJECT_BY_NAME): { - // make a request in order to figure out how to open the iter object, set header string, - // and iter object type + /* Make a request to figure out how to open iter object, set header string, + * and iter object type */ if (RV_find_object_by_path(loc_obj, loc_params->loc_data.loc_by_name.name, &iter_object_type, RV_copy_object_URI_callback, NULL, visit_by_name_URI) < 0) @@ -1015,7 +1015,6 @@ RV_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_s if (callback_ret < 0) { FUNC_GOTO_ERROR(H5E_LINK, H5E_CALLBACK, callback_ret, "H5Oiterate/H5Ovisit (_by_name) user callback failed for target object "); - // A return value > 0 from callback ends iteration early } else if (callback_ret > 0) { FUNC_GOTO_DONE(callback_ret); @@ -1070,7 +1069,6 @@ RV_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_s case H5I_DATASET: case H5I_DATATYPE: /* Execute callback on object */ - H5O_info2_t oinfo; if (RV_parse_response(response_buffer.buffer, NULL, &oinfo, RV_get_object_info_callback) < 0) @@ -1286,11 +1284,6 @@ H5_rest_cmp_objects_by_creation_order_inc(const void *object1, const void *objec return ((_object1->crt_time > _object2->crt_time) - (_object1->crt_time < _object2->crt_time)); } /* end H5_rest_cmp_objects_by_creation_order_inc() */ -void -RV_free_visited_object_hash_table_key(rv_hash_table_key_t value) -{ -} - /*------------------------------------------------------------------------- * Function: RV_object_iter_callback * @@ -1566,9 +1559,6 @@ RV_build_object_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func /* Getting the link URI from the manually-manipulated links section requires a unique callback */ - // if (RV_parse_response(HTTP_buffer, &loc_params, &table[i].object_URI, - // RV_copy_link_URI_by_index) < 0) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "failed to get - // object URI from hard link"); char *link_id_ptr = link_section_start; char recent1 = '\0'; @@ -1586,12 +1576,12 @@ RV_build_object_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func link_id_ptr++; } - // curr points at d in "id": - link_id_ptr += 5; // points at first letter of id - // traverse until ending quote + /* Move the pointer from the "d" in "id" the start of the id itself in the response. */ + link_id_ptr += 5; + char *id_end_ptr = strstr(link_id_ptr, "\""); - size_t id_len = id_end_ptr - link_id_ptr; + size_t id_len = (size_t) (id_end_ptr - link_id_ptr); memcpy(table[i].object_URI, link_id_ptr, id_len); table[i].object_URI[id_len] = '\0'; @@ -1624,8 +1614,7 @@ RV_build_object_table(char *HTTP_response, hbool_t is_recursive, int (*sort_func table[i].subgroup.subgroup_object_table = NULL; if (is_recursive && (H5L_TYPE_HARD == table[i].link_info.type)) { char *link_collection; - int url_len = 0; - + if (NULL == (link_field_obj = yajl_tree_get(link_obj, link_collection_keys2, yajl_t_string))) FUNC_GOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "retrieval of link collection failed");