|
From: James H. <jam...@gm...> - 2015-03-26 22:31:25
|
I was looking at some of the compiler warnings I get while building trunk.
sshguard_options.c: In function ‘get_options_cmdline’:
sshguard_options.c:148:21: warning: implicit declaration of function
‘setenv’ [-Wimplicit-function-declaration]
setenv("SSHGUARD_EVENT_EXECUTE", optarg, 1);
sshguard_logsuck.c: In function ‘read_from’:
sshguard_logsuck.c:354:13: warning: implicit declaration of function
‘usleep’ [-Wimplicit-function-declaration]
usleep(20 * 1000);
If I remove AM_CFLAGS+= -D_XOPEN_SOURCE from the non Solaris case the
warnings go. Another way to go is set AM_CFLAGS+= -D_XOPEN_SOURCE=600 as
that will also remove the warning. In other words remove the conditional
and the compile completes without issue.
My "man 3 usleep" has
usleep():
Since glibc 2.12:
_BSD_SOURCE ||
(_XOPEN_SOURCE >= 500 ||
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
!(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
Before glibc 2.12:
_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE &&
_XOPEN_SOURCE_EXTENDED
and my "man 3 setenv" has
setenv(), unsetenv():
_BSD_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
So what do we think is safer ? Remove _XOPEN_SOURCE or add || LINUX to the
solaris conditional?
--
James Harris
Software Engineer
jam...@gm...
|
|
From: mij <mi...@ss...> - 2015-03-27 09:43:28
|
When running portability-related assessments, avoid “man” as the pest.
“man” is the most implementation-specific source of information you can find.
Run “man” on two different systems, get two different descriptions.
SSHGuard was written against POSIX, and that’s what enabled it to run on
such wide range of servers. Let’s try to maintain it at that level. Use the POSIX
reference from the OpenGroup.
cheers
michele
> On 26 Mar 2015, at 23:31, James Harris <jam...@gm...> wrote:
>
>
> I was looking at some of the compiler warnings I get while building trunk.
>
> sshguard_options.c: In function ‘get_options_cmdline’:
> sshguard_options.c:148:21: warning: implicit declaration of function ‘setenv’ [-Wimplicit-function-declaration]
> setenv("SSHGUARD_EVENT_EXECUTE", optarg, 1);
>
>
> sshguard_logsuck.c: In function ‘read_from’:
> sshguard_logsuck.c:354:13: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
> usleep(20 * 1000);
>
>
> If I remove AM_CFLAGS+= -D_XOPEN_SOURCE from the non Solaris case the warnings go. Another way to go is set AM_CFLAGS+= -D_XOPEN_SOURCE=600 as that will also remove the warning. In other words remove the conditional and the compile completes without issue.
>
>
> My "man 3 usleep" has
>
> usleep():
> Since glibc 2.12:
> _BSD_SOURCE ||
> (_XOPEN_SOURCE >= 500 ||
> _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
> !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
> Before glibc 2.12:
> _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
>
> and my "man 3 setenv" has
>
> setenv(), unsetenv():
> _BSD_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
>
>
> So what do we think is safer ? Remove _XOPEN_SOURCE or add || LINUX to the solaris conditional?
>
> --
> James Harris
> Software Engineer
> jam...@gm...
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/_______________________________________________
> Sshguard-users mailing list
> Ssh...@li...
> https://lists.sourceforge.net/lists/listinfo/sshguard-users
|
|
From: Kevin Z. <kev...@gm...> - 2015-03-27 22:54:56
Attachments:
0001-Correctly-set-POSIX-feature-test-macro.patch
|
On 03/26/2015 17:31, James Harris wrote: > If I remove AM_CFLAGS+= -D_XOPEN_SOURCE from the non Solaris case the > warnings go. Another way to go is set AM_CFLAGS+= -D_XOPEN_SOURCE=600 as > that will also remove the warning. In other words remove the conditional > and the compile completes without issue. Here's what the Open Group has to say [1]: "An XSI-conforming application should ensure that the feature test macro _XOPEN_SOURCE is defined with the value 600 before inclusion of any header." > So what do we think is safer ? Remove _XOPEN_SOURCE or add || LINUX to > the solaris conditional? I think the standard is pretty clear about unconditionally setting _XOPEN_SOURCE to 600. I've attached a patch that does just that. If there are no objections I'll commit it. Note that this is the only source directory that sets _XOPEN_SOURCE; should the others too? Thanks, Kevin Zheng [1] http://pubs.opengroup.org/onlinepubs/007904875/functions/xsh_chap02_02.html -- Kevin Zheng kev...@gm... | ke...@kd... | PGP: 0xC22E1090 |
|
From: mij <mi...@ss...> - 2015-03-27 23:14:29
|
> > Here's what the Open Group has to say [1]: > > "An XSI-conforming application should ensure that the feature test macro > _XOPEN_SOURCE is defined with the value 600 before inclusion of any header." > >> So what do we think is safer ? Remove _XOPEN_SOURCE or add || LINUX to >> the solaris conditional? > > I think the standard is pretty clear about unconditionally setting > _XOPEN_SOURCE to 600. I've attached a patch that does just that. If > there are no objections I'll commit it. A radical change like switching feature test macros should be tested before committing. It doesn’t always work as expected. > Note that this is the only source directory that sets _XOPEN_SOURCE; > should the others too? All should, but careful what Automake inherits. -m |