-
Notifications
You must be signed in to change notification settings - Fork 319
cmake: Fix build errors and warnings #782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR resolves build errors and warnings when compiling with strict flags like -Werror. The changes primarily address string handling issues, function signature mismatches, and proper null-termination to ensure code builds cleanly under strict compilation settings.
Key changes:
- Fixed
callocargument ordering throughout the codebase (nmemb, size) - Replaced unsafe
strncpy/strncatpatterns withsnprintffor buffer safety - Corrected function return types from
inttoDltReturnValuefor consistency - Added proper null-termination and buffer overflow checks
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/dlt_multiple_files.c | Replaced strncat chain with snprintf and added buffer overflow check |
| src/shared/dlt_config_file_parser.c | Fixed calloc argument order (nmemb, size) |
| src/shared/dlt_common.c | Changed return type from int to DltReturnValue for consistency |
| src/offlinelogstorage/dlt_offline_logstorage_behavior.c | Added buffer length validation and replaced unsafe string operations with snprintf; fixed gzflush call with proper gzip guard |
| src/offlinelogstorage/dlt_offline_logstorage.c | Systematically replaced strncpy/strncat with snprintf for safer string handling |
| src/lib/dlt_user.c | Fixed calloc argument order and added buffer length checks before snprintf calls |
| src/gateway/dlt_gateway.h | Changed return types from int to DltReturnValue |
| src/gateway/dlt_gateway.c | Updated function signatures to match header declarations |
| src/examples/dlt-example-user.c | Fixed calloc argument order |
| src/daemon/dlt_daemon_common.c | Added buffer length check before snprintf |
| src/daemon/dlt-daemon.c | Added buffer length checks before snprintf calls |
| src/console/dlt-passive-node-ctrl.c | Fixed strncpy to prevent buffer overrun and ensure null-termination |
| include/dlt/dlt_client.h | Changed return types from int to DltReturnValue |
| CMakeLists.txt | Enabled -Werror flag to enforce strict compilation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
210935b to
ad4d079
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/components/logstorage/logstorage_fsync/logstorage_fsync.cpp
Outdated
Show resolved
Hide resolved
| snprintf(ctid, DLT_ID_SIZE+1, "CT%02d", i + 1); | ||
| char ctid[16], ctdesc[255]; | ||
| snprintf(ctid, sizeof(ctid), "CT%02d", i + 1); | ||
| snprintf(ctdesc, 255, "Test Context %02d", i + 1); |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent use of sizeof() for buffer size. Line 38 uses sizeof(ctid) correctly, but line 39 uses the hardcoded value 255 instead of sizeof(ctdesc). Use sizeof(ctdesc) for consistency and safety.
| snprintf(ctdesc, 255, "Test Context %02d", i + 1); | |
| snprintf(ctdesc, sizeof(ctdesc), "Test Context %02d", i + 1); |
tests/components/logstorage/disable_network/disable_network.cpp
Outdated
Show resolved
Hide resolved
| if (gzflush(config->gzlog, Z_SYNC_FLUSH) != 0) { | ||
| dlt_vlog(LOG_ERR, "%s: failed to gzflush log file\n", __func__); | ||
| } | ||
| } |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditional fsync call on line 1138 will attempt to sync config->log even when gzip compression is enabled and config->gzlog is being used instead. This should be wrapped in an else block or another conditional to ensure it only runs when gzip is not active.
| } | |
| } else |
ad4d079 to
3e512ae
Compare
The rework addresses multiple build errors and warnings encountered under strict compilation flags (e.g., -Werror). The following issues were resolved: - Pointer type errors in gzflush calls are now wrapped in #ifdef DLT_LOGSTORAGE_USE_GZIP to ensure correct compilation when GZIP support is enabled. - String truncation and buffer overflow warnings in logstorage path and filename handling are fixed by using snprintf and proper length checks. - The inline keyword was removed from the declaration of dlt_user_is_logLevel_enabled to match its definition and resolve unused inline warnings. - The node_id buffer in passive node control is now properly null-terminated after strncpy to prevent truncation warnings. - The argument order for calloc in dlt-example-user.c was corrected to avoid transposed-args warnings. Signed-off-by: lum3hc <[email protected]>
3e512ae to
d04b745
Compare
The rework addresses multiple build
errors and warnings encountered under
strict compilation flags (e.g., -Werror).
The following issues were resolved:
to ensure correct compilation when GZIP support is enabled.
fixed by using snprintf and proper length checks.
truncation warnings.