diff --git a/base/include/common_errors.h b/base/include/common_errors.h index 2758bff1206c74ea32a6c4eb6d99c5526ef3e513..2f63ee4a4c16d8142d9379a6ef2d403f968569fd 100644 --- a/base/include/common_errors.h +++ b/base/include/common_errors.h @@ -13,6 +13,13 @@ * limitations under the License. */ + /** + * @file common_errors.h + * + * @brief Provide value of 'Module' segment of ErrCode for all modules in + * commonlibrary subsystem. + */ + #ifndef UTILS_COMMON_ERRORS_H #define UTILS_COMMON_ERRORS_H @@ -31,6 +38,13 @@ namespace Utils { * In this file, subsystem is "SUBSYS_COMMON". */ +/** + * @brief Value of 'Module' segment of ErrCode for modules in commonlibrary + * subsystem. + * + * @var MODULE_DEFAULT Default + * @var MODULE_TIMER Timer(timer.h) + */ enum { MODULE_DEFAULT = 0, MODULE_TIMER = 1 diff --git a/base/include/common_timer_errors.h b/base/include/common_timer_errors.h index 2d244af20054dfb902e50c3089e3638d9268ea52..9c90ccd1a428d73cf6807f259e6c4f6b4d1390ac 100644 --- a/base/include/common_timer_errors.h +++ b/base/include/common_timer_errors.h @@ -13,6 +13,13 @@ * limitations under the License. */ + /** + * @file common_timer_errors.h + * + * @brief Provide value of 'Code' segment of ErrCode for 'Timer' module in + * commonlibrary subsystem. + */ + #ifndef UTILS_COMMON_TIMER_ERRORS_H #define UTILS_COMMON_TIMER_ERRORS_H @@ -38,8 +45,19 @@ namespace Utils { using ErrCode = int; // offset of timer module error, only be used in this file. +/** + * @brief Base ErrCode of module 'Timer' in commonlibrary subsystem. + */ constexpr ErrCode COMMON_TIMER_ERR_OFFSET = ErrCodeOffset(SUBSYS_COMMON, MODULE_TIMER); +/** + * @brief Value of 'Code' segment of ErrCode for 'Timer'. + * + * @var TIMER_ERR_OK Success. + * @var TIMER_ERR_DEAL_FAILED Deal failed. + * @var TIMER_ERR_BADF Bad file descriptor. + * @var TIMER_ERR_INVALID_VALUE Invalid value. + */ enum { TIMER_ERR_OK = 0, TIMER_ERR_DEAL_FAILED = COMMON_TIMER_ERR_OFFSET + EAGAIN, diff --git a/base/include/errors.h b/base/include/errors.h index 9dadfa0d189478765378994399f4b94f1f903f11..56f61fc2508a108a107a18b9a08080ecd4c3e270 100644 --- a/base/include/errors.h +++ b/base/include/errors.h @@ -13,6 +13,12 @@ * limitations under the License. */ + /** + * @file errors.h + * + * @brief Provide format of error code in OpenHarmony. + */ + #ifndef UTILS_BASE_ERRORS_H #define UTILS_BASE_ERRORS_H @@ -32,6 +38,9 @@ namespace OHOS { using ErrCode = int; +/** + * @brief Value of 'Subsystem' segment of ErrCode for every subsystem. + */ enum { SUBSYS_COMMON = 0, SUBSYS_AAFWK = 1, @@ -87,6 +96,15 @@ enum { }; // be used to init the subsystem errorno. +/** + * @brief Generate base error code for a specified module in specified + * subsystem. + * + * @param subsystem Value of 'Subsystem' segment. + * @param module Value of 'Module' segment, + * which is 0 by default. + * @return Return base ErrCode for specified module. + */ constexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0) { constexpr int SUBSYSTEM_BIT_NUM = 21; @@ -95,8 +113,18 @@ constexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0) } // offset of common error, only be used in this file. +/** + * @brief Base ErrCode of common(valid for all modules) + * in commonlibrary subsystem. + */ constexpr ErrCode BASE_ERR_OFFSET = ErrCodeOffset(SUBSYS_COMMON); +/** + * @brief Value of common 'Code' segment of ErrCode + * in commonlibrary subsystem. + * + * @see Related error codes defined in errno.h + */ enum { ERR_OK = 0, ERR_NO_MEMORY = BASE_ERR_OFFSET + ENOMEM,