[PATCH 1/3] fix literal error warning
manuel.f.zerpies at ww.stud.uni-erlangen.de
manuel.f.zerpies at ww.stud.uni-erlangen.de
Tue Jul 31 13:15:49 UTC 2012
From: Manuel Zerpies <manuel.f.zerpies at ww.stud.uni-erlangen.de>
compiling with gcc >= 4.4.3 the warning "format not a string literal
and no format arguments" is thrown. This patch fixes that.
Signed-off-by: Manuel Zerpies <manuel.f.zerpies at ww.stud.uni-erlangen.de>
---
applets/usage_pod.c | 2 +-
archival/libarchive/data_extract_to_command.c | 2 +-
coreutils/expand.c | 2 +-
coreutils/od_bloaty.c | 2 +-
coreutils/stat.c | 4 ++--
libbb/create_icmp6_socket.c | 4 ++--
libbb/create_icmp_socket.c | 4 ++--
libbb/dump.c | 4 ++--
libbb/fflush_stdout_and_exit.c | 2 +-
libbb/wfopen.c | 2 +-
libbb/xfuncs_printf.c | 12 ++++++------
loginutils/addgroup.c | 2 +-
loginutils/adduser.c | 2 +-
loginutils/chpasswd.c | 2 +-
loginutils/deluser.c | 2 +-
miscutils/crontab.c | 2 +-
networking/ntpd.c | 2 +-
networking/traceroute.c | 2 +-
networking/udhcp/arpping.c | 2 +-
networking/wget.c | 2 +-
shell/hush.c | 2 +-
sysklogd/logread.c | 2 +-
util-linux/mount.c | 12 ++++++------
23 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/applets/usage_pod.c b/applets/usage_pod.c
index 0b1c4aa..a67e8b4 100644
--- a/applets/usage_pod.c
+++ b/applets/usage_pod.c
@@ -71,7 +71,7 @@ int main(void)
} else {
printf(", ");
}
- printf(usage_array[i].aname);
+ printf("%s", usage_array[i].aname);
col += len2;
}
printf("\n\n");
diff --git a/archival/libarchive/data_extract_to_command.c b/archival/libarchive/data_extract_to_command.c
index a2ce33b..354e958 100644
--- a/archival/libarchive/data_extract_to_command.c
+++ b/archival/libarchive/data_extract_to_command.c
@@ -38,7 +38,7 @@ static const char *const tar_var[] = {
static void xputenv(char *str)
{
if (putenv(str))
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
}
static void str2env(char *env[], int idx, const char *str)
diff --git a/coreutils/expand.c b/coreutils/expand.c
index 25bbffc..ac5ad5b 100644
--- a/coreutils/expand.c
+++ b/coreutils/expand.c
@@ -227,7 +227,7 @@ int expand_main(int argc UNUSED_PARAM, char **argv)
/* Now close stdin also */
/* (if we didn't read from it, it's a no-op) */
if (fclose(stdin))
- bb_perror_msg_and_die(bb_msg_standard_input);
+ bb_perror_msg_and_die("%s", bb_msg_standard_input);
fflush_stdout_and_exit(exit_status);
}
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 2f66501..2917a08 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -1378,7 +1378,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
dump(n_bytes_to_skip, end_offset);
if (fclose(stdin))
- bb_perror_msg_and_die(bb_msg_standard_input);
+ bb_perror_msg_and_die("%s", bb_msg_standard_input);
return exit_code;
}
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 3fb212f..f0a61d9 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -442,7 +442,7 @@ static bool do_statfs(const char *filename, const char *format)
: getfilecon(filename, &scontext)
) < 0
) {
- bb_perror_msg(filename);
+ bb_perror_msg("%s", filename);
return 0;
}
}
@@ -555,7 +555,7 @@ static bool do_stat(const char *filename, const char *format)
: getfilecon(filename, &scontext)
) < 0
) {
- bb_perror_msg(filename);
+ bb_perror_msg("%s", filename);
return 0;
}
}
diff --git a/libbb/create_icmp6_socket.c b/libbb/create_icmp6_socket.c
index 368c690..bdee7a0 100644
--- a/libbb/create_icmp6_socket.c
+++ b/libbb/create_icmp6_socket.c
@@ -26,8 +26,8 @@ int FAST_FUNC create_icmp6_socket(void)
#endif
if (sock < 0) {
if (errno == EPERM)
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
+ bb_perror_msg_and_die("%s", bb_msg_can_not_create_raw_socket);
}
/* drop root privs if running setuid */
diff --git a/libbb/create_icmp_socket.c b/libbb/create_icmp_socket.c
index 5856269..65eea3b 100644
--- a/libbb/create_icmp_socket.c
+++ b/libbb/create_icmp_socket.c
@@ -25,8 +25,8 @@ int FAST_FUNC create_icmp_socket(void)
#endif
if (sock < 0) {
if (errno == EPERM)
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
+ bb_perror_msg_and_die("%s", bb_msg_can_not_create_raw_socket);
}
/* drop root privs if running setuid */
diff --git a/libbb/dump.c b/libbb/dump.c
index 7e43564..91efe41 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -613,7 +613,7 @@ static void display(priv_dumper_t* dumper)
printf(pr->fmt, (char *) bp);
break;
case F_TEXT:
- printf(pr->fmt);
+ printf("%s", pr->fmt);
break;
case F_U:
conv_u(pr, bp);
@@ -663,7 +663,7 @@ static void display(priv_dumper_t* dumper)
printf(pr->fmt, (unsigned) dumper->eaddress);
break;
case F_TEXT:
- printf(pr->fmt);
+ printf("%s", pr->fmt);
break;
}
}
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c
index 9ad5dbf..41a14d3 100644
--- a/libbb/fflush_stdout_and_exit.c
+++ b/libbb/fflush_stdout_and_exit.c
@@ -16,7 +16,7 @@
void FAST_FUNC fflush_stdout_and_exit(int retval)
{
if (fflush(stdout))
- bb_perror_msg_and_die(bb_msg_standard_output);
+ bb_perror_msg_and_die("%s", bb_msg_standard_output);
if (ENABLE_FEATURE_PREFER_APPLETS && die_sleep < 0) {
/* We are in NOFORK applet. Do not exit() directly,
diff --git a/libbb/wfopen.c b/libbb/wfopen.c
index 76dc8b8..115b091 100644
--- a/libbb/wfopen.c
+++ b/libbb/wfopen.c
@@ -43,7 +43,7 @@ static FILE* xfdopen_helper(unsigned fd_and_rw_bit)
{
FILE* fp = fdopen(fd_and_rw_bit >> 1, fd_and_rw_bit & 1 ? "w" : "r");
if (!fp)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
return fp;
}
FILE* FAST_FUNC xfdopen_for_read(int fd)
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 05aa07c..29c963f 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -37,7 +37,7 @@ void* FAST_FUNC malloc_or_warn(size_t size)
{
void *ptr = malloc(size);
if (ptr == NULL && size != 0)
- bb_error_msg(bb_msg_memory_exhausted);
+ bb_error_msg("%s", bb_msg_memory_exhausted);
return ptr;
}
@@ -46,7 +46,7 @@ void* FAST_FUNC xmalloc(size_t size)
{
void *ptr = malloc(size);
if (ptr == NULL && size != 0)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
return ptr;
}
@@ -57,7 +57,7 @@ void* FAST_FUNC xrealloc(void *ptr, size_t size)
{
ptr = realloc(ptr, size);
if (ptr == NULL && size != 0)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
return ptr;
}
#endif /* DMALLOC */
@@ -81,7 +81,7 @@ char* FAST_FUNC xstrdup(const char *s)
t = strdup(s);
if (t == NULL)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
return t;
}
@@ -299,14 +299,14 @@ char* FAST_FUNC xasprintf(const char *format, ...)
va_end(p);
if (r < 0)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
return string_ptr;
}
void FAST_FUNC xsetenv(const char *key, const char *value)
{
if (setenv(key, value, 1))
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
}
/* Handles "VAR=VAL" strings, even those which are part of environ
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index b37270f..fd5b40b 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -129,7 +129,7 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
/* need to be root */
if (geteuid()) {
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
}
#if ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS
applet_long_options = addgroup_longopts;
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 1d082c8..2a66100 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -154,7 +154,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
/* got root? */
if (geteuid()) {
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
}
pw.pw_gecos = (char *)"Linux User,,,";
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c
index 54ed737..9eab99e 100644
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -39,7 +39,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
int opt;
if (getuid() != 0)
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
opt_complementary = "m--e:e--m";
IF_LONG_OPTS(applet_long_options = chpasswd_longopts;)
diff --git a/loginutils/deluser.c b/loginutils/deluser.c
index e39ac55..ee60efc 100644
--- a/loginutils/deluser.c
+++ b/loginutils/deluser.c
@@ -38,7 +38,7 @@ int deluser_main(int argc, char **argv)
int do_deluser = (ENABLE_DELUSER && (!ENABLE_DELGROUP || applet_name[3] == 'u'));
if (geteuid() != 0)
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
name = argv[1];
member = NULL;
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 4731d8d..49d1da7 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -115,7 +115,7 @@ int crontab_main(int argc UNUSED_PARAM, char **argv)
if (sanitize_env_if_suid()) { /* Clears dangerous stuff, sets PATH */
/* Run by non-root */
if (opt_ler & (OPT_u|OPT_c))
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
}
if (opt_ler & OPT_u) {
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 5b92db6..8482a6e 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -1981,7 +1981,7 @@ static NOINLINE void ntp_init(char **argv)
srandom(getpid());
if (getuid())
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
/* Set some globals */
G.stratum = MAXSTRAT;
diff --git a/networking/traceroute.c b/networking/traceroute.c
index d197e54..dc01ea7 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -850,7 +850,7 @@ common_traceroute_main(int op, char **argv)
* probe (e.g., on a multi-homed host).
*/
if (getuid() != 0)
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
}
if (op & OPT_WAITTIME)
waittime = xatou_range(waittime_str, 1, 24 * 60 * 60);
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index b43e52e..155ec01 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -50,7 +50,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP));
if (s == -1) {
- bb_perror_msg(bb_msg_can_not_create_raw_socket);
+ bb_perror_msg("%s", bb_msg_can_not_create_raw_socket);
return -1;
}
diff --git a/networking/wget.c b/networking/wget.c
index 6d8f8a5..43ad4c2 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -203,7 +203,7 @@ static FILE *open_socket(len_and_sockaddr *lsa)
/* hopefully it understands what ESPIPE means... */
fp = fdopen(xconnect_stream(lsa), "r+");
if (fp == NULL)
- bb_perror_msg_and_die(bb_msg_memory_exhausted);
+ bb_perror_msg_and_die("%s", bb_msg_memory_exhausted);
return fp;
}
diff --git a/shell/hush.c b/shell/hush.c
index b9e763c..5d69e2c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2548,7 +2548,7 @@ static int glob_brace(char *pattern, o_string *o, int n)
return o_save_ptr_helper(o, n);
}
if (gr == GLOB_NOSPACE)
- bb_error_msg_and_die(bb_msg_memory_exhausted);
+ bb_error_msg_and_die("%s", bb_msg_memory_exhausted);
/* GLOB_ABORTED? Only happens with GLOB_ERR flag,
* but we didn't specify it. Paranoia again. */
bb_error_msg_and_die("glob error %d on '%s'", gr, pattern);
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index 9939569..6eef033 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -54,7 +54,7 @@ static void error_exit(const char *str)
{
//release all acquired resources
shmdt(shbuf);
- bb_perror_msg_and_die(str);
+ bb_perror_msg_and_die("%s", str);
}
/*
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 525fdcc..3786bf0 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -616,7 +616,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
// Abort entirely if permission denied.
if (rc && errno == EPERM)
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+ bb_error_msg_and_die("%s", bb_msg_perm_denied_are_you_root);
// If the mount was successful, and we're maintaining an old-style
// mtab file by hand, add the new entry to it now.
@@ -1870,7 +1870,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
mp->mnt_fsname = NULL; // will receive malloced loop dev name
if (set_loop(&mp->mnt_fsname, loopFile, 0, /*ro:*/ (vfsflags & MS_RDONLY)) < 0) {
if (errno == EPERM || errno == EACCES)
- bb_error_msg(bb_msg_perm_denied_are_you_root);
+ bb_error_msg("%s", bb_msg_perm_denied_are_you_root);
else
bb_perror_msg("can't setup loop device");
return errno;
@@ -2066,7 +2066,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// argument when we get it.
if (argv[1]) {
if (nonroot)
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
mtpair->mnt_fsname = argv[0];
mtpair->mnt_dir = argv[1];
mtpair->mnt_type = fstype;
@@ -2083,7 +2083,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
cmdopt_flags = parse_mount_options(cmdopts, NULL);
if (nonroot && (cmdopt_flags & ~MS_SILENT)) // Non-root users cannot specify flags
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
// If we have a shared subtree flag, don't worry about fstab or mtab.
if (ENABLE_FEATURE_MOUNT_FLAGS
@@ -2146,7 +2146,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// No, mount -a won't mount anything,
// even user mounts, for mere humans
if (nonroot)
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
// Does type match? (NULL matches always)
if (!match_fstype(mtcur, fstype))
@@ -2226,7 +2226,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// fstab must have "users" or "user"
l = parse_mount_options(mtcur->mnt_opts, NULL);
if (!(l & MOUNT_USERS))
- bb_error_msg_and_die(bb_msg_you_must_be_root);
+ bb_error_msg_and_die("%s", bb_msg_you_must_be_root);
}
//util-linux-2.12 does not do this check.
--
1.7.0.4
More information about the busybox
mailing list