Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 2, 2023
1 parent 58c2506 commit 97a5600
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/rest_vol.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,10 @@ void RV_free_visited_link_hash_table_key(rv_hash_table_key_t value);

#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) || \
(version.major == major_needed && version.minor == minor_needed && version.patch >= patch_needed) \
(version.major == major_needed && version.minor == minor_needed && version.patch >= patch_needed)

#define SERVER_VERISON_SUPPORTS_FILL_VALUE_ENCODING(version) (SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 1))
#define SERVER_VERISON_SUPPORTS_FILL_VALUE_ENCODING(version) \
(SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 1))

#ifdef __cplusplus
}
Expand Down
59 changes: 33 additions & 26 deletions src/rest_vol_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ static herr_t RV_setup_dataset_create_request_body(void *parent_obj, const char
size_t *create_request_body_len);

static herr_t RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl_id, char **creation_properties_body,
size_t *creation_properties_body_len, hid_t type_id, server_api_version version);
size_t *creation_properties_body_len,
hid_t type_id, server_api_version version);

/* Helper function to convert a selection within an HDF5 Dataspace into a JSON-format string */
static herr_t RV_convert_dataspace_selection_to_string(hid_t space_id, char **selection_string,
Expand Down Expand Up @@ -1838,7 +1839,8 @@ RV_parse_dataset_creation_properties_callback(char *HTTP_response, void *callbac
*/
static herr_t
RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl, char **creation_properties_body,
size_t *creation_properties_body_len, hid_t type_id, server_api_version version)
size_t *creation_properties_body_len, hid_t type_id,
server_api_version version)
{
const char *const leading_string = "\"creationProperties\": {";
H5D_alloc_time_t alloc_time;
Expand All @@ -1850,11 +1852,11 @@ RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl, char **creation_prope
char *out_string = NULL;
char *out_string_curr_pos; /* The "current position" pointer used to print to the appropriate place
in the buffer and not overwrite important leading data */
int bytes_printed = 0;
void *fill_value = NULL;
char *encode_buf_out = NULL;
char *fill_value_str = NULL;
herr_t ret_value = SUCCEED;
int bytes_printed = 0;
void *fill_value = NULL;
char *encode_buf_out = NULL;
char *fill_value_str = NULL;
herr_t ret_value = SUCCEED;

#ifdef RV_CONNECTOR_DEBUG
printf("-> Converting dataset creation properties from DCPL to JSON\n\n");
Expand Down Expand Up @@ -2086,8 +2088,8 @@ RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl, char **creation_prope
******************************************************************/
{
H5D_fill_value_t fill_status;
size_t fill_value_size = 0;
size_t encode_buf_out_size = 0;
size_t fill_value_size = 0;
size_t encode_buf_out_size = 0;

if (H5Pfill_value_defined(dcpl, &fill_status) < 0)
FUNC_GOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve the \"fill value defined\" status");
Expand All @@ -2111,33 +2113,36 @@ RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl, char **creation_prope

strncat(out_string_curr_pos, null_value, null_value_len);
out_string_curr_pos += null_value_len;
} else if (H5D_FILL_VALUE_USER_DEFINED == fill_status) {
}
else if (H5D_FILL_VALUE_USER_DEFINED == fill_status) {
if (!(SERVER_VERISON_SUPPORTS_FILL_VALUE_ENCODING(version)))
FUNC_GOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "server API version %zu.%zu.%zu does not support fill value encoding\n", version.major, version.minor, version.patch);
FUNC_GOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"server API version %zu.%zu.%zu does not support fill value encoding\n",
version.major, version.minor, version.patch);

if ((fill_value_size = H5Tget_size(type_id)) == 0)
FUNC_GOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get the size of fill value type");

if ((fill_value = RV_malloc(fill_value_size)) == NULL)
FUNC_GOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for fill value");
FUNC_GOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for fill value");

if (H5Pget_fill_value(dcpl, type_id, fill_value) < 0)
FUNC_GOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "can't get fill value from creation properties");

FUNC_GOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL,
"can't get fill value from creation properties");

if (RV_base64_encode(fill_value, fill_value_size, &encode_buf_out, &encode_buf_out_size) < 0)
FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "can't base64-encode fill value");

/* Add encoded fill value to request body */
size_t fill_value_str_len = strlen(", \"fillValue\": ") + strlen("\"") + strlen(encode_buf_out) + strlen("\"");
size_t fill_value_str_len =
strlen(", \"fillValue\": ") + strlen("\"") + strlen(encode_buf_out) + strlen("\"");

if ((fill_value_str = RV_calloc(fill_value_str_len + 1)) == NULL)
FUNC_GOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for fill value string in request body");
FUNC_GOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL,
"can't allocate space for fill value string in request body");

snprintf(fill_value_str, fill_value_str_len + 1, "%s%s%s%s",
", \"fillValue\": ",
"\"",
encode_buf_out,
"\"");
snprintf(fill_value_str, fill_value_str_len + 1, "%s%s%s%s", ", \"fillValue\": ", "\"",
encode_buf_out, "\"");

/* Check whether the buffer needs to be grown */
bytes_to_print = fill_value_str_len;
Expand Down Expand Up @@ -2171,9 +2176,10 @@ RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl, char **creation_prope

strncat(out_string, encoding_property, strlen(encoding_property));
out_string_curr_pos += strlen(encoding_property);

} else {
FUNC_GOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve the \"fill value defined\" status");
}
else {
FUNC_GOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,
"can't retrieve the \"fill value defined\" status");
} /* end else */
} /* end if */
}
Expand Down Expand Up @@ -3011,7 +3017,8 @@ RV_setup_dataset_create_request_body(void *parent_obj, const char *name, hid_t t
"layout H5D_CONTIGUOUS is unsupported for server versions before 0.8.0");

if (RV_convert_dataset_creation_properties_to_JSON(dcpl, &creation_properties_body,
&creation_properties_body_len, type_id, pobj->domain->u.file.server_version) < 0)
&creation_properties_body_len, type_id,
pobj->domain->u.file.server_version) < 0)
FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL,
"can't convert Dataset Creation Properties to JSON representation");
}
Expand Down

0 comments on commit 97a5600

Please sign in to comment.