Skip to contentSkip to conversation

f2fs: Simplify bool conversion

PATCH Applied Yang Li 3 participants 5 messages Dec 15, 2021 – Dec 17, 2021 1 message not in the archive F2FS file system

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 f2fs: Simplify bool conversion

Fix the following coccicheck warning:
./fs/f2fs/sysfs.c:491:41-46: WARNING: conversion to bool not needed here

---
 fs/f2fs/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/sysfs.c +1 -1
index 9e1cf44642ae..530c36b89bf1 100644
@@ -488,7 +488,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 
 	if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) {
 		spin_lock(&sbi->gc_urgent_high_lock);
-		sbi->gc_urgent_high_limited = t == 0 ? false : true;
+		sbi->gc_urgent_high_limited = t != 0;
 		sbi->gc_urgent_high_remaining = t;
 		spin_unlock(&sbi->gc_urgent_high_lock);
 
Signature · 1 line
2.20.1.7.g153144c
maintainer
#1 lore raw
Quoted 14 lines · Yang Li

Fix the following coccicheck warning:
./fs/f2fs/sysfs.c:491:41-46: WARNING: conversion to bool not needed here

---
 fs/f2fs/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/sysfs.c +0 -0
index 9e1cf44642ae..530c36b89bf1 100644

fs/f2fs/sysfs.c static ssize_t __sbi_store(struct f2fs_attr *a, · line 491

Quoted 5 lines
fs/f2fs/sysfs.c +1 -1
@@ -488,7 +488,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 
 	if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) {
 		spin_lock(&sbi->gc_urgent_high_lock);
-		sbi->gc_urgent_high_limited = t == 0 ? false : true;
+		sbi->gc_urgent_high_limited = t != 0;

Why not this?

		sbi->gc_urgent_high_limited = t;
Quoted 5 lines
fs/f2fs/sysfs.c +0 -0
 		sbi->gc_urgent_high_remaining = t;
 		spin_unlock(&sbi->gc_urgent_high_lock);
 
Signature · 1 line
2.20.1.7.g153144c

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#3 lore raw
Quoted 4 lines · Yang.Lee

"Why not this?
sbi->gc_urgent_high_limited = t;"

Since 't' is an unsigned long type and 'gc_urgent_high_limited' is a bool type, the assignment operation will cause a new warning.

Huh, that doesn't allow auto casting as well.

Quoted 39 lines

------------------------------------------------------------------
发件人:Jaegeuk Kim <[email protected]>
发送时间:2021年12月17日(星期五) 03:27
收件人:Yang Li <[email protected]>
抄 送:chao <[email protected]>; linux-f2fs-devel <[email protected]>; linux-kernel <[email protected]>; Abaci Robot <[email protected]> 主 题:Re: [PATCH -next] f2fs: Simplify bool conversion

Quoted 14 lines · Yang Li

Fix the following coccicheck warning:
./fs/f2fs/sysfs.c:491:41-46: WARNING: conversion to bool not needed here

---
 fs/f2fs/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/sysfs.c +0 -0
index 9e1cf44642ae..530c36b89bf1 100644

fs/f2fs/sysfs.c static ssize_t __sbi_store(struct f2fs_attr *a, · line 491

Quoted 5 lines
fs/f2fs/sysfs.c +1 -1
@@ -488,7 +488,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 
  if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) {
   spin_lock(&sbi->gc_urgent_high_lock);
-  sbi->gc_urgent_high_limited = t == 0 ? false : true;
+  sbi->gc_urgent_high_limited = t != 0;

Why not this?
sbi->gc_urgent_high_limited = t;

Quoted 5 lines
fs/f2fs/sysfs.c +0 -0
   sbi->gc_urgent_high_remaining = t;
   spin_unlock(&sbi->gc_urgent_high_lock);
 
Signature · 1 line
2.20.1.7.g153144c
maintainer Applied
#5 lore raw
Quoted 8 lines · Chao Yu
Quoted 5 lines · Yang Li

Fix the following coccicheck warning:
./fs/f2fs/sysfs.c:491:41-46: WARNING: conversion to bool not needed here

Thanks for fixing this issue, do you mind merging this fix into original patch?

I applied this separately in order to avoid huge rebase.

Quoted 2 lines

Thanks,