Skip to content

fix build failures#828

Open
sandy-lcq wants to merge 2 commits intoCOVESA:masterfrom
sandy-lcq:master
Open

fix build failures#828
sandy-lcq wants to merge 2 commits intoCOVESA:masterfrom
sandy-lcq:master

Conversation

@sandy-lcq
Copy link
Copy Markdown
Contributor

Fix build failures when -DWITH_SYSTEMD=ON, -DWITH_SYSTEMD_WATCHDOG=ON, -DWITH_SYSTEMD_JOURNAL=ON:
Eg:
src/system/dlt-system-syslog.c:91:39: error: conversion from 'int' to '__uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
91 | syslog_addr.sin6_port = htons(opts.Port);
| ~~~~^~~~~

src/system/dlt-system-logfile.c:74:21: error: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Werror=conversion]
74 | bytes = fread(buffer, 1, sizeof(buffer) - 1, pFile);
| ^~~~~

src/system/dlt-system-syslog.c:120:22: error: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Werror=conversion]
120 | int bytes_read = recvfrom(sock, recv_data, RECV_BUF_SZ, 0,
| ^~~~~~~~

src/system/dlt-system-logfile.c:76:23: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
76 | if (bytes >= 0)
| ^~

src/system/dlt-system-filetransfer.c:727:56: error: '__builtin___snprintf_chk' output may be truncated before the last format cha racter [-Werror=format-truncation=]
10 727 | snprintf(tosend, length, "%s/%s", opts->Directory[j], ie->name);

src/system/dlt-system-filetransfer.c:153: error: declaration of 'len' shadows a previous local [-Werror=shadow]

}

char *tosend = malloc(length);
#pragma GCC diagnostic push
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need proper fix

Copy link
Copy Markdown
Contributor Author

@sandy-lcq sandy-lcq Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for fixing failure:
error: '__builtin___snprintf_chk' output may be truncated before the last format character [-Werror=format-truncation=]

I have changed length to "size_t length = strlen(opts->Directory[j]) + strlen(ie->name) + 2;" , and then snprintf(tosend, length, "%s/%s", opts->Directory[j], ie->name); As I see, malloc tosend with length is enough. I don't understand why gcc still reported the failure, I did not find the proper way, so just skip it. Any suggestion? Thanks.

@sandy-lcq sandy-lcq changed the title fix build failure when systemd is enabled fix build failures Mar 18, 2026
@sandy-lcq
Copy link
Copy Markdown
Contributor Author

update the pull request title since I add another commit.

Fix build failures when -DWITH_SYSTEMD=ON, -DWITH_SYSTEMD_WATCHDOG=ON,
-DWITH_SYSTEMD_JOURNAL=ON:
Eg:
src/system/dlt-system-syslog.c:91:39: error: conversion from 'int' to '__uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
   91 |     syslog_addr.sin6_port = htons(opts.Port);
      |                                   ~~~~^~~~~

src/system/dlt-system-logfile.c:74:21: error: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Werror=conversion]
   74 |             bytes = fread(buffer, 1, sizeof(buffer) - 1, pFile);
      |                     ^~~~~

src/system/dlt-system-syslog.c:120:22: error: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Werror=conversion]
  120 |     int bytes_read = recvfrom(sock, recv_data, RECV_BUF_SZ, 0,
      |                      ^~~~~~~~

src/system/dlt-system-logfile.c:76:23: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
   76 |             if (bytes >= 0)
      |                       ^~

 src/system/dlt-system-filetransfer.c:727:56: error: '__builtin___snprintf_chk' output may be truncated before the last format cha    racter [-Werror=format-truncation=]
 10   727 |                         snprintf(tosend, length, "%s/%s", opts->Directory[j], ie->name);

src/system/dlt-system-filetransfer.c:153: error: declaration of 'len' shadows a previous local [-Werror=shadow]

Signed-off-by: Changqing Li <changqing.li@windriver.com>
src/shared/dlt_common.c:6477:17: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
|  6477 |     char *dot = strrchr(filename, '.');

[1] bminor/glibc@cd748a6

Signed-off-by: Changqing Li <changqing.li@windriver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants