fix build failures - #828
Conversation
| } | ||
|
|
||
| char *tosend = malloc(length); | ||
| #pragma GCC diagnostic push |
There was a problem hiding this comment.
Need proper fix
There was a problem hiding this comment.
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.
|
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>
|
Please resolve conflict, btw, I not yet satisfy with the gcc push pop to avoid truncation checking, we might need proper fix |
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]