]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: fix unused parameters and variables
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 11 Feb 2016 01:58:03 +0000 (02:58 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 11 Feb 2016 12:40:22 +0000 (13:40 +0100)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
lib/at.c
lib/blkdev.c
lib/ismounted.c

index 26f5ab95fa3583eaef8df277b393766885ac64a0..f7074bb74d2f7f352f03dc3b08206fe5465c3ea4 100644 (file)
--- a/lib/at.c
+++ b/lib/at.c
@@ -22,8 +22,8 @@ int fstat_at(int dir, const char *dirname __attribute__ ((__unused__)),
                        nofollow ? AT_SYMLINK_NOFOLLOW : 0);
 }
 #else
-int fstat_at(int dir, const char *dirname, const char *filename,
-                               struct stat *st, int nofollow)
+int fstat_at(int dir __attribute__ ((__unused__)), const char *dirname,
+            const char *filename, struct stat *st, int nofollow)
 {
 
        if (*filename != '/') {
@@ -48,7 +48,8 @@ int open_at(int dir, const char *dirname __attribute__ ((__unused__)),
        return openat(dir, filename, flags);
 }
 #else
-int open_at(int dir, const char *dirname, const char *filename, int flags)
+int open_at(int dir __attribute__((__unused__)), const char *dirname,
+           const char *filename, int flags)
 {
        if (*filename != '/') {
                char path[PATH_MAX];
@@ -82,8 +83,8 @@ ssize_t readlink_at(int dir, const char *dirname __attribute__ ((__unused__)),
        return readlinkat(dir, pathname, buf, bufsiz);
 }
 #else
-ssize_t readlink_at(int dir, const char *dirname, const char *pathname,
-                   char *buf, size_t bufsiz)
+ssize_t readlink_at(int dir __attribute__((__unused__)), const char *dirname,
+                   const char *pathname, char *buf, size_t bufsiz)
 {
        if (*pathname != '/') {
                char path[PATH_MAX];
index a57b3672bf930c25ceecf1b57350a69a8b047e87..f6df92d4f208750340f5199cd4fc7241bf50e1b2 100644 (file)
@@ -202,17 +202,20 @@ blkdev_get_sectors(int fd, unsigned long long *sectors)
  * This is the smallest unit the storage device can
  * address. It is typically 512 bytes.
  */
+#ifdef BLKSSZGET
 int blkdev_get_sector_size(int fd, int *sector_size)
 {
-#ifdef BLKSSZGET
        if (ioctl(fd, BLKSSZGET, sector_size) >= 0)
                return 0;
        return -1;
+}
 #else
+int blkdev_get_sector_size(int fd __attribute__((__unused__)), int *sector_size)
+{
        *sector_size = DEFAULT_SECTOR_SIZE;
        return 0;
-#endif
 }
+#endif
 
 /*
  * Get physical block device size. The BLKPBSZGET is supported since Linux
@@ -228,24 +231,27 @@ int blkdev_get_sector_size(int fd, int *sector_size)
  *             physec = DEFAULT_SECTOR_SIZE;
  * }
  */
+#ifdef BLKPBSZGET
 int blkdev_get_physector_size(int fd, int *sector_size)
 {
-#ifdef BLKPBSZGET
        if (ioctl(fd, BLKPBSZGET, &sector_size) >= 0)
                return 0;
        return -1;
+}
 #else
+int blkdev_get_physector_size(int fd __attribute__((__unused__)), int *sector_size)
+{
        *sector_size = DEFAULT_SECTOR_SIZE;
        return 0;
-#endif
 }
+#endif
 
 /*
  * Return the alignment status of a device
  */
+#ifdef BLKALIGNOFF
 int blkdev_is_misaligned(int fd)
 {
-#ifdef BLKALIGNOFF
        int aligned;
 
        if (ioctl(fd, BLKALIGNOFF, &aligned) < 0)
@@ -255,10 +261,13 @@ int blkdev_is_misaligned(int fd)
         * sizes and alignments exist for stacked devices
         */
        return aligned != 0 ? 1 : 0;
+}
 #else
+int blkdev_is_misaligned(int fd __attribute__((__unused__)))
+{
        return 0;
-#endif
 }
+#endif
 
 int open_blkdev_or_file(const struct stat *st, const char *name, const int oflag)
 {
@@ -278,19 +287,22 @@ int open_blkdev_or_file(const struct stat *st, const char *name, const int oflag
        return fd;
 }
 
+#ifdef CDROM_GET_CAPABILITY
 int blkdev_is_cdrom(int fd)
 {
-#ifdef CDROM_GET_CAPABILITY
        int ret;
 
        if ((ret = ioctl(fd, CDROM_GET_CAPABILITY, NULL)) < 0)
                return 0;
        else
                return ret;
+}
 #else
+int blkdev_is_cdrom(int fd __attribute__((__unused__)))
+{
        return 0;
-#endif
 }
+#endif
 
 /*
  * Get kernel's interpretation of the device's geometry.
@@ -300,9 +312,9 @@ int blkdev_is_cdrom(int fd)
  *
  * Note that this is deprecated in favor of LBA addressing.
  */
+#ifdef HDIO_GETGEO
 int blkdev_get_geometry(int fd, unsigned int *h, unsigned int *s)
 {
-#ifdef HDIO_GETGEO
        struct hd_geometry geometry;
 
        if (ioctl(fd, HDIO_GETGEO, &geometry) == 0) {
@@ -311,6 +323,9 @@ int blkdev_get_geometry(int fd, unsigned int *h, unsigned int *s)
                return 0;
        }
 #else
+int blkdev_get_geometry(int fd __attribute__((__unused__)),
+               unsigned int *h, unsigned int *s)
+{
        *h = 0;
        *s = 0;
 #endif
index 135ac29d6cf598ab834fc533f5720568cf623177..90952905d03bd15fa0366793437e51e22f45f183 100644 (file)
@@ -311,9 +311,7 @@ leave:
 int check_mount_point(const char *device, int *mount_flags,
                                  char *mtpt, int mtlen)
 {
-       struct stat     st_buf;
        int     retval = 0;
-       int             fd;
 
        if (is_swap_device(device)) {
                *mount_flags = MF_MOUNTED | MF_SWAP;
@@ -337,15 +335,19 @@ int check_mount_point(const char *device, int *mount_flags,
                return retval;
 
 #ifdef __linux__ /* This only works on Linux 2.6+ systems */
-       if ((stat(device, &st_buf) != 0) ||
-           !S_ISBLK(st_buf.st_mode))
-               return 0;
-       fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC);
-       if (fd < 0) {
-               if (errno == EBUSY)
-                       *mount_flags |= MF_BUSY;
-       } else
-               close(fd);
+       {
+               struct stat st_buf;
+               int fd;
+               if ((stat(device, &st_buf) != 0) ||
+                   !S_ISBLK(st_buf.st_mode))
+                       return 0;
+               fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC);
+               if (fd < 0) {
+                       if (errno == EBUSY)
+                               *mount_flags |= MF_BUSY;
+               } else
+                       close(fd);
+       }
 #endif
 
        return 0;