misc: fix compile warnings on OSX
PATCH 1/1 misc: fix compile warnings on OSX
The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not really have anything to do with __GNUC__ (which is also used on OS/X and Solaris). Only print these warnings on Linux systems.
statfs64() is deprecated on OSX and generates a deliberate warning. Fix some other warnings that show up on OSX builds.
Signed-off-by Andreas Dilger <[email protected]>
--- lib/e2p/fgetflags.c | 8 ++++---- lib/e2p/fsetflags.c | 15 ++++++++------- lib/e2p/getflags.c | 5 +++-- lib/e2p/setflags.c | 5 +++-- lib/ext2fs/flushb.c | 12 ++++-------- lib/ext2fs/getsize.c | 2 +- 6 files changed, 23 insertions(+), 24 deletions(-)
lib/e2p/fgetflags.c +4 -4
@@ -63,7 +63,7 @@ int fgetflags (const char * name, unsigned long * flags)#endif return 0 ; -#else +#else /* !HAVE_STAT_FLAGS || (APPLE_DARWIN && HAVE_EXT2_IOCTLS) */ #if HAVE_EXT2_IOCTLS int fd, r, f, save_errno =0 ;
@@ -83,15 +83,15 @@ int fgetflags (const char * name, unsigned long * flags)if (save_errno) errno = save_errno;return r; -#else +#else /* APPLE_DARWIN */ f =-1 ; save_errno =syscall (SYS_fsctl, name,EXT2_IOC_GETFLAGS , &f,0 ); *flags = f;return (save_errno); -#endif +#endif /* !APPLE_DARWIN */ +notsupp:#endif /* HAVE_EXT2_IOCTLS */ #endif -notsupp: errno =EOPNOTSUPP ;return -1 ; }
lib/e2p/fsetflags.c +8 -7
@@ -51,7 +51,6 @@int fsetflags (const char * name,unsigned long flags) { -struct stat buf;#if HAVE_CHFLAGS && !(APPLE_DARWIN &&HAVE_EXT2_IOCTLS )unsigned long bsd_flags =0 ;
@@ -69,9 +68,10 @@ int fsetflags (const char * name, unsigned long flags)#endif return chflags (name, bsd_flags); -#else +#else /* !HAVE_CHFLAGS || (APPLE_DARWIN && HAVE_EXT2_IOCTLS) */ #if HAVE_EXT2_IOCTLS int fd, r, f, save_errno =0 ; +struct stat buf;if (!lstat (name, &buf) && !S_ISREG (buf.st_mode) && !S_ISDIR (buf.st_mode)) {
@@ -88,14 +88,15 @@ int fsetflags (const char * name, unsigned long flags)close (fd);if (save_errno) errno = save_errno; -#else - f = (int ) flags; -return syscall (SYS_fsctl, name,EXT2_IOC_SETFLAGS , &f,0 ); -#endif +#else /* APPLE_DARWIN */ + f = (int ) flags; +return syscall (SYS_fsctl, name,EXT2_IOC_SETFLAGS , &f,0 ); +#endif /* !APPLE_DARWIN */ return r; + +notsupp:#endif /* HAVE_EXT2_IOCTLS */ #endif -notsupp: errno =EOPNOTSUPP ;return -1 ; }
lib/e2p/getflags.c +3 -2
@@ -57,12 +57,13 @@ int getflags (int fd, unsigned long * flags)if (!fstat (fd, &buf) && !S_ISREG (buf.st_mode) && !S_ISDIR (buf.st_mode)) goto notsupp; - r =ioctl (fd,EXT2_IOC_GETFLAGS , &f); + r =ioctl (fd,EXT2_IOC_GETFLAGS , &f); *flags = f; +return r; +notsupp:#endif /* HAVE_EXT2_IOCTLS */ #endif -notsupp: errno =EOPNOTSUPP ;return -1 ; }
lib/e2p/setflags.c +3 -2
@@ -38,7 +38,6 @@int setflags (int fd,unsigned long flags) { -struct stat buf;#if HAVE_CHFLAGS unsigned long bsd_flags =0 ;
@@ -58,6 +57,7 @@ int setflags (int fd, unsigned long flags)return fchflags (fd, bsd_flags);#else #if HAVE_EXT2_IOCTLS +struct stat buf;int f; if (!fstat(fd, &buf) &&
@@ -66,7 +66,8 @@ int setflags (int fd, unsigned long flags)return -1 ; } f = (int ) flags; -return ioctl (fd,EXT2_IOC_SETFLAGS , &f); + +return ioctl (fd,EXT2_IOC_SETFLAGS , &f);#endif /* HAVE_EXT2_IOCTLS */ #endif errno =EOPNOTSUPP ;
lib/ext2fs/flushb.c +4 -8
@@ -65,17 +65,13 @@ errcode_t ext2fs_sync_device(int fd, int flushb)#ifdef BLKFLSBUF if (ioctl (fd,BLKFLSBUF ,0 ) ==0 )return 0 ; -#else -#ifdef __GNUC__ -#warning BLKFLSBUF not defined -#endif /* __GNUC__ */ +#elif defined(__linux__) +#warning BLKFLSBUF not defined#endif #ifdef FDFLUSH ioctl (fd,FDFLUSH ,0 );/* In case this is a floppy */ -#else -#ifdef __GNUC__ -#warning FDFLUSH not defined -#endif /* __GNUC__ */ +#elif defined(__linux__) +#warning FDFLUSH not defined#endif }return 0 ;
lib/ext2fs/getsize.c +1 -1
@@ -235,7 +235,7 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,#endif /* HAVE_SYS_DISKLABEL_H */ { -#ifdef HAVE_FSTAT64 +#if defined(HAVE_FSTAT64 ) && !defined(__OSX__)struct stat64 st;if (fstat64 (fd, &st) ==0 ) #else
Signature · 1 line
1.7.3.4
Ted Ts'o
AppliedQuoted 8 lines · Andreas Dilger
The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not really have anything to do with
__GNUC__(which is also used on OS/X and Solaris). Only print these warnings on Linux systems.
statfs64()is deprecated on OSX and generates a deliberate warning. Fix some other warnings that show up on OSX builds.Signed-off-by Andreas Dilger <[email protected]>
Applied to the next tree, thanks.
- Ted