clar: avoid using the comma operator unnecessarily

The comma operator is a somewhat obscure C feature that is often used by mistake and can even cause unintentional code flow. In this instance, it makes the code harder to read than necessary, too. Better use a semicolon instead. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Mar 27, 2025 at 11:52 UTC 0fbbb2c9f595a8460a7fd7c72d4e95081eb96b08
1 file changed +8 -2
t/unit-tests/clar/clar/fs.h
+8 -2
@@ -376,9 +376,12 @@ fs_copydir_helper(const char *source, const char *dest, int dest_mode)
376 mkdir(dest, dest_mode);
377
378 cl_assert_(source_dir = opendir(source), "Could not open source dir");
379 - while ((d = (errno = 0, readdir(source_dir))) != NULL) {
379 + for (;;) {
380 char *child;
381
382 + errno = 0;
383 + if ((d = readdir(source_dir)) == NULL)
384 + break;
385 if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
386 continue;
387
@@ -479,9 +482,12 @@ fs_rmdir_helper(const char *path)
482 struct dirent *d;
483
484 cl_assert_(dir = opendir(path), "Could not open dir");
482 - while ((d = (errno = 0, readdir(dir))) != NULL) {
485 + for (;;) {
486 char *child;
487
488 + errno = 0;
489 + if ((d = readdir(dir)) == NULL)
490 + break;
491 if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
492 continue;
493