From 4026323383aef6afc9c6844b5a549e35ee8c1dc8 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Fri, 22 Mar 2019 15:16:47 -0600 Subject: [PATCH] Fix minor --ansi warnings in dinfermodel.c and bzlib.c re: Needed to provide centralized definitions of fileno and fdopen; also need to #include sys/types.h --- CMakeLists.txt | 1 + config.h.cmake.in | 2 ++ include/ncconfigure.h | 10 +++++++++- libdispatch/dfile.c | 1 - libdispatch/dinfermodel.c | 8 ++++++-- libdispatch/dparallel.c | 1 - plugins/bzlib.c | 1 + 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f61541d..a0a0d2270 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1418,6 +1418,7 @@ CHECK_FUNCTION_EXISTS(getrlimit HAVE_GETRLIMIT) CHECK_FUNCTION_EXISTS(_filelengthi64 HAVE_FILE_LENGTH_I64) CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP) CHECK_FUNCTION_EXISTS(mremap HAVE_MREMAP) +CHECK_FUNCTION_EXISTS(fileno HAVE_FILENO) # Check to see if MAP_ANONYMOUS is defined. CHECK_C_SOURCE_COMPILES(" diff --git a/config.h.cmake.in b/config.h.cmake.in index f1621bbae..46ee7da33 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -199,6 +199,8 @@ are set when opening a binary file on Windows. */ /* Define if we have filelengthi64. */ #cmakedefine HAVE_FILE_LENGTH_I64 @HAVE_FILE_LENGTH_I64@ +/* Define to 1 if you have the `fileno' function. */ +#cmakedefine HAVE_FILENO 1 /* Define to 1 if you have the `fsync' function. */ #cmakedefine HAVE_FSYNC 1 diff --git a/include/ncconfigure.h b/include/ncconfigure.h index ef2f55bbc..2c5b2c8fd 100644 --- a/include/ncconfigure.h +++ b/include/ncconfigure.h @@ -13,6 +13,9 @@ #ifdef HAVE_STDLIB_H #include #endif +#ifdef HAVE_STDIO_H +#include +#endif /* This is included in bottom @@ -63,8 +66,13 @@ extern int snprintf(char*, size_t, const char*, ...); extern int strcasecmp(const char*, const char*); extern long long int strtoll(const char*, char**, int); extern unsigned long long int strtoull(const char*, char**, int); + +#ifndef fileno +extern int fileno(FILE*); #endif -#endif + +#endif /*STDC*/ +#endif /*!WIN32*/ #ifdef _WIN32 #ifndef strlcat diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 72d424a43..56e4cf205 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -32,7 +32,6 @@ #ifdef HAVE_STDIO_H #include #endif -extern int fileno(FILE*); #include "ncdispatch.h" #include "netcdf_mem.h" diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index c4a270fed..f65270f49 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -13,6 +13,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif #include "ncdispatch.h" #include "ncwinpath.h" @@ -775,10 +778,11 @@ openmagic(struct MagicFile* file) { if(file->path == NULL || strlen(file->path)==0) {status = NC_EINVAL; goto done;} + #ifdef _WIN32 - file->fp = fopen(file->path, "rb"); + file->fp = NCfopen(file->path, "rb"); #else - file->fp = fopen(file->path, "r"); + file->fp = NCfopen(file->path, "r"); #endif if(file->fp == NULL) {status = errno; goto done;} diff --git a/libdispatch/dparallel.c b/libdispatch/dparallel.c index 5400e83dd..21e5e5ee3 100644 --- a/libdispatch/dparallel.c +++ b/libdispatch/dparallel.c @@ -10,7 +10,6 @@ #ifdef HAVE_STDIO_H #include #endif -extern int fileno(FILE*); /** Create a netCDF file for parallel I/O. diff --git a/plugins/bzlib.c b/plugins/bzlib.c index bd358a793..7629b3f94 100644 --- a/plugins/bzlib.c +++ b/plugins/bzlib.c @@ -30,6 +30,7 @@ #include "bzlib_private.h" +extern FILE* fdopen(int,const char*); /*---------------------------------------------------*/ /*--- Compression stuff ---*/