Re: git: 195b00ec45e5 - main - quot: Clean up

From: Ryan Libby <rlibby_at_gmail.com>
Date: Fri, 17 Oct 2025 22:01:04 UTC
On Fri, Oct 17, 2025 at 4:55 AM Dag-Erling Smørgrav <des@freebsd.org> wrote:
>
> The branch main has been updated by des:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=195b00ec45e55c38da13d1bcd2d7eb6614abec59
>
> commit 195b00ec45e55c38da13d1bcd2d7eb6614abec59
> Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
> AuthorDate: 2025-10-17 11:54:59 +0000
> Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
> CommitDate: 2025-10-17 11:54:59 +0000
>
>     quot: Clean up
>
>     * Fix numerous style violations.
>     * Modernize somewhat.
>     * Don't bother examining errno after calling get_inode(), as it always
>       exits on error.
>     * Fix confusing wording in the manual page.
>
>     The code remains somewhat idiosyncratic, e.g. in its insistance on
>     counting down rather than up in simple for loops, but in the absence
>     of comprehensive automated tests, the risk of introducing bugs exceeds
>     the benefit of rewriting these into more idiomatic forms.
>
>     Reviewed by:    obiwac
>     Differential Revision:  https://reviews.freebsd.org/D53130
> ---
>  usr.sbin/quot/Makefile |   2 -
>  usr.sbin/quot/quot.8   |   7 +-
>  usr.sbin/quot/quot.c   | 227 ++++++++++++++++++++++---------------------------
>  3 files changed, 106 insertions(+), 130 deletions(-)
>
> diff --git a/usr.sbin/quot/Makefile b/usr.sbin/quot/Makefile
> index ed8360ae938e..34ebcb1009c8 100644
> --- a/usr.sbin/quot/Makefile
> +++ b/usr.sbin/quot/Makefile
> @@ -2,6 +2,4 @@ PROG=   quot
>  MAN=   quot.8
>  LIBADD=        ufs
>
> -WARNS?=        2
> -

Apparently this broke the gcc build:
https://ci.freebsd.org/job/FreeBSD-main-amd64-gcc14_build/1897/

> --- all_subdir_usr.sbin/quot ---
> In function 'usrrehash',
>     inlined from 'user' at /workspace/src/usr.sbin/quot/quot.c:244:3:
> /workspace/src/usr.sbin/quot/quot.c:210:22: error: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
>   210 |         if ((users = calloc(nusers, sizeof(*users))) == NULL)
>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from /workspace/src/usr.sbin/quot/quot.c:51:
> /tmp/obj/workspace/src/amd64.amd64/tmp/usr/include/stdlib.h: In function 'user':
> /tmp/obj/workspace/src/amd64.amd64/tmp/usr/include/stdlib.h:92:10: note: in a call to allocation function 'calloc' declared here
>    92 | void    *calloc(size_t, size_t) __malloc_like __result_use_check
>       |          ^~~~~~

Probably it is from
-WARNS?=        2

I think gcc is saying that it thinks nusers may be negative.  Maybe we
can convince it that it can't be?  For example, this rescues the build

$ git diff
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c
index 879580f649b9..384ae5b0c27e 100644
--- a/usr.sbin/quot/quot.c
+++ b/usr.sbin/quot/quot.c
@@ -178,7 +178,7 @@ static struct user {
        daddr_t spc60;
        daddr_t spc90;
 } *users;
-static int nusers;
+static unsigned int nusers;

 static void
 inituser(void)

Ryan