fix: [log] verbosity configuration initialization order#404
Closed
add-uos wants to merge 0 commit into
Closed
Conversation
deepin pr auto review我对这段代码进行了审查,以下是我的分析和改进建议:
if(my_options->verbosity >= 0 && my_options->verbosity <= 3) // 假设最大值为3
my_config->verbosity = my_options->verbosity;
else if(strcmp(token, "verbosity") == 0)
{
char *endptr;
long val = strtol(value, &endptr, 10);
if (endptr == value || *endptr != '\0') {
// 处理转换错误
fprintf(stderr, "Invalid verbosity value\n");
continue;
}
my_config.verbosity = (int)val;
}
int verbosity; /* Debug verbosity level (0=none, 1=normal, 2=detailed, 3=verbose) */
#define VERBOSITY_NONE 0
#define VERBOSITY_NORMAL 1
#define VERBOSITY_DETAILED 2
#define VERBOSITY_VERBOSE 3总体而言,这次改动添加了verbosity功能,实现了配置的保存和加载,逻辑清晰。但需要注意边界条件的处理和代码安全性。 |
67de34d to
d2d696e
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: Fix debug level configuration loading sequence