Skip to content

Commit 0d74116

Browse files
lib/, src/, tests/: Rename snprintf() to stprintf()
For consistency with strTcpy(), call it sTprintf(). Signed-off-by: Alejandro Colomar <alx@kernel.org>
1 parent 62d3f05 commit 0d74116

File tree

24 files changed

+116
-116
lines changed

24 files changed

+116
-116
lines changed

lib/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ libshadow_la_SOURCES = \
188188
sssd.h \
189189
string/memset/memzero.c \
190190
string/memset/memzero.h \
191-
string/sprintf/snprintf.c \
192-
string/sprintf/snprintf.h \
193191
string/sprintf/stpeprintf.c \
194192
string/sprintf/stpeprintf.h \
193+
string/sprintf/stprintf.c \
194+
string/sprintf/stprintf.h \
195195
string/sprintf/xasprintf.c \
196196
string/sprintf/xasprintf.h \
197197
string/strchr/strchrcnt.c \

lib/commonio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "shadowlog_internal.h"
3636
#include "sssd.h"
3737
#include "string/memset/memzero.h"
38-
#include "string/sprintf/snprintf.h"
38+
#include "string/sprintf/stprintf.h"
3939
#include "string/strcmp/streq.h"
4040
#include "string/strtok/stpsep.h"
4141

@@ -146,7 +146,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
146146
}
147147

