Re: [0/5] lib: resync lib/div64.c and <linux/math64.h> with Linux v7.1

Simon Glass <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <CAFLszTjKpeJZZ=6Nv31zKh6QQ6-9s72dZTGQiG7wiwNg+Ws8dA@mail.gmail.com>
Hi Alexey,

On 2026-07-30T18:40:37, Alexey Charkov <[email protected]> wrote:

> While auditing the header, two bugs turned up in lib/div64.c, so this
> series starts with those. Both are 32-bit only:

Thanks for looking at this!

> - div64_u64() and div64_u64_rem() shifted by 1 + fls(high) instead of
>   fls(high), losing a bit of the divisor. Linux fixed this in 2019, while
>   U-Boot never picked it up.

Since patch 1 has such a nice reproducer, how about adding a small
self-test under test/lib/ for div64_u64() and div64_s64() as part of
this series? It would guard against future regressions on 32-bit and
give the sync patches some cover. A handful of the
divisor-just-above-2^32 cases plus the div64_s64() truncation case
would be plenty.

Regards,
Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.