I kept the original size_t buflen (because snprintf takes a size_t argument), 
and then just cast the LHS of the if statement to (size_t) -- explicitly 
promote it (to avoid -Wsign-compare
which is the default for NetBSD and this is probably what that person was 
observing. 
I think this is cleaner than making things int (which changes the original 
semantics) as opposed to the
cast that made the promotion explicit.

christos

> On Oct 3, 2026, at 5:22 PM, Paul Eggert <[email protected]> wrote:
> 
> On 2026-10-03 11:44, Christos Zoulas wrote:
>> I am wondering why size_t was changed to int?
>> Is it because of the < bufsize comparison?
> 
> Yes, a compiler (I forget which) complained about signed vs unsigned 
> comparison not because it was incorrect, but because it was confusing. I 
> changed one side to signed without noticing the problem that you noticed.
> 
>> That works because the negative value on error return
>> gets promoted to unsigned.
> 
> Thanks, good catch. I installed the attached to fix that. I suppose I should 
> be more skeptical about compiler diagnostics, or more precisely, about my 
> attempts to silence false 
> alarms....<0001-asctime_r-checks-for-negative-snprintf-again.patch>

Reply via email to