diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2022-04-13 21:17:29 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2022-04-13 21:17:29 (GMT) |
commit | cabc39c3e197e2591449d2604bfee26465fb60e1 (patch) | |
tree | d5f39f5f5965584bf9bf49646a2af617adfd3e4e /src/H5PL.c | |
parent | 7355f4c505092a7a85474b47f18d5206028e2c95 (diff) | |
parent | ab69f5df770ee3cc6cd6c81d905a5317b894a002 (diff) | |
download | hdf5-feature/coding_standards.zip hdf5-feature/coding_standards.tar.gz hdf5-feature/coding_standards.tar.bz2 |
Merge branch 'develop' into feature/coding_standardsfeature/coding_standards
Diffstat (limited to 'src/H5PL.c')
-rw-r--r-- | src/H5PL.c | 120 |
1 files changed, 53 insertions, 67 deletions
@@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,48 +14,39 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5PLpkg.h" /* Plugin */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5PLpkg.h" /* Plugin */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5PLset_loading_state * @@ -76,27 +67,26 @@ * the special "::" string. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ herr_t H5PLset_loading_state(unsigned int plugin_control_mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Iu", plugin_control_mask); /* Set the plugin control mask */ - if(H5PL__set_plugin_control_mask(plugin_control_mask) < 0) + if (H5PL__set_plugin_control_mask(plugin_control_mask) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "error setting plugin control mask") done: FUNC_LEAVE_API(ret_value) } /* end H5PLset_loading_state() */ - /*------------------------------------------------------------------------- * Function: H5PLget_loading_state * @@ -109,37 +99,36 @@ done: * Positive if one or more of the plugin types are enabled * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ herr_t -H5PLget_loading_state(unsigned int *plugin_control_mask) +H5PLget_loading_state(unsigned *plugin_control_mask /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("e", "*Iu", plugin_control_mask); + H5TRACE1("e", "x", plugin_control_mask); if (NULL == plugin_control_mask) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plugin_control_mask parameter cannot be NULL") /* Set the plugin control mask */ - if(H5PL__get_plugin_control_mask(plugin_control_mask) < 0) + if (H5PL__get_plugin_control_mask(plugin_control_mask) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error getting plugin control mask") done: FUNC_LEAVE_API(ret_value) } /* end H5PLget_loading_state() */ - /*------------------------------------------------------------------------- * Function: H5PLappend * * Purpose: Insert a plugin search path at the end of the list. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -165,14 +154,13 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLappend() */ - /*------------------------------------------------------------------------- * Function: H5PLprepend * * Purpose: Insert a plugin search path at the beginning of the list. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -198,7 +186,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLprepend() */ - /*------------------------------------------------------------------------- * Function: H5PLreplace * @@ -210,13 +197,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5PLreplace(const char *search_path, unsigned int index) +H5PLreplace(const char *search_path, unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "*sIu", search_path, index); + H5TRACE2("e", "*sIu", search_path, idx); /* Check args */ if (NULL == search_path) @@ -228,18 +215,18 @@ H5PLreplace(const char *search_path, unsigned int index) num_paths = H5PL__get_num_paths(); if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") - else if (index >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + else if (idx >= num_paths) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Insert the search path into the path table */ - if (H5PL__replace_path(search_path, index) < 0) + if (H5PL__replace_path(search_path, idx) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to replace search path") done: FUNC_LEAVE_API(ret_value) } /* end H5PLreplace() */ - /*------------------------------------------------------------------------- * Function: H5PLinsert * @@ -247,18 +234,18 @@ done: * other paths after the index. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ herr_t -H5PLinsert(const char *search_path, unsigned int index) +H5PLinsert(const char *search_path, unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "*sIu", search_path, index); + H5TRACE2("e", "*sIu", search_path, idx); /* Check args */ if (NULL == search_path) @@ -268,56 +255,56 @@ H5PLinsert(const char *search_path, unsigned int index) /* Check index */ num_paths = H5PL__get_num_paths(); - if ((0 != num_paths) && (index >= num_paths)) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + if ((0 != num_paths) && (idx >= num_paths)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Insert the search path into the path table */ - if (H5PL__insert_path(search_path, index) < 0) + if (H5PL__insert_path(search_path, idx) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to insert search path") done: FUNC_LEAVE_API(ret_value) } /* end H5PLinsert() */ - /*------------------------------------------------------------------------- * Function: H5PLremove * - * Purpose: Remove the plugin path at the specifed index and compact + * Purpose: Remove the plugin path at the specified index and compact * the list. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * * Return: Non-negative or success. * *------------------------------------------------------------------------- */ herr_t -H5PLremove(unsigned int index) +H5PLremove(unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("e", "Iu", index); + H5TRACE1("e", "Iu", idx); /* Check index */ num_paths = H5PL__get_num_paths(); if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") - else if (index >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + else if (idx >= num_paths) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Delete the search path from the path table */ - if (H5PL__remove_path(index) < 0) + if (H5PL__remove_path(idx) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTDELETE, FAIL, "unable to remove search path") done: FUNC_LEAVE_API(ret_value) } /* end H5PLremove() */ - /*------------------------------------------------------------------------- * Function: H5PLget * @@ -343,35 +330,36 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5PLget(unsigned int index, char *path_buf, size_t buf_size) +H5PLget(unsigned int idx, char *path_buf, size_t buf_size) { - unsigned num_paths; /* Current number of stored paths */ - const char *path = NULL; /* path from table */ - size_t path_len = 0; /* Length of path */ - ssize_t ret_value = 0; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + const char *path = NULL; /* path from table */ + size_t path_len = 0; /* Length of path */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("Zs", "Iu*sz", index, path_buf, buf_size); + H5TRACE3("Zs", "Iu*sz", idx, path_buf, buf_size); /* Check index */ num_paths = H5PL__get_num_paths(); if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") - else if (index >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + else if (idx >= num_paths) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Check if the search table is empty */ if (H5PL__get_num_paths() == 0) HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, (-1), "plugin search path table is empty") /* Get the path at the specified index and its length */ - if (NULL == (path = H5PL__get_path(index))) + if (NULL == (path = H5PL__get_path(idx))) HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, (-1), "no path stored at that index") path_len = HDstrlen(path); /* If the path buffer is not NULL, copy the path to the buffer */ if (path_buf) { - HDstrncpy(path_buf, path, MIN((size_t)(path_len + 1), buf_size)); + HDstrncpy(path_buf, path, buf_size); if ((size_t)path_len >= buf_size) path_buf[buf_size - 1] = '\0'; } /* end if */ @@ -383,7 +371,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLget() */ - /*------------------------------------------------------------------------- * Function: H5PLsize * @@ -412,4 +399,3 @@ H5PLsize(unsigned int *num_paths) done: FUNC_LEAVE_API(ret_value) } /* end H5PLsize() */ - |