[PATCH] fs/afs: Remove unnecessary integer promotion in format strings

Dipendra Khadka posted 1 patch 1 month ago
fs/afs/rotate.c    | 4 ++--
fs/afs/vl_rotate.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
[PATCH] fs/afs: Remove unnecessary integer promotion in format strings
Posted by Dipendra Khadka 1 month ago
Remove 'h' length modifier from printk format strings where integer
promotion makes it redundant. When short integers are passed to
variadic functions like pr_notice(), they are automatically promoted
to int, making the 'h' modifier unnecessary.

This addresses checkpatch warnings:
  WARNING: Integer promotion: Using 'h' in '%hd' is unnecessary
  WARNING: Integer promotion: Using 'h' in '%hx' is unnecessary
  WARNING: Integer promotion: Using 'h' in '%hu' is unnecessary

Changes:
- fs/afs/rotate.c: %hd → %d, %hx → %x
- fs/afs/vl_rotate.c: %hu → %u, %hx → %x, %hd → %d

Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
---
 fs/afs/rotate.c    | 4 ++--
 fs/afs/vl_rotate.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/afs/rotate.c b/fs/afs/rotate.c
index 6a4e7da10fc4..9c8dc6911b9b 100644
--- a/fs/afs/rotate.c
+++ b/fs/afs/rotate.c
@@ -724,7 +724,7 @@ void afs_dump_edestaddrreq(const struct afs_operation *op)
 	rcu_read_lock();
 
 	pr_notice("EDESTADDR occurred\n");
-	pr_notice("OP: cbb=%x cbb2=%x fl=%x err=%hd\n",
+	pr_notice("OP: cbb=%x cbb2=%x fl=%x err=%d\n",
 		  op->file[0].cb_break_before,
 		  op->file[1].cb_break_before, op->flags, op->cumul_error.error);
 	pr_notice("OP: ut=%lx ix=%d ni=%u\n",
@@ -735,7 +735,7 @@ void afs_dump_edestaddrreq(const struct afs_operation *op)
 	if (op->server_list) {
 		const struct afs_server_list *sl = op->server_list;
 
-		pr_notice("FC: SL nr=%u vnov=%hx\n",
+		pr_notice("FC: SL nr=%u vnov=%x\n",
 			  sl->nr_servers, sl->vnovol_mask);
 		for (i = 0; i < sl->nr_servers; i++) {
 			const struct afs_server *s = sl->servers[i].server;
diff --git a/fs/afs/vl_rotate.c b/fs/afs/vl_rotate.c
index 6ad9688d8f4b..fe4d41cb9ba5 100644
--- a/fs/afs/vl_rotate.c
+++ b/fs/afs/vl_rotate.c
@@ -336,7 +336,7 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc)
 	pr_notice("CELL: %s err=%d\n", cell->name, cell->error);
 	pr_notice("DNS: src=%u st=%u lc=%x\n",
 		  cell->dns_source, cell->dns_status, cell->dns_lookup_count);
-	pr_notice("VC: ut=%lx ix=%u ni=%hu fl=%hx err=%hd\n",
+	pr_notice("VC: ut=%lx ix=%u ni=%u fl=%x err=%d\n",
 		  vc->untried_servers, vc->server_index, vc->nr_iterations,
 		  vc->flags, vc->cumul_error.error);
 	pr_notice("VC: call  er=%d ac=%d r=%u\n",
@@ -348,7 +348,7 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc)
 			  sl->nr_servers, sl->index);
 		for (i = 0; i < sl->nr_servers; i++) {
 			const struct afs_vlserver *s = sl->servers[i].server;
-			pr_notice("VC: server %s+%hu fl=%lx E=%hd\n",
+			pr_notice("VC: server %s+%u fl=%lx E=%d\n",
 				  s->name, s->port, s->flags, s->probe.error);
 			if (s->addresses) {
 				const struct afs_addr_list *a =
-- 
2.43.0

Re: [PATCH] fs/afs: Remove unnecessary integer promotion in format strings
Posted by David Laight 1 month ago
On Fri,  2 Jan 2026 11:57:40 +0000
Dipendra Khadka <kdipendra88@gmail.com> wrote:

> Remove 'h' length modifier from printk format strings where integer
> promotion makes it redundant. When short integers are passed to
> variadic functions like pr_notice(), they are automatically promoted
> to int, making the 'h' modifier unnecessary.

Fairly pointless churn for existing code.

The message isn't really right either, 'short integers' are always
promoted to 'int' whenever they are used.
There is nothing special about variadic functions.

	David
Re: [PATCH] fs/afs: Remove unnecessary integer promotion in format strings
Posted by Dipendra Khadka 1 month ago
>Fairly pointless churn for existing code.
>
>The message isn't really right either, 'short integers' are always
>promoted to 'int' whenever they are used.
>There is nothing special about variadic functions.

Yeah , I accept that but this patch is for consistency.
Other subsytems are migrating. There are very small 
printk statements with "%hd","%hx" and "%hu".

root@ubuntu:/home/ubuntu/linux# git grep "%hd" . | wc -l
48
root@ubuntu:/home/ubuntu/linux# git log --oneline 
b69053dd3ffb (HEAD -> master, origin/master, origin/HEAD) wifi: mt76: Remove blank line after mt792x firmware version dmesg
af7809f037e6 Revert "wifi: mt76: Strip whitespace from build ddate"
9528d5c091c5 Merge tag 'platform-drivers-x86-v6.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
349bd28a86f2 Merge tag 'vfio-v6.19-rc4' of https://github.com/awilliam/linux-vfio


Best Regards,
Dipendra