From 57255510c95ca3369d241502f26d7bbd8fac30a6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Sep 2015 14:33:32 +0200 Subject: [PATCH] tree-wide: replace while(1) by for(;;) everywhere Another Coccinelle script. --- coccinelle/while-true.cocci | 12 ++++++++++++ src/bootchart/svg.c | 2 +- src/journal-remote/journal-remote-parse.c | 2 +- src/journal-remote/journal-remote.c | 2 +- src/journal-remote/journal-upload-journal.c | 2 +- src/journal-remote/journal-upload.c | 2 +- src/udev/ata_id/ata_id.c | 2 +- src/udev/cdrom_id/cdrom_id.c | 2 +- src/udev/collect/collect.c | 2 +- src/udev/scsi_id/scsi_id.c | 2 +- 10 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 coccinelle/while-true.cocci diff --git a/coccinelle/while-true.cocci b/coccinelle/while-true.cocci new file mode 100644 index 00000000000..c23fb11f223 --- /dev/null +++ b/coccinelle/while-true.cocci @@ -0,0 +1,12 @@ +@@ +statement s; +@@ +- while (true) ++ for (;;) +s +@@ +statement s; +@@ +- while (1) ++ for (;;) +s diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index 1231e6eaceb..c66f12e3a6f 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -888,7 +888,7 @@ static struct ps_struct *get_next_ps(struct ps_struct *ps, struct ps_struct *ps_ return ps->next; /* go back for parent siblings */ - while (1) { + for (;;) { if (ps->parent && ps->parent->next) return ps->parent->next; diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 5ff05d3ad61..2e0f78701a5 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -94,7 +94,7 @@ static int get_line(RemoteSource *source, char **line, size_t *size) { assert(source->buf == NULL || source->size > 0); assert(source->fd >= 0); - while (true) { + for (;;) { if (source->buf) { size_t start = MAX(source->scanned, source->offset); diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index efa4baafdee..d6ebca20ec5 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -518,7 +518,7 @@ static int process_http_upload( } else finished = true; - while (true) { + for (;;) { r = process_source(source, arg_compress, arg_seal); if (r == -EAGAIN) break; diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c index 507210f51c4..6b3ad924a73 100644 --- a/src/journal-remote/journal-upload-journal.c +++ b/src/journal-remote/journal-upload-journal.c @@ -17,7 +17,7 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) { assert(size <= SSIZE_MAX); - while (true) { + for (;;) { switch(u->entry_state) { case ENTRY_CURSOR: { diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 172fd80a12a..311bd3fddab 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -828,7 +828,7 @@ int main(int argc, char **argv) { "READY=1\n" "STATUS=Processing input..."); - while (true) { + for (;;) { r = sd_event_get_state(u.events); if (r < 0) break; diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index c6a2c56e773..e265aa5f538 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -432,7 +432,7 @@ int main(int argc, char *argv[]) if (udev == NULL) return 0; - while (1) { + for (;;) { int option; option = getopt_long(argc, argv, "xh", options, NULL); diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index e6a9e354ff3..001bae7a245 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -868,7 +868,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - while (1) { + for (;;) { int option; option = getopt_long(argc, argv, "deluh", options, NULL); diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c index 6cf41c67bb3..b3a1f0bca1f 100644 --- a/src/udev/collect/collect.c +++ b/src/udev/collect/collect.c @@ -364,7 +364,7 @@ int main(int argc, char **argv) goto exit; } - while (1) { + for (;;) { int option; option = getopt_long(argc, argv, "ardh", options, NULL); diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index 3c4653fd19a..adb91869df0 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -190,7 +190,7 @@ static int get_file_options(struct udev *udev, *newargv = NULL; lineno = 0; - while (1) { + for (;;) { vendor_in = model_in = options_in = NULL; buf = fgets(buffer, MAX_BUFFER_LEN, f);