[git commit] ubi_tools: a bit smaller applet resolution code

Denys Vlasenko vda.linux at googlemail.com
Mon Aug 7 00:55:33 UTC 2017


commit: https://git.busybox.net/busybox/commit/?id=115e0a719950f8f716f73d5e36e9483df9dbbf1e
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
ubi_tools_main                                      1241    1235      -6

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 NOFORK_NOEXEC.lst     |  1 -
 miscutils/ubi_tools.c | 21 +++++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst
index 21f0972..d54c206 100644
--- a/NOFORK_NOEXEC.lst
+++ b/NOFORK_NOEXEC.lst
@@ -55,7 +55,6 @@ blockdev - noexec. leaks fd
 bootchartd - daemon
 brctl - noexec
 bunzip2 - runner
-busybox
 bzcat - runner
 bzip2 - runner
 cal - runner: cal -n9999
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c
index c6ba22a..d9b76b6 100644
--- a/miscutils/ubi_tools.c
+++ b/miscutils/ubi_tools.c
@@ -67,12 +67,21 @@
 #endif
 #include <mtd/ubi-user.h>
 
-#define do_attach (ENABLE_UBIATTACH && applet_name[3] == 'a')
-#define do_detach (ENABLE_UBIDETACH && applet_name[3] == 'd')
-#define do_mkvol  (ENABLE_UBIMKVOL  && applet_name[3] == 'm')
-#define do_rmvol  (ENABLE_UBIRMVOL  && applet_name[4] == 'm')
-#define do_rsvol  (ENABLE_UBIRSVOL  && applet_name[4] == 's')
-#define do_update (ENABLE_UBIUPDATEVOL && applet_name[3] == 'u')
+#define UBI_APPLET_CNT (0 \
+	+ ENABLE_UBIATTACH \
+	+ ENABLE_UBIDETACH \
+	+ ENABLE_UBIMKVOL \
+	+ ENABLE_UBIRMVOL \
+	+ ENABLE_UBIRSVOL \
+	+ ENABLE_UBIUPDATEVOL \
+	)
+
+#define do_attach (ENABLE_UBIATTACH    && (UBI_APPLET_CNT == 1 || applet_name[4] == 't'))
+#define do_detach (ENABLE_UBIDETACH    && (UBI_APPLET_CNT == 1 || applet_name[4] == 'e'))
+#define do_mkvol  (ENABLE_UBIMKVOL     && (UBI_APPLET_CNT == 1 || applet_name[4] == 'k'))
+#define do_rmvol  (ENABLE_UBIRMVOL     && (UBI_APPLET_CNT == 1 || applet_name[4] == 'm'))
+#define do_rsvol  (ENABLE_UBIRSVOL     && (UBI_APPLET_CNT == 1 || applet_name[4] == 's'))
+#define do_update (ENABLE_UBIUPDATEVOL && (UBI_APPLET_CNT == 1 || applet_name[4] == 'p'))
 
 static unsigned get_num_from_file(const char *path, unsigned max, const char *errmsg)
 {


More information about the busybox-cvs mailing list