[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-mtools] [PATCH] Use own definition of strtoi
From: |
Sam James |
Subject: |
Re: [Info-mtools] [PATCH] Use own definition of strtoi |
Date: |
Wed, 13 Apr 2022 05:11:50 +0100 |
> On 10 Apr 2022, at 19:34, Alain Knaff <alain@knaff.lu> wrote:
>
> Hi,
>
> On 06/03/2022 03:42, Sam James wrote:
>> Before this change, build resulted in implicit function declarations like:
>> ```
>> * config.c:269:57: warning: implicit declaration of function ‘strtoi’; did
>> you mean ‘strtoui’? [-Wimplicit-function-declaration]
>> * floppyd_io.c:473:20: warning: implicit declaration of function ‘strtoi’;
>> did you mean ‘strtoui’? [-Wimplicit-function-declaration]
>> ```
>>
>> The include(s) for inttypes.h are guarded by HAVE_INTTYPES_H
>> (normal autoconf pattern) but we're not checking for inttypes.h
>> in configure. But adding this doesn't solve the issue.
>>
>> If libbsd is installed, configure discovers the strtoi
>> provided by libbsd although the included version may still
>> end up being glibc's as the include path doesn't change
>> (glibc has its own which doesn't feature strtoi).
>>
>> If trying to use libbsd's, we end up with a build failure:
>> ```
>> config.c: In function ‘get_env_conf’:
>> config.c:269:57: error: too few arguments to function ‘strtoi’
>> 269 | * ((int *)global_switches[i].address) = strtoi(s,0,0);
>> | ^~~~~~
>> In file included from sysincludes.h:174,
>> from config.c:18:
>> /usr/include/bsd/inttypes.h:43:10: note: declared here
>> 43 | intmax_t strtoi(const char *__restrict nptr, char **__restrict endptr,
>> | ^~~~~~
>> ```
>
> Thanks for the note, I wasn't aware that BSD was actually using strtoi
> for something which is not just the signed int equivalent of strtoui.
>
>>
>> So, it seems best to just always use our own definition of strtoi,
>> given our definition doesn't match libbsd's anyway. This avoids
>> the build failure as well as the implicit declaration warnings.
>
> I preferred to change the name instead: strtosi (str to *s*igned *i*nt),
> that way there is no confusion possible.
>
> Fix is in 4.0.39
>
Thanks!
> Regards,
>
> Alain
Best,
sam
signature.asc
Description: Message signed with OpenPGP