]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
build: fix compile warnings on OSX
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 24 Feb 2012 07:48:57 +0000 (00:48 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 27 Feb 2012 06:28:23 +0000 (01:28 -0500)
Clean up some compile warnings related to fstat64(), which is
verbosely deprecated on OSX.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/blkid/getsize.c
lib/ext2fs/getsize.c
resize/main.c

index 77e68cf770f4bedb727bc28a5970b471c7b8ae82..f670e1b1471f4abab623844407044579681fcce7 100644 (file)
@@ -77,7 +77,7 @@ blkid_loff_t blkid_get_dev_size(int fd)
 {
        int valid_blkgetsize64 = 1;
 #ifdef __linux__
-       struct          utsname ut;
+       struct          utsname ut;
 #endif
        unsigned long long size64;
        unsigned long size;
@@ -116,7 +116,7 @@ blkid_loff_t blkid_get_dev_size(int fd)
                        return 0; /* EFBIG */
                return size64;
        }
-#endif
+#endif /* BLKGETSIZE64 */
 
 #ifdef BLKGETSIZE
        if (ioctl(fd, BLKGETSIZE, &size) >= 0)
@@ -143,8 +143,9 @@ blkid_loff_t blkid_get_dev_size(int fd)
         * Note that FreeBSD >= 4.0 has disk devices as unbuffered (raw,
         * character) devices, so we need to check for S_ISCHR, too.
         */
-       if ((fstat(fd, &st) >= 0) && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
+       if (fstat(fd, &st) >= 0 && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
                part = st.st_rdev & 7;
+
        if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
                pp = &lab.d_partitions[part];
                if (pp->p_size)
@@ -152,7 +153,7 @@ blkid_loff_t blkid_get_dev_size(int fd)
        }
 #endif /* HAVE_SYS_DISKLABEL_H */
        {
-#ifdef HAVE_FSTAT64
+#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
                struct stat64   st;
                if (fstat64(fd, &st) == 0)
 #else
@@ -163,7 +164,6 @@ blkid_loff_t blkid_get_dev_size(int fd)
                                return st.st_size;
        }
 
-
        /*
         * OK, we couldn't figure it out by using a specialized ioctl,
         * which is generally the best way.  So do binary search to
@@ -172,8 +172,7 @@ blkid_loff_t blkid_get_dev_size(int fd)
        low = 0;
        for (high = 1024; valid_offset(fd, high); high *= 2)
                low = high;
-       while (low < high - 1)
-       {
+       while (low < high - 1) {
                const blkid_loff_t mid = (low + high) / 2;
 
                if (valid_offset(fd, mid))
index 1e0ed16fc6df51cb26784929fc862cd844e43402..0a7053e3bcc6c9aabc9de0dd97bdef4dfb3358b0 100644 (file)
@@ -183,7 +183,7 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
                *retblocks = size64 / blocksize;
                goto out;
        }
-#endif
+#endif /* BLKGETSIZE64 */
 
 #ifdef BLKGETSIZE
        if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
index 1ab0e048d1b88487914da0a0b627ec5a3e7f518f..ffefe0193fd9f2f38b3e7676306e8724f520a684 100644 (file)
@@ -165,11 +165,7 @@ int main (int argc, char ** argv)
        io_manager      io_ptr;
        char            *new_size_str = 0;
        int             use_stride = -1;
-#ifdef HAVE_FSTAT64
-       struct stat64   st_buf;
-#else
-       struct stat     st_buf;
-#endif
+       ext2fs_struct_stat st_buf;
        __s64           new_file_size;
        unsigned int    sys_page_size = 4096;
        long            sysval;
@@ -265,11 +261,7 @@ int main (int argc, char ** argv)
                exit(1);
        }
 
-#ifdef HAVE_FSTAT64
-       ret = fstat64(fd, &st_buf);
-#else
-       ret = fstat(fd, &st_buf);
-#endif
+       ret = ext2fs_fstat(fd, &st_buf);
        if (ret < 0) {
                com_err("open", errno,
                        _("while getting stat information for %s"),