Skip to contentSkip to conversation

ext4: use str_plural() instead of custom macro

PATCH Superseded Joshua Crofts 3 participants 3 messages Jul 11 – Jul 13 ext4 file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: use str_plural() instead of custom macro

Remove the custom PLURAL() macro and use str_plural() from string_choices.h instead.

---
 fs/ext4/orphan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/orphan.c +3 -3
index 64ea47624233..e307d6d55451 100644
@@ -4,6 +4,7 @@
 #include <linux/fs.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+#include <linux/string_choices.h>
 
 #include "ext4.h"
 #include "ext4_jbd2.h"
@@ -486,14 +487,13 @@ void ext4_orphan_cleanup(struct super_block *sb, struct ext4_super_block *es)
 		}
 	}
 
-#define PLURAL(x) (x), ((x) == 1) ? "" : "s"
 
 	if (nr_orphans)
 		ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted",
-		       PLURAL(nr_orphans));
+			 nr_orphans, str_plural(nr_orphans));
 	if (nr_truncates)
 		ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
-		       PLURAL(nr_truncates));
+			 nr_truncates, str_plural(nr_truncates));
 #ifdef CONFIG_QUOTA
 	/* Turn off quotas if they were enabled for orphan cleanup */
 	if (quota_update) {

---
base-commit: c143957520c6c9b5cd72e0de8b52b814f0c576fe
change-id: 20260711-remove-plural-macro-7ecfa879fcae

Best regards,

Signature · 3 lines
Kind regards

CJD
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Joshua Crofts

Remove the custom PLURAL() macro and use str_plural() from string_choices.h instead.

Yeah, I guess it's cleaner this way. Feel free to add:

Honza

Quoted 44 lines
---
 fs/ext4/orphan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/orphan.c +3 -4
index 64ea47624233..e307d6d55451 100644
@@ -4,6 +4,7 @@
 #include <linux/fs.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+#include <linux/string_choices.h>
 
 #include "ext4.h"
 #include "ext4_jbd2.h"
@@ -486,14 +487,13 @@ void ext4_orphan_cleanup(struct super_block *sb, struct ext4_super_block *es)
 		}
 	}
 
-#define PLURAL(x) (x), ((x) == 1) ? "" : "s"
 
 	if (nr_orphans)
 		ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted",
-		       PLURAL(nr_orphans));
+			 nr_orphans, str_plural(nr_orphans));
 	if (nr_truncates)
 		ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
-		       PLURAL(nr_truncates));
+			 nr_truncates, str_plural(nr_truncates));
 #ifdef CONFIG_QUOTA
 	/* Turn off quotas if they were enabled for orphan cleanup */
 	if (quota_update) {
 
---

base-commit: c143957520c6c9b5cd72e0de8b52b814f0c576fe
change-id: 20260711-remove-plural-macro-7ecfa879fcae

Best regards,

Signature · 3 lines
Kind regards

CJD
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Joshua Crofts
Quoted 4 lines · Joshua Crofts

Remove the custom PLURAL() macro and use str_plural() from string_choices.h instead.


Looks good to me, just one nit:

Quoted 17 lines
---
 fs/ext4/orphan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/orphan.c +1 -0
index 64ea47624233..e307d6d55451 100644
@@ -4,6 +4,7 @@
 #include <linux/fs.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+#include <linux/string_choices.h>
 
 #include "ext4.h"
 #include "ext4_jbd2.h"

fs/ext4/orphan.c void ext4_orphan_cleanup(struct super_block *sb, struct ext4_super_block *es) · line 490

Quoted 5 lines
fs/ext4/orphan.c +0 -1
@@ -486,14 +487,13 @@ void ext4_orphan_cleanup(struct super_block *sb, struct ext4_super_block *es)
 		}
 	}
 
-#define PLURAL(x) (x), ((x) == 1) ? "" : "s"
 

this leaves two blank lines here

Quoted 17 lines
fs/ext4/orphan.c +2 -3
 	if (nr_orphans)
 		ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted",
-		       PLURAL(nr_orphans));
+			 nr_orphans, str_plural(nr_orphans));
 	if (nr_truncates)
 		ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
-		       PLURAL(nr_truncates));
+			 nr_truncates, str_plural(nr_truncates));
 #ifdef CONFIG_QUOTA
 	/* Turn off quotas if they were enabled for orphan cleanup */
 	if (quota_update) {
 
---

base-commit: c143957520c6c9b5cd72e0de8b52b814f0c576fe
change-id: 20260711-remove-plural-macro-7ecfa879fcae

Best regards,