fix: [log] verbosity configuration initialization order#438
Merged
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom Dec 18, 2025
Merged
fix: [log] verbosity configuration initialization order#438deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
Conversation
- Added verbosity field to config structure for persistent storage - Fixed initialization sequence to load verbosity from config before updating options - Ensured debug level is set from saved configuration rather than default options - Maintained configuration file compatibility with new verbosity parameter Log: Fix debug level configuration loading sequence v20 BUG 分支合一到v25主线 Task: https://pms.uniontech.com/task-view-383481.html
Reviewer's GuideAdds a persistent verbosity field to the camera configuration, wires it through load/save/update, and changes initialization so the debug log level is taken from the saved config before options are applied. Sequence diagram for updated camInit configuration and debug level initializationsequenceDiagram
participant camInit
participant config_module
participant options_t
participant config_t
participant debug_level
camInit->>config_module: config_load(config_file)
activate config_module
config_module->>config_t: populate_from_file(verbosity, other_fields)
deactivate config_module
camInit->>config_module: config_get()
config_module-->>camInit: config_t
camInit->>debug_level: set_from(config_t.verbosity)
camInit->>options_t: options_t.verbosity = config_t.verbosity
camInit->>config_module: config_update(options_t)
activate config_module
config_module->>config_t: apply_options_verbosity(options_t.verbosity)
deactivate config_module
Class diagram for updated camera configuration verbosity handlingclassDiagram
class config_t {
char* device_name
char* device_location
uint32_t format
char* render
char* gui
char* audio
char* capture
char* video_codec
char* audio_codec
char* profile_name
char* profile_path
char* video_name
char* video_path
char* photo_name
char* photo_path
int video_sufix
int photo_sufix
int fps_num
int fps_denom
int audio_device
uint32_t video_fx
uint32_t audio_fx
uint32_t osd_mask
uint32_t crosshair_color
int verbosity
}
class options_t {
int verbosity
}
class debug_level {
int level
}
config_t "1" -- "1" options_t : synchronized_verbosity
debug_level "1" -- "1" config_t : initialized_from
debug_level "1" -- "1" options_t : updated_to_match
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- There’s a new tab/space inconsistency introduced in
config_save(thesetlocaleline is now indented with a tab and misaligned relative to surrounding code); please align it with the existing indentation style in this file. - Now that
verbosityis persisted and read from config, double-check that any default/initial values forconfig_t.verbosityandoptions_t.verbosityare consistently initialized sodebug_levelis never derived from an unintentionally uninitialized or sentinel value.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There’s a new tab/space inconsistency introduced in `config_save` (the `setlocale` line is now indented with a tab and misaligned relative to surrounding code); please align it with the existing indentation style in this file.
- Now that `verbosity` is persisted and read from config, double-check that any default/initial values for `config_t.verbosity` and `options_t.verbosity` are consistently initialized so `debug_level` is never derived from an unintentionally uninitialized or sentinel value.
## Individual Comments
### Comment 1
<location> `libcam/libcam/cameraconfig.c:315-317` </location>
<code_context>
free(my_config.photo_path);
my_config.photo_path = strdup(value);
}
+ else if(strcmp(token, "verbosity") == 0)
+ {
+ my_config.verbosity = (int) strtoul(value, NULL, 10);
+ }
// else if(strcmp(token, "video_sufix") == 0)
</code_context>
<issue_to_address>
**issue (bug_risk):** Parsing verbosity with strtoul and casting to int can mis-handle negative or out-of-range values.
Using `strtoul` here means negative inputs are parsed as large positive values, and very large values can overflow when cast to `int` (implementation-defined). If you need to support negative sentinel values or just ensure safe bounds, prefer `strtol`, validate the range against `INT_MIN`/`INT_MAX`, and clamp or reject invalid values before assigning to `my_config.verbosity`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…e logging - Add decode performance monitoring that measures and logs decode time every 5 operations - Reduce verbose logging frequency in JPEG decoder to print every 5th frame instead of every frame - Include QElapsedTimer header for timing functionality - Maintain existing behavior when verbosity is disabled v20 BUG 分支合一到v25主线 Task: https://pms.uniontech.com/task-view-383481.html
deepin pr auto review我来对这个 diff 进行详细的代码审查:
建议改进:
// 在 jpeg_decoder.c 中
static _Atomic int decodeCount = 0; // 使用原子变量
// 在 majorimageprocessingthread.cpp 中
// 将计数器作为类成员变量
class MajorImageProcessingThread {
private:
int decodeCount = 0;
QElapsedTimer decodeTimer;
};
// 在 config_load() 中
else if(strcmp(token, "verbosity") == 0)
{
unsigned long val = strtoul(value, NULL, 10);
if (val <= INT_MAX) {
my_config.verbosity = (int)val;
} else {
// 处理错误情况
my_config.verbosity = 0;
}
}
这些改进将使代码更加健壮、安全和可维护。 |
lzwind
approved these changes
Dec 18, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lichaofan2008, lzwind 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 |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
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
v20 BUG 分支合一到v25主线
Task: https://pms.uniontech.com/task-view-383481.html
Summary by Sourcery
Persist and load the log verbosity level through the camera configuration so the runtime debug level respects saved settings.
New Features:
Bug Fixes:
Enhancements: