lib/, src/: Use SNPRINTF() instead of its pattern

The variable declarations for the buffers have been aligned in this
commit, so that they appear in the diff, making it easier to review.

Some important but somewhat tangent changes included in this commit:

-  lib/nss.c: The size was being defined as 65, but then used as 64.
   That was a bug, although not an important one; we were just wasting
   one byte.  Fix that while we replace snprintf() by SNPRINTF(), which
   will get the size from sizeof(), and thus will use the real size.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-08-26 12:32:32 +02:00
committed by Iker Pedrosa
parent 8c6634d9bc
commit cf9cc6963c
18 changed files with 159 additions and 165 deletions
+5 -2
View File
@@ -15,6 +15,9 @@
#include <errno.h>
#include "prototypes.h"
#include "defines.h"
#include "string/sprintf.h"
extern char **newenvp;
extern size_t newenvc;
@@ -45,7 +48,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* don't want to tell us what it is themselves.
*/
if (arg == NULL) {
snprintf(arg0, sizeof(arg0), "-%s", Basename(file));
SNPRINTF(arg0, "-%s", Basename(file));
arg = arg0;
}
@@ -71,7 +74,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* how to execute this stupid shell, so I might as well give
* up in disgust ...
*/
(void) snprintf (arg0, sizeof arg0, _("Cannot execute %s"), file);
SNPRINTF(arg0, _("Cannot execute %s"), file);
errno = err;
perror (arg0);
return err;