[git commit] libbb: pass "" rather than NULL as format string in _nomsg functions

Denys Vlasenko vda.linux at googlemail.com
Mon Jun 12 08:19:29 UTC 2023


commit: https://git.busybox.net/busybox/commit/?id=4bd70463c7e7511aea9de58876f0beacbcec1779
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

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 at googlemail.com>
---
 libbb/perror_nomsg.c         | 12 ++----------
 libbb/perror_nomsg_and_die.c | 12 ++----------
 libbb/verror_msg.c           |  6 ------
 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 @@
  *
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
+#include "libbb.h"
 
-/* gcc warns about a null format string, therefore we provide
- * modified definition without "attribute (format)"
- * instead of including libbb.h */
-//#include "libbb.h"
-#include "platform.h"
-extern void bb_perror_msg(const char *s, ...) FAST_FUNC;
-
-/* suppress gcc "no previous prototype" warning */
-void FAST_FUNC bb_perror_nomsg(void);
 void FAST_FUNC bb_perror_nomsg(void)
 {
-	bb_perror_msg(0);
+	bb_simple_perror_msg("");
 }
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 @@
  *
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
+#include "libbb.h"
 
-/* gcc warns about a null format string, therefore we provide
- * modified definition without "attribute (format)"
- * instead of including libbb.h */
-//#include "libbb.h"
-#include "platform.h"
-extern void bb_perror_msg_and_die(const char *s, ...) FAST_FUNC;
-
-/* suppress gcc "no previous prototype" warning */
-void FAST_FUNC bb_perror_nomsg_and_die(void);
 void FAST_FUNC bb_perror_nomsg_and_die(void)
 {
-	bb_perror_msg_and_die(0);
+	bb_simple_perror_msg_and_die("");
 }
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)
 	if (!logmode)
 		return;
 
-	if (!s) /* nomsg[_and_die] uses NULL fmt */
-		s = ""; /* some libc don't like printf(NULL) */
-
 	applet_len = strlen(applet_name) + 2; /* "applet: " */
 	strerr_len = strerr ? strlen(strerr) : 0;
 	msgeol_len = strlen(msg_eol);
@@ -116,9 +113,6 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr)
 	if (!logmode)
 		return;
 
-	if (!s) /* nomsg[_and_die] uses NULL fmt */
-		s = ""; /* some libc don't like printf(NULL) */
-
 	/* Prevent "derefing type-punned ptr will break aliasing rules" */
 	used = vasprintf((char**)(void*)msgptr, s, p);
 	if (used < 0)


More information about the busybox-cvs mailing list