Skip to contentSkip to conversation

bs_rbd: fix error assignment in if condition

PATCH Applied Ruoyu 2 participants 2 messages Jul 23, 2014 – Jul 25, 2014 Kbuild

lore
Share & tools
lore

Ruoyu

author
#0 lore raw

PATCH 1/1 bs_rbd: fix error assignment in if condition

The statement

if ((x == f()) < 0) {}

is strange. I think it should be

if ((x = f()) < 0) {}

For the reasone of coding style, I modify it as

x = f();
if (x < 0) {}

---
 usr/bs_rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
usr/bs_rbd.c +2 -2
index 3a052ed..ef14797 100644
@@ -431,8 +431,8 @@ static int bs_rbd_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size)
 	eprintf("bs_rbd_open: pool: %s image: %s snap: %s\n",
 		poolname, imagename, snapname);
 
-	if ((ret == rados_ioctx_create(rbd->cluster, poolname, &rbd->ioctx))
-	    < 0) {
+	ret = rados_ioctx_create(rbd->cluster, poolname, &rbd->ioctx);
+	if (ret < 0) {
 		eprintf("bs_rbd_open: rados_ioctx_create: %d\n", ret);
 		return -EIO;
 	}
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 10 lines · On Wed, 23 Jul 2014 10:38:34 +0800 Ruoyu <[email protected]> wrote:

The statement

if ((x == f()) < 0) {}

is strange. I think it should be

if ((x = f()) < 0) {}

For the reasone of coding style, I modify it as

Quoted 7 lines

x = f();
if (x < 0) {}

---
 usr/bs_rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.