From: Ruediger Meier Date: Thu, 11 Feb 2016 01:58:03 +0000 (+0100) Subject: lib: fix unused parameters and variables X-Git-Tag: v2.28-rc1~108^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b9cf26affe26b454f293e1a59049eed586be450;p=thirdparty%2Futil-linux.git lib: fix unused parameters and variables Signed-off-by: Ruediger Meier --- diff --git a/lib/at.c b/lib/at.c index 26f5ab95fa..f7074bb74d 100644 --- 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]; diff --git a/lib/blkdev.c b/lib/blkdev.c index a57b3672bf..f6df92d4f2 100644 --- a/lib/blkdev.c +++ b/lib/blkdev.c @@ -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, §or_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 diff --git a/lib/ismounted.c b/lib/ismounted.c index 135ac29d6c..90952905d0 100644 --- a/lib/ismounted.c +++ b/lib/ismounted.c @@ -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;