Unix Technical Forum

Re: Default GCC behaviour on OpenBSD vs Linux

This is a discussion on Re: Default GCC behaviour on OpenBSD vs Linux within the mailing.openbsd.tech forums, part of the OpenBSD category; --> The warnings printed by the linker are very handy, and it's not a local customization either.. it's just not ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-24-2008, 10:30 PM
Brynet
 
Posts: n/a
Default Re: Default GCC behaviour on OpenBSD vs Linux

The warnings printed by the linker are very handy, and it's not a
local customization either.. it's just not very widely utilized.

/usr/include/`uname -m`/cdefs.h determines if GCC is being used and
defines __warn_references as follows:

#define __warn_references(sym,msg) \
__asm__(".section .gnu.warning." __STRING(sym) \
" ; .ascii \"" msg "\" ; .text")
#endif

Then, in strcpy.c for instance, the C preprocessor first checks to see
if APIWARN is defined, and if it is, the function is marked as unsafe.

#if defined(APIWARN)
__warn_references(strcpy,
"warning: strcpy() is almost always misused, please use strlcpy()");
#endif

Personally, I think it's a brilliant idea.. but this reminds me,
several files don't define that...

/usr/src/lib/libc/stdio/gets.c
/usr/src/lib/libc/stdio/mktemp.c
/usr/src/lib/libc/stdio/tempnam.c
/usr/src/lib/libc/stdio/tmpnam.c
/usr/src/lib/libc/compat-43/getwd.c
/usr/src/lib/libcompat/4.3/setruid.c
/usr/src/lib/libcompat/4.3/setrgid.c

I'm not sure if that was the intent of the developers, or if it was an
oversight.. regardless I'll send patches if anyone wants them.

Be well. 8)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-27-2008, 11:09 AM
Ted Unangst
 
Posts: n/a
Default Re: Default GCC behaviour on OpenBSD vs Linux

On 6/24/08, Brynet <brynet@gmail.com> wrote:
> Personally, I think it's a brilliant idea.. but this reminds me,
> several files don't define that...
>
> /usr/src/lib/libc/stdio/gets.c
> /usr/src/lib/libc/stdio/mktemp.c


Some warnings are not optional.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:33 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com