From 825b82dffc321b9c607133c8d207d972bdf1cebf Mon Sep 17 00:00:00 2001 From: huangyuchen Date: Thu, 19 Jan 2023 19:51:14 +0800 Subject: [PATCH] Add doc comments for ErrCode-related files(errors.h, common_errors.h, common_timer_errors.h) Issue: I6BBDJ Test: NA Signed-off-by: huangyuchen Change-Id: I670b2571c321cdcca9f29df5ff328f08f9457fc6 --- base/include/common_errors.h | 14 ++++++++++++++ base/include/common_timer_errors.h | 18 ++++++++++++++++++ base/include/errors.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/base/include/common_errors.h b/base/include/common_errors.h index 2758bff..2f63ee4 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 2d244af..9c90ccd 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 9dadfa0..56f61fc 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, -- Gitee