Skip to content

Commit 0fbbb2c

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Acked-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 22542b6 commit 0fbbb2c

File tree

1 file changed

+8
-2
lines changed
  • t/unit-tests/clar/clar

1 file changed

+8
-2
lines changed

t/unit-tests/clar/clar/fs.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,12 @@ fs_copydir_helper(const char *source, const char *dest, int dest_mode)
376376
mkdir(dest, dest_mode);
377377

378378
cl_assert_(source_dir = opendir(source), "Could not open source dir");
379-
while ((d = (errno = 0, readdir(source_dir))) != NULL) {
379+
for (;;) {
380380
char *child;
381381

382+
errno = 0;
383+
if ((d = readdir(source_dir)) == NULL)
384+
break;
382385
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
383386
continue;
384387

@@ -479,9 +482,12 @@ fs_rmdir_helper(const char *path)
479482
struct dirent *d;
480483

481484
cl_assert_(dir = opendir(path), "Could not open dir");
482-
while ((d = (errno = 0, readdir(dir))) != NULL) {
485+
for (;;) {
483486
char *child;
484487

488+
errno = 0;
489+
if ((d = readdir(dir)) == NULL)
490+
break;
485491
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
486492
continue;
487493

0 commit comments

Comments
 (0)