Bug 86080 - Implicit function declarations
Summary: Implicit function declarations
Alias: None
Product: p11-glue
Classification: Unclassified
Component: p11-kit (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Stef Walter
QA Contact:
Depends on:
Reported: 2014-11-09 21:39 UTC by Daniel Macks
Modified: 2015-07-14 19:44 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

fix implicit decl on BSD (954 bytes, patch)
2015-05-02 10:24 UTC, Antoine Jacoutot
Details | Splinter Review

Description Daniel Macks 2014-11-09 21:39:04 UTC
Building 0.22.1 on OS X 10.8, I get two warnings about implicit function declarations:

common/test-message.c:53:6: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
        if (asprintf (&expected, "Details: value: %s", strerror (ENOENT)) < 0)

common/compat.c:820:12: warning: implicit declaration of function 'issetugid' is invalid in C99 [-Wimplicit-function-declaration]
                secure = issetugid ();

This type of warning is usually a missing #include. It's sometimes platform-specific (other platforms might get them implicitly via other explicitly #included ones), but rarely a problem to do them explicitly on all platforms (especially given how universal these specific cases are). According to my manpages for these functions, asprintf() is declared via stdio.h and issetugid() via unistd.h
Comment 1 Daniel Macks 2014-11-09 22:04:11 UTC
Adding #include <stdio.h> to common/test-message.c solves asprintf().

issetugid() is weird...I need to set -D_DARWIN_C_SOURCE in order for unistd.h (which already *was* being included implicitly/indirectly) to actually supply the prototype for it. Chalk it up to darwin being weird, I guess?
Comment 2 Stef Walter 2014-11-14 06:10:11 UTC
A patch would be welcome. I don't have a Mac at my disposal to test such a fix. I could include the patch in 0.22.2
Comment 3 Antoine Jacoutot 2015-05-02 10:24:48 UTC
Created attachment 115512 [details] [review]
fix implicit decl on BSD

Hi Stef.

I see the same issue on OpenBSD.
Here's a patch that fixes all implicit decl for me.
Comment 4 Stef Walter 2015-07-14 19:44:06 UTC
Comment on attachment 115512 [details] [review]
fix implicit decl on BSD

Sorry for the delay reviewing this. This causes build problems on Linux:

In file included from /usr/include/sys/types.h:25:0,
                 from /data/src/p11-kit/x86_64/../common/compat.h:40,
                 from /data/src/p11-kit/x86_64/../common/compat.c:48:
/usr/include/features.h:148:3: error: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Werror=cpp]

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.