Skip to content

Conversation

@minminlittleshrimp
Copy link
Collaborator

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.

Copy link

Copilot AI left a 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 calloc argument ordering throughout the codebase (nmemb, size)
  • Replaced unsafe strncpy/strncat patterns with snprintf for buffer safety
  • Corrected function return types from int to DltReturnValue for 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.

@minminlittleshrimp minminlittleshrimp force-pushed the dlt_devel_fix_cmake branch 6 times, most recently from 210935b to ad4d079 Compare November 5, 2025 20:20
Copy link

Copilot AI left a 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.

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);
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
snprintf(ctdesc, 255, "Test Context %02d", i + 1);
snprintf(ctdesc, sizeof(ctdesc), "Test Context %02d", i + 1);

Copilot uses AI. Check for mistakes.
if (gzflush(config->gzlog, Z_SYNC_FLUSH) != 0) {
dlt_vlog(LOG_ERR, "%s: failed to gzflush log file\n", __func__);
}
}
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
}
} else

Copilot uses AI. Check for mistakes.
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants