public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_fsr: Fix parentheses around truth value
@ 2015-08-04  3:30 Eric Sandeen
  2015-08-04 11:17 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2015-08-04  3:30 UTC (permalink / raw)
  To: xfs-oss

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@redhat.com>
---

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;
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xfs_fsr: Fix parentheses around truth value
  2015-08-04  3:30 [PATCH] xfs_fsr: Fix parentheses around truth value Eric Sandeen
@ 2015-08-04 11:17 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:17 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-04 11:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04  3:30 [PATCH] xfs_fsr: Fix parentheses around truth value Eric Sandeen
2015-08-04 11:17 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox