]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/stdio-util: use a fixed message in xsprintf
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jul 2025 10:44:06 +0000 (12:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jul 2025 11:02:37 +0000 (13:02 +0200)
commit048a94c8f606706fbb42882f7b559cd982eb3914
treecc8cf46fc16e8da82135dcdc1c9c68694800355e
parent1e99c4e2be7bf27ca2bc14b528232aef0b1715aa
basic/stdio-util: use a fixed message in xsprintf

We put the name of the variable in the message, but it is a local variable
and the name does not have global meaning. We end up with pointless copies
of the error string:

$ strings build/libsystemd.so.0.40.0 | grep 'big enough'
xsprintf: p[] must be big enough
xsprintf: error[] must be big enough
xsprintf: prefix[] must be big enough
xsprintf: pty[] must be big enough
xsprintf: mode[] must be big enough
xsprintf: t[] must be big enough
xsprintf: s[] must be big enough
xsprintf: spid[] must be big enough
xsprintf: header_priority[] must be big enough
xsprintf: header_pid[] must be big enough
xsprintf: path[] must be big enough
xsprintf: buf[] must be big enough

The error message already shows the file, line, and function name, which
is enough to identify the problem:

  Assertion 'xsprintf: buffer too small' failed at src/test/test-string-util.c:20, function test_xsprintf(). Aborting.
src/basic/stdio-util.h