]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
misc: fix compile warnings on OSX
authorAndreas Dilger <adilger@whamcloud.com>
Sat, 11 Jun 2011 15:50:01 +0000 (11:50 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 11 Jun 2011 15:50:01 +0000 (11:50 -0400)
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 <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/e2p/fgetflags.c
lib/e2p/fsetflags.c
lib/e2p/getflags.c
lib/e2p/setflags.c
lib/ext2fs/flushb.c
lib/ext2fs/getsize.c

index d66f8e188732cb01501965cf627d52e5cee0301f..ca3ea16638efa410c6317eb5f3196d7348da695f 100644 (file)
@@ -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;
 }
index 30437a20ba923256fd36d6f5fa3465ab657c9f1a..08dd114dc0b86822bebc69ae3d3499385ed569d1 100644 (file)
@@ -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;
 }
index a738fed3e8333e6fcc293149d69a97981b4af1e1..e8716848785ff30197d731202f9d5c2f8c5983b0 100644 (file)
@@ -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;
 }
index cc00b2039d1117c91b3ff8c7426c6f9d1279d87c..72cf4413732d2779671072667b1cc1733813b8ce 100644 (file)
@@ -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;
index 394bb074e6e2f60534a9201f100b53a917227c19..ee0093ad351df4d2e2dc94546ed3f040a428cff9 100644 (file)
@@ -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;
index 5ef0081bf64c0fc93f925f8a5aee07aae825af3f..0c91b5b8de08bca66dd6b378da7b4f7eb91aaddf 100644 (file)
@@ -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