[CORE] Eliminate compile warnings - #4155
Conversation
|
@devarajabc This pr addresses compiler‑warnings. |
| readCpuinfo(&box64_sysinfo); | ||
|
|
||
| char branding[3 * 4 * 4 + 1]; | ||
| char branding[64]; |
There was a problem hiding this comment.
why 64? 344+1 is exactly the size the branding should be (3 sets of 4 32bits registers) + terminal 0
There was a problem hiding this comment.
The actual output of this statement can exceed 49 bytes, hence the warning shown below.
snprintf(branding, sizeof(branding), "Box64 v0.4.3 on %.\*s", 39, box64\_sysinfo.cpuname);
/usr/include/riscv64-linux-gnu/bits/stdio2.h:68:10: note: ‘__builtin___snprintf_chk’ output between 27 and 55 bytes into a destination of size 49
| return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| __va_arg_pack ());
There was a problem hiding this comment.
I have fixed the issue in a separate commit. It make no sense to build a brand bigger than needed.
There was a problem hiding this comment.
Sorry, your changes did not fully eliminate the warning.
- At line 190, only 31 characters are available for
cpuname; - At lines 193 and 195, only 21 characters can be printed for
cpuname, since@%1.2f GHzconsumes 10 characters.
This is not a fatal overflow. Because snprintf enforces the buffer‑size limit, real buffer overflow cannot happen. The warning only suggests potential truncation of output. There is no impact even without a fix.
/usr/include/riscv64-linux-gnu/bits/stdio2.h:68:10: note: ‘__builtin___snprintf_chk’ output between 17 and 49 bytes into a destination of size 48
68 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70 | __va_arg_pack ());
/usr/include/riscv64-linux-gnu/bits/stdio2.h:68:10: note: ‘__builtin___snprintf_chk’ output between 27 and 55 bytes into a destination of size 48
68 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70 | __va_arg_pack ());
3b504d2 to
fe0b0a5
Compare
1. `vasprintf` can return a negative value and `buff` may be NULL. 2. The `events` argument in `epoll_pwait` must not be NULL. 3. The size of `val.f.q` is 64 bits.
As per ptitSeb's requirements, patches addressing compiler warnings may only be merged after the 0.4.4 release. This PR is solely for pre‑review at this stage.
vasprintfcan return a negative value andbuffmay be NULL.The
eventsargument inepoll_pwaitmust not be NULL.The size of
val.f.qis 64 bits.