148148
pid = getpid ();
149-
SNPRINTF(buf, "%lu", (unsigned long) pid);
149+
STPRINTF(buf, "%lu", (unsigned long) pid);
150150
len = (ssize_t) strlen (buf) + 1;
151151
if (write_full(fd, buf, len) == -1) {
152152
if (log) {
@@ -347,7 +347,7 @@ static void free_linked_list (struct commonio_db *db)
347347

348348
int commonio_setname (struct commonio_db *db, const char *name)
349349
{
350-
SNPRINTF(db->filename, "%s", name);
350+
STPRINTF(db->filename, "%s", name);
351351
db->setname = true;
352352
return 1;
353353
}
@@ -490,7 +490,7 @@ int commonio_unlock (struct commonio_db *db)
490490
* then call ulckpwdf() (if used) on last unlock.
491491
*/
492492
db->locked = false;
493-
SNPRINTF(lock, "%s.lock", db->filename);
493+
STPRINTF(lock, "%s.lock", db->filename);
494494
unlink (lock);
495495
dec_lock_count ();
496496
return 1;
@@ -924,7 +924,7 @@ int commonio_close (struct commonio_db *db)
924924
/*
925925
* Create backup file.
926926
*/
927-
if (SNPRINTF(buf, "%s-", db->filename) == -1) {
927+
if (STPRINTF(buf, "%s-", db->filename) == -1) {
928928
(void) fclose (db->fp);
929929
db->fp = NULL;
930930
goto fail;
@@ -961,7 +961,7 @@ int commonio_close (struct commonio_db *db)
961961
sb.st_gid = db->st_gid;
962962
}
963963

964-
if (SNPRINTF(buf, "%s+", db->filename) == -1)
964+
if (STPRINTF(buf, "%s+", db->filename) == -1)
965965
goto fail;
966966

967967
#ifdef WITH_SELINUX

lib/env.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "prototypes.h"
2222
#include "defines.h"
2323
#include "shadowlog.h"
24-
#include "string/sprintf/snprintf.h"
24+
#include "string/sprintf/stprintf.h"
2525
#include "string/sprintf/xasprintf.h"
2626
#include "string/strdup/xstrdup.h"
2727

@@ -168,7 +168,7 @@ void set_env (int argc, char *const *argv)
168168

169169
cp = strchr (*argv, '=');
170170
if (NULL == cp) {
171-
assert(SNPRINTF(variable, "L%d", noname) != -1);
171+
assert(STPRINTF(variable, "L%d", noname) != -1);
172172
noname++;
173173
addenv (variable, *argv);
174174
} else {

lib/get_pid.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <fcntl.h>
1515

1616
#include "atoi/getnum.h"
17-
#include "string/sprintf/snprintf.h"
17+
#include "string/sprintf/stprintf.h"
1818

1919

2020
/*
@@ -59,8 +59,8 @@ int open_pidfd(const char *pidstr)
5959
return -ENOENT;
6060

6161
/* max string length is 6 + 10 + 1 + 1 = 18, allocate 32 bytes */
62-
if (SNPRINTF(proc_dir_name, "/proc/%u/", target) == -1) {
63-
fprintf(stderr, "snprintf of proc path failed for %u: %s\n",
62+
if (STPRINTF(proc_dir_name, "/proc/%u/", target) == -1) {
63+
fprintf(stderr, "stprintf of proc path failed for %u: %s\n",
6464
target, strerror(errno));
6565
return -EINVAL;
6666
}

lib/hushed.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "defines.h"
2121
#include "getdef.h"
2222
#include "prototypes.h"
23-
#include "string/sprintf/snprintf.h"
23+
#include "string/sprintf/stprintf.h"
2424
#include "string/strcmp/streq.h"
2525
#include "string/strtok/stpsep.h"
2626

@@ -60,7 +60,7 @@ bool hushed (const char *username)
6060
*/
6161

6262
if (hushfile[0] != '/') {
63-
SNPRINTF(buf, "%s/%s", pw->pw_dir, hushfile);
63+
STPRINTF(buf, "%s/%s", pw->pw_dir, hushfile);
6464
return (access (buf, F_OK) == 0);
6565
}
6666

lib/nss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "../libsubid/subid.h"
1515
#include "shadowlog_internal.h"
1616
#include "shadowlog.h"
17-
#include "string/sprintf/snprintf.h"
17+
#include "string/sprintf/stprintf.h"
1818
#include "string/strchr/stpspn.h"
1919
#include "string/strcmp/streq.h"
2020
#include "string/strtok/stpsep.h"
@@ -107,7 +107,7 @@ nss_init(const char *nsswitch_path) {
107107
fprintf(shadow_logfd, "Using files\n");
108108
goto null_subid;
109109
}
110-
SNPRINTF(libname, "libsubid_%s.so", p);
110+
STPRINTF(libname, "libsubid_%s.so", p);
111111
h = dlopen(libname, RTLD_LAZY);
112112
if (!h) {
113113
fprintf(shadow_logfd, "Error opening %s: %s\n", libname, dlerror());

lib/pwauth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "pwauth.h"
2626
#include "getdef.h"
2727
#include "string/memset/memzero.h"
28-
#include "string/sprintf/snprintf.h"
28+
#include "string/sprintf/stprintf.h"
2929
#include "string/strcmp/streq.h"
3030

3131
#ifdef SKEY
@@ -111,7 +111,7 @@ pw_auth(const char *cipher, const char *user)
111111
}
112112
#endif
113113

114-
SNPRINTF(prompt, cp, user);
114+
STPRINTF(prompt, cp, user);
115115
clear = agetpass(prompt);
116116
input = (clear == NULL) ? "" : clear;
117117

lib/shell.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <errno.h>
1616
#include "prototypes.h"
1717
#include "defines.h"
18-
#include "string/sprintf/snprintf.h"
18+
#include "string/sprintf/stprintf.h"
1919

2020

2121
extern char **newenvp;
@@ -48,7 +48,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
4848
* don't want to tell us what it is themselves.
4949
*/
5050
if (arg == NULL) {
51-
SNPRINTF(arg0, "-%s", Basename(file));
51+
STPRINTF(arg0, "-%s", Basename(file));
5252
arg = arg0;
5353
}
5454

@@ -74,7 +74,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
7474
* how to execute this stupid shell, so I might as well give
7575
* up in disgust ...
7676
*/
77-
SNPRINTF(arg0, _("Cannot execute %s"), file);
77+
STPRINTF(arg0, _("Cannot execute %s"), file);
7878
errno = err;
7979
perror (arg0);
8080
return err;

lib/string/sprintf/stpeprintf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <stddef.h>
1313

1414
#include "attr.h"
15-
#include "string/sprintf/snprintf.h"
15+
#include "string/sprintf/stprintf.h"
1616

1717

1818
#if !defined(HAVE_STPEPRINTF)
@@ -98,7 +98,7 @@ vstpeprintf(char *dst, char *end, const char *restrict fmt, va_list ap)
9898
return NULL;
9999

100100
size = end - dst;
101-
len = vsnprintf_(dst, size, fmt, ap);
101+
len = vstprintf(dst, size, fmt, ap);
102102
if (len == -1)
103103
return NULL;
104104

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
#include <config.h>
66

7-
#include "string/sprintf/snprintf.h"
7+
#include "string/sprintf/stprintf.h"
88

99
#include <stdarg.h>
1010

1111

12-
extern inline int snprintf_(char *restrict s, int size,
12+
extern inline int stprintf(char *restrict s, int size,
1313
const char *restrict fmt, ...);
14-
extern inline int vsnprintf_(char *restrict s, int size,
14+
extern inline int vstprintf(char *restrict s, int size,
1515
const char *restrict fmt, va_list ap);

0 commit comments

Comments
 (0)