Skip to content

[CORE] Eliminate compile warnings - #4155

Draft
zengdage wants to merge 1 commit into
ptitSeb:mainfrom
zengdage:fix-warnings
Draft

[CORE] Eliminate compile warnings#4155
zengdage wants to merge 1 commit into
ptitSeb:mainfrom
zengdage:fix-warnings

Conversation

@zengdage

@zengdage zengdage commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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.

  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.

@zengdage
zengdage marked this pull request as draft July 30, 2026 01:42
@zengdage

Copy link
Copy Markdown
Contributor Author

@devarajabc This pr addresses compiler‑warnings.

Comment thread src/emu/x87emu_private.c Outdated
Comment thread src/os/sysinfo.c Outdated
readCpuinfo(&box64_sysinfo);

char branding[3 * 4 * 4 + 1];
char branding[64];

@ptitSeb ptitSeb Jul 30, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why 64? 344+1 is exactly the size the branding should be (3 sets of 4 32bits registers) + terminal 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 ());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I have fixed the issue in a separate commit. It make no sense to build a brand bigger than needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, your changes did not fully eliminate the warning.

  1. At line 190, only 31 characters are available for cpuname;
  2. At lines 193 and 195, only 21 characters can be printed for cpuname, since @%1.2f GHz consumes 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 ());

@zengdage
zengdage force-pushed the fix-warnings branch 2 times, most recently from 3b504d2 to fe0b0a5 Compare July 31, 2026 01:44
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.
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