[PATCH] dlm: Simplify character output in three functions

From: Markus Elfring
Date: Mon Jul 15 2024 - 06:52:25 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Jul 2024 12:36:44 +0200

Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc” for three selected calls.

This issue was transformed by using the Coccinelle software.

Suggested-by: Christophe Jaillet <christophe.jaillet@xxxxxxxxxx>
Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
fs/dlm/debug_fs.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 7112958c2e5b..0d21007930ed 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -81,12 +81,8 @@ static void print_format1(struct dlm_rsb *res, struct seq_file *s)

seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length);

- for (i = 0; i < res->res_length; i++) {
- if (isprint(res->res_name[i]))
- seq_printf(s, "%c", res->res_name[i]);
- else
- seq_printf(s, "%c", '.');
- }
+ for (i = 0; i < res->res_length; i++)
+ seq_putc(s, (isprint(res->res_name[i]) ? res->res_name[i] : '.'));

if (res->res_nodeid > 0)
seq_printf(s, "\"\nLocal Copy, Master is node %d\n",
@@ -284,7 +280,7 @@ static void print_format3(struct dlm_rsb *r, struct seq_file *s)

for (i = 0; i < r->res_length; i++) {
if (print_name)
- seq_printf(s, "%c", r->res_name[i]);
+ seq_putc(s, r->res_name[i]);
else
seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
}
@@ -358,7 +354,7 @@ static void print_format4(struct dlm_rsb *r, struct seq_file *s)

for (i = 0; i < r->res_length; i++) {
if (print_name)
- seq_printf(s, "%c", r->res_name[i]);
+ seq_putc(s, r->res_name[i]);
else
seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
}
--
2.45.2