[git commit] devfsd: constify, code shrink

Denys Vlasenko vda.linux at googlemail.com
Mon Feb 2 07:49:11 UTC 2026


commit: https://git.busybox.net/busybox/commit/?id=705c9b3487928df07d218f8327d1f4951b17a6bd
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
static.copy_inode                                    613     608      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5)               Total: -5 bytes
   text	   data	    bss	    dec	    hex	filename
1087619	    827	   5088	1093534	 10af9e	busybox_old
1087654	    787	   5088	1093529	 10af99	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 miscutils/devfsd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 36b491595..642cd3637 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -306,7 +306,7 @@ static struct config_entry_struct *last_config = NULL;
 static char *mount_point = NULL;
 static volatile int caught_signal = FALSE;
 static volatile int caught_sighup = FALSE;
-static struct initial_symlink_struct {
+static const struct initial_symlink_struct {
 	const char *dest;
 	const char *name;
 } initial_symlinks[] = {
@@ -413,7 +413,7 @@ int devfsd_main(int argc, char **argv)
 	int fd, proto_rev, count;
 	unsigned long event_mask = 0;
 	struct sigaction new_action;
-	struct initial_symlink_struct *curr;
+	const struct initial_symlink_struct *curr;
 
 	if (argc < 2)
 		bb_show_usage();
@@ -1072,8 +1072,8 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
 			if (fd < 0)
 				break;
 			un_addr.sun_family = AF_UNIX;
-			snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath);
-			val = bind(fd, (struct sockaddr *) &un_addr, (int) sizeof un_addr);
+			strncpy(un_addr.sun_path, destpath, sizeof(un_addr.sun_path));
+			val = bind(fd, (struct sockaddr *) &un_addr, (int)sizeof(un_addr));
 			close(fd);
 			if (val != 0 || chmod(destpath, new_mode & ~S_IFMT) != 0)
 				break;


More information about the busybox-cvs mailing list