]> git.ipfire.org Git - thirdparty/systemd.git/commit
string-util: simplify logic in strjoin_real()
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 30 Oct 2020 09:13:27 +0000 (10:13 +0100)
committerRasmus Villemoes <rasmus.villemoes@prevas.dk>
Tue, 3 Nov 2020 13:25:28 +0000 (14:25 +0100)
commit020003f235ca2e5e7897b4bd1d4a0dba7c463b08
tree6179ca9720a7b14854c49d03cde72a18d28d018b
parentcd2065989163a5b6f71c8f1e4a8d73f1be63a52b
string-util: simplify logic in strjoin_real()

The loops over (x, then all varargs, until a NULL is found) can be written much
simpler with an ordinary for loop. Just initialize the loop variable to x, test
that, and in the increment part, fetch the next va_arg(). That removes a level
of indentation, and avoids doing a separate strlen()/stpcpy() call for x.

While touching this code anyway, change (size_t)-1 to the more readable
SIZE_MAX.
src/basic/string-util.c