aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-12 10:19:29 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-12 10:19:29 +0200
commit4bd70463c7e7511aea9de58876f0beacbcec1779 (patch)
treead700e6ec59309e998a27d1cda6730f7b968688b
parent2ca39ffd447ca874fcea933194829717d5573247 (diff)
downloadbusybox-w32-4bd70463c7e7511aea9de58876f0beacbcec1779.tar.gz
busybox-w32-4bd70463c7e7511aea9de58876f0beacbcec1779.tar.bz2
busybox-w32-4bd70463c7e7511aea9de58876f0beacbcec1779.zip
libbb: pass "" rather than NULL as format string in _nomsg functions
function old new delta bb_perror_nomsg_and_die 9 10 +1 bb_perror_nomsg 9 10 +1 bb_verror_msg 480 469 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 2/-11) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/perror_nomsg.c12
-rw-r--r--libbb/perror_nomsg_and_die.c12
-rw-r--r--libbb/verror_msg.c6
3 files changed, 4 insertions, 26 deletions
diff --git a/libbb/perror_nomsg.c b/libbb/perror_nomsg.c
index a2a11cc8e..670ccbc0c 100644
--- a/libbb/perror_nomsg.c
+++ b/libbb/perror_nomsg.c
@@ -6,17 +6,9 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9#include "libbb.h"
9 10
10/* gcc warns about a null format string, therefore we provide
11 * modified definition without "attribute (format)"
12 * instead of including libbb.h */
13//#include "libbb.h"
14#include "platform.h"
15extern void bb_perror_msg(const char *s, ...) FAST_FUNC;
16
17/* suppress gcc "no previous prototype" warning */
18void FAST_FUNC bb_perror_nomsg(void);
19void FAST_FUNC bb_perror_nomsg(void) 11void FAST_FUNC bb_perror_nomsg(void)
20{ 12{
21 bb_perror_msg(0); 13 bb_simple_perror_msg("");
22} 14}
diff --git a/libbb/perror_nomsg_and_die.c b/libbb/perror_nomsg_and_die.c
index 543ff5178..4151e0246 100644
--- a/libbb/perror_nomsg_and_die.c
+++ b/libbb/perror_nomsg_and_die.c
@@ -6,17 +6,9 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9#include "libbb.h"
9 10
10/* gcc warns about a null format string, therefore we provide
11 * modified definition without "attribute (format)"
12 * instead of including libbb.h */
13//#include "libbb.h"
14#include "platform.h"
15extern void bb_perror_msg_and_die(const char *s, ...) FAST_FUNC;
16
17/* suppress gcc "no previous prototype" warning */
18void FAST_FUNC bb_perror_nomsg_and_die(void);
19void FAST_FUNC bb_perror_nomsg_and_die(void) 11void FAST_FUNC bb_perror_nomsg_and_die(void)
20{ 12{
21 bb_perror_msg_and_die(0); 13 bb_simple_perror_msg_and_die("");
22} 14}
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c
index 71512aee2..74b608f4c 100644
--- a/libbb/verror_msg.c
+++ b/libbb/verror_msg.c
@@ -26,9 +26,6 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr)
26 if (!logmode) 26 if (!logmode)
27 return; 27 return;
28 28
29 if (!s) /* nomsg[_and_die] uses NULL fmt */
30 s = ""; /* some libc don't like printf(NULL) */
31
32 applet_len = strlen(applet_name) + 2; /* "applet: " */ 29 applet_len = strlen(applet_name) + 2; /* "applet: " */
33 strerr_len = strerr ? strlen(strerr) : 0; 30 strerr_len = strerr ? strlen(strerr) : 0;
34 msgeol_len = strlen(msg_eol); 31 msgeol_len = strlen(msg_eol);
@@ -116,9 +113,6 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr)
116 if (!logmode) 113 if (!logmode)
117 return; 114 return;
118 115
119 if (!s) /* nomsg[_and_die] uses NULL fmt */
120 s = ""; /* some libc don't like printf(NULL) */
121
122 /* Prevent "derefing type-punned ptr will break aliasing rules" */ 116 /* Prevent "derefing type-punned ptr will break aliasing rules" */
123 used = vasprintf((char**)(void*)msgptr, s, p); 117 used = vasprintf((char**)(void*)msgptr, s, p);
124 if (used < 0) 118 if (used < 0)