Skip to contentSkip to conversation

f2fs: use extra parenthesis around assignment/condition

PATCH In review Arnd Bergmann 3 participants 3 messages Oct 17, 2017 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: use extra parenthesis around assignment/condition

gcc warns that writing a while() loop with an assignment as the condition looks suspiciously like a comparison, and suggests a workaround:

fs/f2fs/checkpoint.c: In function 'sync_meta_pages':
fs/f2fs/checkpoint.c:321:9: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,

This seems reasonable, so let's do that.

Fixes 4aba7297f4a5 ("f2fs: simplify page iteration loops")

---
The warning is from mmotm. Andrew, please fold this fix into the patch that caused the warning, unless there are objections.

---
 fs/f2fs/checkpoint.c |  4 ++--
 fs/f2fs/node.c       | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
fs/f2fs/checkpoint.c +2 -2
index 3ed9dcbf70ae..6124f8710dc3 100644
@@ -318,8 +318,8 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
 
 	blk_start_plug(&plug);
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
fs/f2fs/node.c +8 -8
index d4ceb9ebfe92..d6e4df0bb622 100644
@@ -1285,8 +1285,8 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 	pagevec_init(&pvec, 0);
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1439,8 +1439,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 	pagevec_init(&pvec, 0);
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1552,8 +1552,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
 next_step:
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1650,8 +1650,8 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
 
 	pagevec_init(&pvec, 0);
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_WRITEBACK)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_WRITEBACK))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
Signature · 1 line
2.9.0
#1 lore raw
Quoted 7 lines · Arnd Bergmann

gcc warns that writing a while() loop with an assignment as the condition looks suspiciously like a comparison, and suggests a workaround:

fs/f2fs/checkpoint.c: In function 'sync_meta_pages':
fs/f2fs/checkpoint.c:321:9: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,

Quoted 7 lines

This seems reasonable, so let's do that.

Fixes 4aba7297f4a5 ("f2fs: simplify page iteration loops")

---
The warning is from mmotm. Andrew, please fold this fix into the patch that caused the warning, unless there are objections.

Yeah, thanks for fixing this.

Honza

Quoted 71 lines
---
 fs/f2fs/checkpoint.c |  4 ++--
 fs/f2fs/node.c       | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
fs/f2fs/checkpoint.c +2 -2
index 3ed9dcbf70ae..6124f8710dc3 100644
@@ -318,8 +318,8 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
 
 	blk_start_plug(&plug);
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
fs/f2fs/node.c +8 -8
index d4ceb9ebfe92..d6e4df0bb622 100644
@@ -1285,8 +1285,8 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 	pagevec_init(&pvec, 0);
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1439,8 +1439,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 	pagevec_init(&pvec, 0);
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1552,8 +1552,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
 next_step:
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1650,8 +1650,8 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
 
 	pagevec_init(&pvec, 0);
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_WRITEBACK)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_WRITEBACK))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
Signature · 1 line
2.9.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

gcc warns that writing a while() loop with an assignment as the condition looks suspiciously like a comparison, and suggests a workaround:

fs/f2fs/checkpoint.c: In function 'sync_meta_pages':
fs/f2fs/checkpoint.c:321:9: error: suggest parentheses around assignment used as truth value [-Werror=parentheses]
while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,

This seems reasonable, so let's do that.

Fixes 4aba7297f4a5 ("f2fs: simplify page iteration loops")

Thanks,

Quoted 72 lines

---
The warning is from mmotm. Andrew, please fold this fix into the patch that caused the warning, unless there are objections.

---
 fs/f2fs/checkpoint.c |  4 ++--
 fs/f2fs/node.c       | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
fs/f2fs/checkpoint.c +2 -2
index 3ed9dcbf70ae..6124f8710dc3 100644
@@ -318,8 +318,8 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
 
 	blk_start_plug(&plug);
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
fs/f2fs/node.c +8 -8
index d4ceb9ebfe92..d6e4df0bb622 100644
@@ -1285,8 +1285,8 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 	pagevec_init(&pvec, 0);
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1439,8 +1439,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 	pagevec_init(&pvec, 0);
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1552,8 +1552,8 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
 next_step:
 	index = 0;
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_DIRTY)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_DIRTY))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {
@@ -1650,8 +1650,8 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
 
 	pagevec_init(&pvec, 0);
 
-	while (nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-				PAGECACHE_TAG_WRITEBACK)) {
+	while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
+				PAGECACHE_TAG_WRITEBACK))) {
 		int i;
 
 		for (i = 0; i < nr_pages; i++) {