aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-08 17:31:55 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-08 17:31:55 +0000
commitbd8f43dbab871d19484887556632af50749786b6 (patch)
treeaff74eaa70da2da4ea68915687eeb354df2f74da
parent9a9edf200b797a92380b634d57dec6cd9410919f (diff)
downloadbusybox-w32-bd8f43dbab871d19484887556632af50749786b6.tar.gz
busybox-w32-bd8f43dbab871d19484887556632af50749786b6.tar.bz2
busybox-w32-bd8f43dbab871d19484887556632af50749786b6.zip
few random readability enhansements. No code changes
-rw-r--r--coreutils/stty.c4
-rw-r--r--libbb/device_open.c1
-rw-r--r--sysklogd/syslogd.c13
3 files changed, 10 insertions, 8 deletions
diff --git a/coreutils/stty.c b/coreutils/stty.c
index 073de847b..d709bfc1e 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -514,8 +514,8 @@ int stty_main(int argc, char **argv)
514 device_name = file_name; 514 device_name = file_name;
515 fclose(stdin); 515 fclose(stdin);
516 xopen(device_name, O_RDONLY | O_NONBLOCK); 516 xopen(device_name, O_RDONLY | O_NONBLOCK);
517 if ((fdflags = fcntl(STDIN_FILENO, F_GETFL)) == -1 517 fdflags = fcntl(STDIN_FILENO, F_GETFL);
518 || fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) 518 if (fdflags == -1 || fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
519 perror_on_device("%s: couldn't reset non-blocking mode"); 519 perror_on_device("%s: couldn't reset non-blocking mode");
520 } else { 520 } else {
521 device_name = bb_msg_standard_input; 521 device_name = bb_msg_standard_input;
diff --git a/libbb/device_open.c b/libbb/device_open.c
index d34557b5a..c788b6982 100644
--- a/libbb/device_open.c
+++ b/libbb/device_open.c
@@ -20,6 +20,7 @@ int device_open(const char *device, int mode)
20 m = mode | O_NONBLOCK; 20 m = mode | O_NONBLOCK;
21 21
22 /* Retry up to 5 times */ 22 /* Retry up to 5 times */
23 /* TODO: explain why it can't be considered insane */
23 for (f = 0; f < 5; f++) 24 for (f = 0; f < 5; f++)
24 if ((fd = open(device, m, 0600)) >= 0) 25 if ((fd = open(device, m, 0600)) >= 0)
25 break; 26 break;
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index a8b52b36e..f3de04653 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -277,9 +277,9 @@ static void message(char *fmt, ...)
277 277
278 } else 278 } else
279#endif 279#endif
280 if ((fd = device_open(logFilePath, 280 fd = device_open(logFilePath, O_WRONLY | O_CREAT
281 O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | 281 | O_NOCTTY | O_APPEND | O_NONBLOCK);
282 O_NONBLOCK)) >= 0) { 282 if (fd >= 0) {
283 fl.l_type = F_WRLCK; 283 fl.l_type = F_WRLCK;
284 fcntl(fd, F_SETLKW, &fl); 284 fcntl(fd, F_SETLKW, &fl);
285 285
@@ -291,7 +291,8 @@ static void message(char *fmt, ...)
291 && (lseek(fd,0,SEEK_END) > logFileSize) ) { 291 && (lseek(fd,0,SEEK_END) > logFileSize) ) {
292 if(logFileRotate > 0) { 292 if(logFileRotate > 0) {
293 int i; 293 int i;
294 char oldFile[(strlen(logFilePath)+4)], newFile[(strlen(logFilePath)+4)]; 294 char oldFile[(strlen(logFilePath)+4)];
295 char newFile[(strlen(logFilePath)+4)];
295 for(i=logFileRotate-1;i>0;i--) { 296 for(i=logFileRotate-1;i>0;i--) {
296 sprintf(oldFile, "%s.%d", logFilePath, i-1); 297 sprintf(oldFile, "%s.%d", logFilePath, i-1);
297 sprintf(newFile, "%s.%d", logFilePath, i); 298 sprintf(newFile, "%s.%d", logFilePath, i);
@@ -321,8 +322,8 @@ static void message(char *fmt, ...)
321 close(fd); 322 close(fd);
322 } else { 323 } else {
323 /* Always send console messages to /dev/console so people will see them. */ 324 /* Always send console messages to /dev/console so people will see them. */
324 if ((fd = device_open(_PATH_CONSOLE, 325 fd = device_open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);
325 O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { 326 if (fd >= 0) {
326 va_start(arguments, fmt); 327 va_start(arguments, fmt);
327 vdprintf(fd, fmt, arguments); 328 vdprintf(fd, fmt, arguments);
328 va_end(arguments); 329 va_end(arguments);