diff --git a/coccinelle/while-true.cocci b/coccinelle/while-true.cocci new file mode 100644 index 0000000000..c23fb11f22 --- /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 1231e6eace..c66f12e3a6 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 5ff05d3ad6..2e0f78701a 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 efa4baafde..d6ebca20ec 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 507210f51c..6b3ad924a7 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 172fd80a12..311bd3fdda 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 c6a2c56e77..e265aa5f53 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 e6a9e354ff..001bae7a24 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 6cf41c67bb..b3a1f0bca1 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 3c4653fd19..adb91869df 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);