On Tue, Aug 19, 2025 at 12:05 PM Askar Safin <safinas...@zohomail.com> wrote:
>
> TL;DR: this patchset fixes regression, introduced in aecc554e7b.
> This patchset should be backported to all distributions, which packaged 
> v2.0.31, otherwise
> kexec doesn't work at all at my laptop with pretty common setup with v2.0.31.
> v2.0.31 is broken without this patchset.
>
> See details of this bug on my laptop in first commit message.
>
> Okay, why the bug happens? I suspect this is because of "%lux"
> string specifiers, which are totally wrong. The author meant "print (and 
> scan) in hexademical"
> here, but this specifier prints (and scans) number in decimal, followed by 
> literal "x". Oops.
> And this seems to break kexec.
>
> The bug reproduces on kexec-tools aecc554e7ba , but
> doesn't reproduce on kexec-tools 6aecc32c6db .
>
> I. e. it is regression, introduced by aecc554e7ba .
>
> Okay, how to fix this? Well, this is not easy. In 07821da7cf and d2f4297166 
> Andy Shevchenko
> observed compilation warnings, when %lx is used with uint64_t, so he replaced 
> %lx with %llx.
>
> Then in aecc554e7b Jeremy Linton observed warnings with %llx and replaced it 
> with %lux.
> (Yes, C is nightmare.)
>
> So, uint64_t is sometimes defined as long unsigned, and thus needs %lx, and 
> sometimes as
> long long unsigned and thus needs %llx.
>
> How to fix this once and for all?
>
> I see three ways.
>
> 1. uint64_t a; printf ("%llx", (unsigned long long)a);
> 2. uint64_t a; printf ("%" PRIx64, a);
> 3. uint64_t a; printf ("%w64x", a);
>
> I think that %w64x is beautiful, but it causes compilation warnings on clang. 
> (Facepalm.)
> Also it was introduced in C23, which is too young.
>
> "(unsigned long long)a" is the best in my opinion. This is what I used in v1.
> But Andy said to me that POD conversions are evil.
>
> PRIx64 is ugly, but this is the only option left. So this is what I used in 
> this version.
>
> Also this patchset fixes other misc things. See commit messages for details.
>
> I tested on my laptop that this patchset actually fixes the bug.

There are still some small issues with the commit messages, otherwise LGTM.
After addressing them, feel free to add
Reviewed-by: Andy Shevchenko <a...@kernel.org>
to the entire series.

-- 
With Best Regards,
Andy Shevchenko

Reply via email to