[Mesa-dev] [PATCH] loader: include <sys/stat.h> for non-sysfs builds
Ian Romanick
idr at freedesktop.org
Wed Mar 11 15:18:35 PDT 2015
On 03/11/2015 02:44 PM, Emil Velikov wrote:
> On 11 March 2015 at 20:50, Ian Romanick <idr at freedesktop.org> wrote:
>> On 03/11/2015 12:12 PM, Emil Velikov wrote:
>>> Required by fstat(), otherwise we'll error out due to implicit function
>>> declaration.
>>
>> Alternate suggestion... include unistd.h unconditionally. I see that's
>> already in the #ifdef HAVE_LIBUDEV path. Does that work too?
>>
> Perhaps the commit message is a bit confusing, but your suggestion
> does not parse here. How does the following sound ?
>
> When building with libudev (non-sysfs) we don't include sys/stat.h
> thus we error out due to the implicit declaration of the function
> fstat().
What I meant was:
diff --git a/src/loader/loader.c b/src/loader/loader.c
index 9ff5115..4709b02 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -67,11 +67,11 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#ifdef HAVE_LIBUDEV
#include <assert.h>
#include <dlfcn.h>
#include <fcntl.h>
-#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#ifdef USE_DRICONF
@@ -80,7 +80,6 @@
#endif
#endif
#ifdef HAVE_SYSFS
-#include <sys/stat.h>
#include <sys/types.h>
#endif
#include "loader.h"
The fstat man page led me to believe that fstat also comes from
unistd.h, but
http://pubs.opengroup.org/onlinepubs/009695399/functions/fstat.html
leads me to believe that is incorrect. That link also says that 'struct
stat' is defined in sys/stat.h, so the implicit function declaration
should have been the least of the problems.
In any case, just ignore all my noise.
More information about the mesa-dev
mailing list