svn commit: trunk/busybox: coreutils libbb sysklogd

vda at busybox.net vda at busybox.net
Fri Sep 8 17:31:56 UTC 2006


Author: vda
Date: 2006-09-08 10:31:55 -0700 (Fri, 08 Sep 2006)
New Revision: 16076

Log:
few random readability enhansements. No code changes



Modified:
   trunk/busybox/coreutils/stty.c
   trunk/busybox/libbb/device_open.c
   trunk/busybox/sysklogd/syslogd.c


Changeset:
Modified: trunk/busybox/coreutils/stty.c
===================================================================
--- trunk/busybox/coreutils/stty.c	2006-09-08 17:29:53 UTC (rev 16075)
+++ trunk/busybox/coreutils/stty.c	2006-09-08 17:31:55 UTC (rev 16076)
@@ -514,8 +514,8 @@
 		device_name = file_name;
 		fclose(stdin);
 		xopen(device_name, O_RDONLY | O_NONBLOCK);
-		if ((fdflags = fcntl(STDIN_FILENO, F_GETFL)) == -1
-			|| fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
+		fdflags = fcntl(STDIN_FILENO, F_GETFL);
+		if (fdflags == -1 || fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
 			perror_on_device("%s: couldn't reset non-blocking mode");
 	} else {
 		device_name = bb_msg_standard_input;

Modified: trunk/busybox/libbb/device_open.c
===================================================================
--- trunk/busybox/libbb/device_open.c	2006-09-08 17:29:53 UTC (rev 16075)
+++ trunk/busybox/libbb/device_open.c	2006-09-08 17:31:55 UTC (rev 16076)
@@ -20,6 +20,7 @@
 	m = mode | O_NONBLOCK;
 
 	/* Retry up to 5 times */
+	/* TODO: explain why it can't be considered insane */
 	for (f = 0; f < 5; f++)
 		if ((fd = open(device, m, 0600)) >= 0)
 			break;

Modified: trunk/busybox/sysklogd/syslogd.c
===================================================================
--- trunk/busybox/sysklogd/syslogd.c	2006-09-08 17:29:53 UTC (rev 16075)
+++ trunk/busybox/sysklogd/syslogd.c	2006-09-08 17:31:55 UTC (rev 16076)
@@ -277,9 +277,9 @@
 
 	} else
 #endif
-	if ((fd = device_open(logFilePath,
-					O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND |
-							 O_NONBLOCK)) >= 0) {
+	fd = device_open(logFilePath, O_WRONLY | O_CREAT
+					| O_NOCTTY | O_APPEND | O_NONBLOCK);
+	if (fd >= 0) {
 		fl.l_type = F_WRLCK;
 		fcntl(fd, F_SETLKW, &fl);
 
@@ -291,7 +291,8 @@
 				&& (lseek(fd,0,SEEK_END) > logFileSize) ) {
 				if(logFileRotate > 0) {
 					int i;
-					char oldFile[(strlen(logFilePath)+4)], newFile[(strlen(logFilePath)+4)];
+					char oldFile[(strlen(logFilePath)+4)];
+					char newFile[(strlen(logFilePath)+4)];
 					for(i=logFileRotate-1;i>0;i--) {
 						sprintf(oldFile, "%s.%d", logFilePath, i-1);
 						sprintf(newFile, "%s.%d", logFilePath, i);
@@ -321,8 +322,8 @@
 		close(fd);
 	} else {
 		/* Always send console messages to /dev/console so people will see them. */
-		if ((fd = device_open(_PATH_CONSOLE,
-						 O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) {
+		fd = device_open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);
+		if (fd >= 0) {
 			va_start(arguments, fmt);
 			vdprintf(fd, fmt, arguments);
 			va_end(arguments);




More information about the busybox-cvs mailing list