Fix a build warning of strnlen: lport.c: In function ‘sysfs_scan’: lport.c:390: warning: implicit declaration of function ‘strnlen’
The build warning is because __USE_GNU is not defined in /usr/include/string.h. The man page of strnlen requires #define _GNU_SOURCE to present before #include <string.h>. The fix is to make #define _GNU_SOURCE to be the very first thing in the file utils.h which is the first include file of lport.c, and because almost every header file in /usr/include includes features.h, __USE_GNU will be defined by features.h if _GNU_SOURCE is defined. We do not use #define __USE_GNU before #include <string.h> because __USE_GNU is a glibc internal macro. In addition to this fix, an unused variable is also removed. Signed-off-by: Steve Ma <[email protected]> --- pci.c | 1 - utils.h | 1 + 2 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pci.c b/pci.c index ee53c3d..82879bf 100644 --- a/pci.c +++ b/pci.c @@ -152,7 +152,6 @@ static void get_pci_device_info(struct pci_device *dev, struct hba_info *hba_info) { const char *name; - u_int16_t class; u_int8_t revision; u_int8_t hdr_type; char *unknown = "Unknown"; diff --git a/utils.h b/utils.h index 13109e2..3b1781a 100644 --- a/utils.h +++ b/utils.h @@ -19,6 +19,7 @@ #ifndef _UTILS_H_ #define _UTILS_H_ +#define _GNU_SOURCE #include <sys/types.h> #include <sys/stat.h> #include <sys/param.h> _______________________________________________ devel mailing list [email protected] http://www.open-fcoe.org/mailman/listinfo/devel
