On Thu, May 14, 2026 at 7:56 PM Thorsten Blum <[email protected]> wrote:
>
> Use min() and drop the limit variable to simplify sized_strscpy().

...

> -       if ((long)src & (sizeof(long) - 1)) {
> -               size_t limit = PAGE_SIZE - ((long)src & (PAGE_SIZE - 1));
> -               if (limit < max)
> -                       max = limit;
> -       }
> +       if ((long)src & (sizeof(long) - 1))
> +               max = min(PAGE_SIZE - ((long)src & (PAGE_SIZE - 1)), max);

Side note: Isn't simply
               max = min(PAGE_SIZE - offset_in_page(src), max);

? (One will need to include linux/mm.h for this, though.)

Moreover there are plenty of duplications to count the size in the
first page and even the similar min() as in
  fs/iomap/buffered-io.c:869
  arch/s390/kvm/gaccess.c:976
and many more...

Perhaps a new macro with a good (famous last words!) naming?

-- 
With Best Regards,
Andy Shevchenko

Reply via email to