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

From: Dag-Erling_Smørgrav <des_at_FreeBSD.org>
Date: Mon, 20 Oct 2025 16:42:06 UTC
Ryan Libby <rlibby@gmail.com> writes:
> Dag-Erling Smørgrav <des@freebsd.org> writes:
>> 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.

It's saying nusers may be large enough that the result of multiplying it
by sizeof(*users) exceeds an arbitrary threshold, which is technically
true but completely unhelpful.  This gcc option should not be used.

DES
-- 
Dag-Erling Smørgrav - des@FreeBSD.org