aboutsummaryrefslogtreecommitdiff
path: root/util-linux/lsblk.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2026-02-05 13:36:27 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2026-02-05 13:36:27 +0100
commitfddd93edbdbf8c5afbfdb3c01d82e082a8a82d1a (patch)
treebc67c4cd3acea69333eb7bb4d8d4d904d5d6027a /util-linux/lsblk.c
parent3d572a8cc3d71b43877db2776882e91303a0532d (diff)
downloadbusybox-w32-fddd93edbdbf8c5afbfdb3c01d82e082a8a82d1a.tar.gz
busybox-w32-fddd93edbdbf8c5afbfdb3c01d82e082a8a82d1a.tar.bz2
busybox-w32-fddd93edbdbf8c5afbfdb3c01d82e082a8a82d1a.zip
libbb: introduce and use xasprintf_inplace()
function old new delta xasprintf_and_free - 49 +49 watch_main 269 282 +13 singlemount 1313 1315 +2 append_mount_options 157 149 -8 ip_port_str 122 112 -10 lsblk_main 869 858 -11 add_cmd 1178 1167 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/4 up/down: 64/-40) Total: 24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/lsblk.c')
-rw-r--r--util-linux/lsblk.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/util-linux/lsblk.c b/util-linux/lsblk.c
index a482bfbbc..3bd40bcb4 100644
--- a/util-linux/lsblk.c
+++ b/util-linux/lsblk.c
@@ -101,10 +101,10 @@ static char *get_mountpoints(const char *majmin)
101 101
102 mountpoints = NULL; 102 mountpoints = NULL;
103 len = strlen(majmin); 103 len = strlen(majmin);
104 p = G.mountinfo; // "/proc/self/mountinfo" 104 p = G.mountinfo; // contents of "/proc/self/mountinfo"
105 /* lines a-la "63 1 259:3 / /MNTPOINT per-mount_options - ext4 /dev/NAME per-superblock_options" */ 105 /* lines a-la "63 1 259:3 / /MNTPOINT per-mount_options - ext4 /dev/NAME per-superblock_options" */
106 while (*p) { 106 while (*p) {
107 char *e, *f; 107 char *e;
108 108
109 p = skip_non_whitespace(p); 109 p = skip_non_whitespace(p);
110 if (*p != ' ') break; 110 if (*p != ' ') break;
@@ -127,12 +127,11 @@ static char *get_mountpoints(const char *majmin)
127 // at " /MNTPOINT" 127 // at " /MNTPOINT"
128 e = skip_non_whitespace(p + 1); 128 e = skip_non_whitespace(p + 1);
129 // e is at the end of " /MNTPOINT" 129 // e is at the end of " /MNTPOINT"
130 f = mountpoints;
131// NO. We return " /MNT1 /MNT2 /MNT3" _with_ leading space! 130// NO. We return " /MNT1 /MNT2 /MNT3" _with_ leading space!
132// if (!f) 131// if (!mountpoints)
133// p++; 132// p++;
134 mountpoints = xasprintf("%s%.*s", f ? f : "", (int)(e - p), p); 133 xasprintf_inplace(mountpoints, "%s%.*s",
135 free(f); 134 mountpoints ? mountpoints : "", (int)(e - p), p);
136 } 135 }
137 return mountpoints; 136 return mountpoints;
138} 137}