xfs
[Top] [All Lists]

[PATCH] xfs_fsr: Fix parentheses around truth value

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfs_fsr: Fix parentheses around truth value
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Mon, 03 Aug 2015 20:30:36 -0700
Delivered-to: xfs@xxxxxxxxxxx
Someone in the distant past must have responded to gcc's
warning about parentheses around assignment used as a truth
value by changing:

        while (ret = func() == 0)
to:
        while ((ret = func() == 0))

While this shuts up gcc, it doesn't yield the proper result.
If func () returns 0, func == 0 is true, and ret is assigned
a value of 1.

This does keep the while loop going, but it's a very strange
way to go about it, and may someday yield confusing results.

Fix this as:

        while ((ret = func()) == 0)

so that ret gets the function return value as expected.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index b46ad1f..b384565 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -716,7 +716,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange)
        tmp_init(mntdir);
 
        while ((ret = xfs_bulkstat(fsfd,
-                               &lastino, GRABSZ, &buf[0], &buflenout) == 0)) {
+                               &lastino, GRABSZ, &buf[0], &buflenout)) == 0) {
                xfs_bstat_t *p;
                xfs_bstat_t *endp;
 

<Prev in Thread] Current Thread [Next in Thread>