Re: [PATCH] mm/oom_kill: Remove unnecessary integer promotion in format string
From: Andrew Morton
Date: Wed Dec 31 2025 - 20:45:59 EST
On Wed, 31 Dec 2025 12:21:17 +0000 Dipendra Khadka <kdipendra88@xxxxxxxxx> wrote:
> Since the value is already promoted to int internally, using %d is
> simpler and avoids the unnecessary cast. The checkpatch warning
> confirms this:
>
> ```
> WARNING: Integer promotion: Using 'h' in '%hd' is unnecessary
> #461: FILE: mm/oom_kill.c:461:
> + pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n",
> + current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
> + current->signal->oom_score_adj);
>
>
> WARNING: Integer promotion: Using 'h' in '%hd' is unnecessary
> #961: FILE: mm/oom_kill.c:961:
> + pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n",
> + message, task_pid_nr(victim), victim->comm, K(mm->total_vm),
> + K(get_mm_counter(mm, MM_ANONPAGES)),
> + K(get_mm_counter(mm, MM_FILEPAGES)),
> + K(get_mm_counter(mm, MM_SHMEMPAGES)),
> + from_kuid(&init_user_ns, task_uid(victim)),
> + mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);
> ```
>
> Checkpatch flags the 'h' modifier as unnecessary for this reason,
> and many other subsystems have moved to using %d for promoted types.
> Hence, I think this patch aligns with kernel coding practices.
hm, OK, this code is pretty lonely.
hp2:/usr/src/linux-6.19-rc3> grep -r "%hd" . | wc -l
50
Consistency is good.