Re: [PATCH v2 3/1] t-strvec: tighten .alloc check in check_strvec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 15.07.24 um 16:43 schrieb Junio C Hamano:
> René Scharfe <l.s.r@xxxxxx> writes:
>
>> diff --git a/t/unit-tests/t-strvec.c b/t/unit-tests/t-strvec.c
>> index fdb28ba220..6a4d425840 100644
>> --- a/t/unit-tests/t-strvec.c
>> +++ b/t/unit-tests/t-strvec.c
>> @@ -8,7 +8,9 @@
>>  		if (check_uint(ARRAY_SIZE(expect), >, 0) && \
>>  		    check_pointer_eq(expect[ARRAY_SIZE(expect) - 1], NULL) && \
>>  		    check_uint((vec)->nr, ==, ARRAY_SIZE(expect) - 1) && \
>> -		    check_uint((vec)->nr, <=, (vec)->alloc)) { \
>> +		    ((vec)->v == empty_strvec ? \
>> +		     check_uint((vec)->nr, ==, (vec)->alloc) : \
>> +		     check_uint((vec)->nr, <, (vec)->alloc))) { \
>
> Not a huge deal but with empty_strvec, don't we want to barf if
> nr==alloc==1?

Yes, and that's handled by the comparison with ARRAY_SIZE(expect) - 1
above.  Perhaps comparing to 0 explicitly would be clearer.  My thinking
was just to split up the old <= check into its < and == cases, without
changing anything else..

>
>>  			for (size_t i = 0; i < ARRAY_SIZE(expect); i++) { \
>>  				if (!check_str((vec)->v[i], expect[i])) { \
>>  					test_msg("      i: %"PRIuMAX, i); \
>> --
>> 2.45.2





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux