[PATCH v2 5/5] inet: Implement inet_ntoa on top of inet_ntop

Collin Funk collin.funk1@gmail.com
Fri Jun 6 03:58:45 GMT 2025


Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:

>> Nothing major, but can't you just do:
>> 
>>     return __inet_ntop (AF_INET, &in, buffer, sizeof buffer);
>> 
>> Or does that cause a warning about a discard const qualifier?
>
> Yeah, that's why I did it:
>
> inet_ntoa.c: In function ‘inet_ntoa’:
> inet_ntoa.c:32:10: error: return discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
>    32 |   return __inet_ntop (AF_INET, &in, buffer, sizeof buffer);
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors

Okay, makes perfect sense then. The patch as-is is better than adding a
cast in my opinion.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin


More information about the Libc-alpha mailing list