svn commit: r303988 - head/lib/libc/gen

Bryan Drewery bdrewery at FreeBSD.org
Wed Aug 24 20:30:48 UTC 2016


On 8/24/16 1:26 PM, Eric van Gyzen wrote:
> On 08/24/2016 15:16, Bryan Drewery wrote:
>> On 8/24/16 1:12 PM, Eric van Gyzen wrote:
>>> On 08/24/2016 15:01, Ed Schouten wrote:
>>>> 2016-08-24 21:53 GMT+02:00 Bryan Drewery <bdrewery at freebsd.org>:
>>>>> Is it possible to cause the use of these old prototypes to print a
>>>>> warning and note that they are deprecated/unsafe?
>>>>
>>>> That's a good question. In theory, we could annotate these functions
>>>> with __attribute__((__deprecated__)):
>>>>
>>>> https://gcc.gnu.org/onlinedocs/gcc-3.3.4/gcc/Type-Attributes.html
>>>>
>>>> But I'm actually too afraid to use it. In the worst case it may cause
>>>> the compiler to generate a warning even when basename()/dirname() is
>>>> used correctly, as __old_* will still be part of the compiled
>>>> expression.
>>>
>>> Could __warn_references() be used, as libc currently does for gets() and
>>> others?
>>>
>>> Eric
>>>
>>
>> /usr/include/stdio.h:extern char *gets (char *__s) __wur
>> __attribute_deprecated__;
>> /usr/include/x86_64-linux-gnu/sys/cdefs.h:# define
>> __attribute_deprecated__ __attribute__ ((__deprecated__))
>>
>> __wur being warning about unused result.
> 
> /usr/src/lib/libc/stdio/gets.c:__warn_references(gets, "warning: this
> program uses gets(), which is unsafe.");

Ah! Ours! I misunderstood and thought about the FORTIFY_SOURCE glibc stuff.

This is a linker warning.  It would not be as obvious which line is the
problem but would still tell the user they have potentially unsafe code.
 They also may not care if not using threads.

We would need to move old_dirname/basename into their own .c files to
use this I think. Playing around with that...

> 
>> As for actually using it here, I tried adding it onto the
>> _old_dirname/basename prototypes.  It produces an error, fine, in the
>> bootstrap build for xinstall it would not error, great.  However, for
>> building xinstall on head where it will not use the __old_dirname and
>> will use the new dirname at FBSD_1.5, it _still_ complains about using the
>> __old_dirname() prototype via __generic and errors in the wrong case.


-- 
Regards,
Bryan Drewery

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20160824/f18bc5a5/attachment-0001.sig>


More information about the svn-src-all mailing list