public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
* Building `rt-tests` v2.9 fails with `Werror=format-overflow`
@ 2026-01-03 17:27 Maximilian Bosch
  0 siblings, 0 replies; only message in thread
From: Maximilian Bosch @ 2026-01-03 17:27 UTC (permalink / raw)
  To: linux-rt-users

Hi!

On a GCC 15.2, compiling rt-tests 2.9 fails for me with the following
error:

    rt-tests> src/pmqtest/pmqtest.c: In function 'main':
    rt-tests> src/pmqtest/pmqtest.c:32:21: error: '__builtin___sprintf_chk' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
    rt-tests>    32 | #define TESTMQ_NAME "/testmsg%d"
    rt-tests>       |                     ^~~~~~~~~~~~
    rt-tests> src/pmqtest/pmqtest.c:644:33: note: in expansion of macro 'TESTMQ_NAME'
    rt-tests>   644 |                 sprintf(mqname, TESTMQ_NAME, i);
    rt-tests>       |                                 ^~~~~~~~~~~
    rt-tests> src/pmqtest/pmqtest.c:32:32: note: format string is defined here
    rt-tests>    32 | #define TESTMQ_NAME "/testmsg%d"
    rt-tests>       |                                ^

I assume this is

* 8 chars for /testmsg
* 10 chars for INT_MAX
* 1 char for a minus (this probably can't happen, but the compiler still
  takes it into account - I assume?)
* One nullbyte

Which can exceed the char pointer of 19 bytes by one byte.

While this is a case that won't happen (given the construction of the
for loop), the compiler still complains because of `-Werror`.

Best
Maximilian

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-01-03 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-03 17:27 Building `rt-tests` v2.9 fails with `Werror=format-overflow` Maximilian Bosch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox