[git commit master 1/1] convert "do {...} while (1); " -> "while (1) {...}"

Denys Vlasenko vda.linux at googlemail.com
Wed Mar 2 03:07:14 UTC 2011


commit: http://git.busybox.net/busybox/commit/?id=940c7206c2a4acb386ab47199a6c313c04387f3b
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/split.c  |    4 ++--
 loginutils/vlock.c |    9 +++++----
 networking/route.c |    4 ++--
 shell/ash.c        |   16 ++++++++--------
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/coreutils/split.c b/coreutils/split.c
index db5a172..79316ed 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -32,7 +32,7 @@ static char *next_file(char *old, unsigned suffix_len)
 	unsigned i = 1;
 	char *curr;
 
-	do {
+	while (1) {
 		curr = old + end - i;
 		if (*curr < 'z') {
 			*curr += 1;
@@ -43,7 +43,7 @@ static char *next_file(char *old, unsigned suffix_len)
 			return NULL;
 		}
 		*curr = 'a';
-	} while (1);
+	}
 
 	return old;
 }
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 216b317..0d0f3bc 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -93,16 +93,17 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
 	term.c_lflag &= ~(ECHO | ECHOCTL);
 	tcsetattr_stdin_TCSANOW(&term);
 
-	do {
+	while (1) {
 		printf("Virtual console%s locked by %s.\n",
-				option_mask32 /*o_lock_all*/ ? "s" : "",
-				pw->pw_name);
+				/* "s" if -a, else "": */ "s" + !option_mask32,
+				pw->pw_name
+		);
 		if (correct_password(pw)) {
 			break;
 		}
 		bb_do_delay(FAIL_DELAY);
 		puts("Password incorrect");
-	} while (1);
+	}
 
 #ifdef __linux__
 	ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
diff --git a/networking/route.c b/networking/route.c
index ac4fbb4..98a03de 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -605,7 +605,7 @@ static void INET6_displayroutes(void)
 		set_flags(flags, (iflags & IPV6_MASK));
 
 		r = 0;
-		do {
+		while (1) {
 			inet_pton(AF_INET6, addr6x + r,
 					  (struct sockaddr *) &snaddr6.sin6_addr);
 			snaddr6.sin6_family = AF_INET6;
@@ -624,7 +624,7 @@ static void INET6_displayroutes(void)
 				free(naddr6);
 				break;
 			}
-		} while (1);
+		}
 	}
 	fclose(fp);
 }
diff --git a/shell/ash.c b/shell/ash.c
index 98d2c7c..c3c9536 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3539,12 +3539,12 @@ set_curjob(struct job *jp, unsigned mode)
 
 	/* first remove from list */
 	jpp = curp = &curjob;
-	do {
+	while (1) {
 		jp1 = *jpp;
 		if (jp1 == jp)
 			break;
 		jpp = &jp1->prev_job;
-	} while (1);
+	}
 	*jpp = jp1->prev_job;
 
 	/* Then re-insert in correct position */
@@ -3560,14 +3560,14 @@ set_curjob(struct job *jp, unsigned mode)
 	case CUR_RUNNING:
 		/* newly created job or backgrounded job,
 		   put after all stopped jobs. */
-		do {
+		while (1) {
 			jp1 = *jpp;
 #if JOBS
 			if (!jp1 || jp1->state != JOBSTOPPED)
 #endif
 				break;
 			jpp = &jp1->prev_job;
-		} while (1);
+		}
 		/* FALLTHROUGH */
 #if JOBS
 	case CUR_STOPPED:
@@ -3740,7 +3740,7 @@ setjobctl(int on)
 			goto out;
 		/* fd is a tty at this point */
 		close_on_exec_on(fd);
-		do { /* while we are in the background */
+		while (1) { /* while we are in the background */
 			pgrp = tcgetpgrp(fd);
 			if (pgrp < 0) {
  out:
@@ -3751,7 +3751,7 @@ setjobctl(int on)
 			if (pgrp == getpgrp())
 				break;
 			killpg(0, SIGTTIN);
-		} while (1);
+		}
 		initialpgrp = pgrp;
 
 		setsignal(SIGTSTP);
@@ -5970,7 +5970,7 @@ expari(int quotes)
 	p = expdest - 1;
 	*p = '\0';
 	p--;
-	do {
+	while (1) {
 		int esc;
 
 		while ((unsigned char)*p != CTLARI) {
@@ -5988,7 +5988,7 @@ expari(int quotes)
 		}
 
 		p -= esc + 1;
-	} while (1);
+	}
 
 	begoff = p - start;
 
-- 
1.7.3.4



More information about the busybox-cvs mailing list