linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: erofs: fix if assignment style issue
@ 2018-08-05 15:21 Kristaps Čivkulis
  2018-08-05 16:05 ` Gao Xiang
  2018-08-06  1:43 ` Chao Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Kristaps Čivkulis @ 2018-08-05 15:21 UTC (permalink / raw)
  To: gaoxiang25, yuchao0, gregkh, linux-erofs, devel, linux-kernel

Fix coding style issue "do not use assignment in if condition"
detected by checkpatch.pl.

Signed-off-by: Kristaps Čivkulis <kristaps.civkulis@gmail.com>
---
 drivers/staging/erofs/unzip_vle.c |  3 ++-
 drivers/staging/erofs/xattr.c     | 16 ++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index 1030ca5c2dc3..45b1255f5a22 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -702,7 +702,8 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 	/* can be used for verification */
 	map->m_llen = offset + cur - map->m_la;
 
-	if ((end = cur) > 0)
+	end = cur;
+	if (end > 0)
 		goto repeat;
 
 	/* FIXME! avoid the last relundant fixup & endio */
diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index 6b9685fa601c..0e9cfeccdf99 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -288,8 +288,8 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it)
 
 	remaining = ret;
 	while (remaining) {
-		if ((ret = xattr_foreach(&it->it,
-			&find_xattr_handlers, &remaining)) >= 0)
+		ret = xattr_foreach(&it->it, &find_xattr_handlers, &remaining);
+		if (ret >= 0)
 			break;
 	}
 	xattr_iter_end(&it->it, true);
@@ -321,8 +321,8 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
 			it->it.blkaddr = blkaddr;
 		}
 
-		if ((ret = xattr_foreach(&it->it,
-			&find_xattr_handlers, NULL)) >= 0)
+		ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL);
+		if (ret >= 0)
 			break;
 	}
 	if (vi->xattr_shared_count)
@@ -512,8 +512,8 @@ static int inline_listxattr(struct listxattr_iter *it)
 
 	remaining = ret;
 	while (remaining) {
-		if ((ret = xattr_foreach(&it->it,
-			&list_xattr_handlers, &remaining)) < 0)
+		ret = xattr_foreach(&it->it, &list_xattr_handlers, &remaining);
+		if (ret < 0)
 			break;
 	}
 	xattr_iter_end(&it->it, true);
@@ -544,8 +544,8 @@ static int shared_listxattr(struct listxattr_iter *it)
 			it->it.blkaddr = blkaddr;
 		}
 
-		if ((ret = xattr_foreach(&it->it,
-			&list_xattr_handlers, NULL)) < 0)
+		ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL);
+		if (ret < 0)
 			break;
 	}
 	if (vi->xattr_shared_count)
-- 
2.18.0


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

* Re: [PATCH] staging: erofs: fix if assignment style issue
  2018-08-05 15:21 [PATCH] staging: erofs: fix if assignment style issue Kristaps Čivkulis
@ 2018-08-05 16:05 ` Gao Xiang
  2018-08-06  1:43 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2018-08-05 16:05 UTC (permalink / raw)
  To: Kristaps Čivkulis, gaoxiang25, yuchao0, gregkh, linux-erofs,
	devel, linux-kernel

Hi Kristaps,

On 2018/8/5 23:21, Kristaps Čivkulis wrote:
> Fix coding style issue "do not use assignment in if condition"
> detected by checkpatch.pl.
>
> Signed-off-by: Kristaps Čivkulis <kristaps.civkulis@gmail.com>

I don't know whether this rule is mandatory or not for the current linux
kernel
when I checked the original patchset with checkpatch.pl.

Sometime I prefer to use assignment in if condition since the whole
statement
is more meaningful than separate to several statements...  although it
can lead to
some potential bugs.

Another case is use (!ptr) to replace (ptr == NULL) and use (ptr) to replace
(ptr != NULL) for pointers. Actually these expressions are equivalent in C,
but I personally like the nullptr concept... I also have no idea if it
is mandatory to fix
as the checkpatch.pl suggested or not...

Thanks for your patch :) if it is actually mandatory or strongly
recommend, you can add:

Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>

Thanks,
Gao Xiang

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

* Re: [PATCH] staging: erofs: fix if assignment style issue
  2018-08-05 15:21 [PATCH] staging: erofs: fix if assignment style issue Kristaps Čivkulis
  2018-08-05 16:05 ` Gao Xiang
@ 2018-08-06  1:43 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2018-08-06  1:43 UTC (permalink / raw)
  To: Kristaps Čivkulis, gaoxiang25, gregkh, linux-erofs, devel,
	linux-kernel

On 2018/8/5 23:21, Kristaps Čivkulis wrote:
> Fix coding style issue "do not use assignment in if condition"
> detected by checkpatch.pl.
> 
> Signed-off-by: Kristaps Čivkulis <kristaps.civkulis@gmail.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,


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

end of thread, other threads:[~2018-08-06  1:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-05 15:21 [PATCH] staging: erofs: fix if assignment style issue Kristaps Čivkulis
2018-08-05 16:05 ` Gao Xiang
2018-08-06  1:43 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).