Skip to content

Commit dd304b7

Browse files
committed
hwloc.h: add an error reporting section describing the common conventions
Refs #578 Signed-off-by: Brice Goglin <[email protected]>
1 parent b813cf0 commit dd304b7

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

doc/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ pdf_DATA = $(DOX_A4PDF) $(DOX_LETTERPDF)
253253
# list of dependencies too.
254254

255255
man3_MANS = \
256+
$(DOX_MAN_DIR)/man3/hwlocality_api_error_reporting.3 \
256257
$(DOX_MAN_DIR)/man3/hwlocality_api_version.3 \
257258
$(DOX_MAN_DIR)/man3/HWLOC_API_VERSION.3 \
258259
$(DOX_MAN_DIR)/man3/hwloc_get_api_version.3

include/hwloc.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@ extern "C" {
7777
#endif
7878

7979

80+
/** \defgroup hwlocality_api_error_reporting Error reporting in the API
81+
* @{
82+
* Most functions in the hwloc API return an integer value.
83+
* Unless documentated differently, they return 0 on success
84+
* and -1 on error.
85+
* Functions that return a pointer type return \c NULL on error.
86+
*
87+
* \p errno will be set to a meaningful value whenever possible.
88+
* This includes the usual \c EINVAL when invalid function parameters are passed
89+
* or \c ENOMEM when an internal allocation fails.
90+
* Some specific \c errno value are also used, for instance for binding
91+
* errors as documented in \ref hwlocality_cpubinding.
92+
*
93+
* Some modules describe return values of their functions
94+
* in their introduction, for instance in \ref hwlocality_bitmap.
95+
* @}
96+
*/
97+
98+
8099
/** \defgroup hwlocality_api_version API version
81100
* @{
82101
*/

include/hwloc/bitmap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ extern "C" {
5050
* hwloc_bitmap_free(set);
5151
* \endcode
5252
*
53-
* \note Most functions below return an int that may be negative in case of
54-
* error. The usual error case would be an internal failure to realloc/extend
53+
* \note Most functions below return 0 on success and -1 on error.
54+
* The usual error case would be an internal failure to realloc/extend
5555
* the storage of the bitmap (\p errno would be set to \c ENOMEM).
56+
* See also \ref hwlocality_api_error_reporting.
5657
*
5758
* \note Several examples of using the bitmap API are available under the
5859
* doc/examples/ directory in the source tree.

0 commit comments

Comments
 (0)