diff options
-rw-r--r-- | disk-utils/fsck.c | 24 | ||||
-rw-r--r-- | lib/at.c | 13 | ||||
-rw-r--r-- | lib/blkdev.c | 33 | ||||
-rw-r--r-- | lib/exec_shell.c | 8 | ||||
-rw-r--r-- | lib/ismounted.c | 24 | ||||
-rw-r--r-- | lib/pager.c | 1 | ||||
-rw-r--r-- | lib/path.c | 4 | ||||
-rw-r--r-- | lib/strutils.c | 2 | ||||
-rw-r--r-- | lib/sysfs.c | 3 | ||||
-rw-r--r-- | lib/timeutils.c | 2 | ||||
-rw-r--r-- | libuuid/src/gen_uuid.c | 4 | ||||
-rw-r--r-- | libuuid/src/uuid_time.c | 2 | ||||
-rw-r--r-- | sys-utils/ipcutils.h | 10 | ||||
-rw-r--r-- | term-utils/script.c | 3 |
14 files changed, 78 insertions, 55 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index 5be2b44d7..b4630c541 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -591,26 +591,26 @@ static void print_stats(struct fsck_instance *inst) if (report_stats_file) fprintf(report_stats_file, "%s %d %ld " - "%ld.%06ld %d.%06d %d.%06d\n", + "%ld.%06ld %ld.%06ld %ld.%06ld\n", fs_get_device(inst->fs), inst->exit_status, inst->rusage.ru_maxrss, - delta.tv_sec, delta.tv_usec, - (int)inst->rusage.ru_utime.tv_sec, - (int)inst->rusage.ru_utime.tv_usec, - (int)inst->rusage.ru_stime.tv_sec, - (int)inst->rusage.ru_stime.tv_usec); + (long)delta.tv_sec, (long)delta.tv_usec, + (long)inst->rusage.ru_utime.tv_sec, + (long)inst->rusage.ru_utime.tv_usec, + (long)inst->rusage.ru_stime.tv_sec, + (long)inst->rusage.ru_stime.tv_usec); else fprintf(stdout, "%s: status %d, rss %ld, " - "real %ld.%06ld, user %d.%06d, sys %d.%06d\n", + "real %ld.%06ld, user %ld.%06ld, sys %ld.%06ld\n", fs_get_device(inst->fs), inst->exit_status, inst->rusage.ru_maxrss, - delta.tv_sec, delta.tv_usec, - (int)inst->rusage.ru_utime.tv_sec, - (int)inst->rusage.ru_utime.tv_usec, - (int)inst->rusage.ru_stime.tv_sec, - (int)inst->rusage.ru_stime.tv_usec); + (long)delta.tv_sec, (long)delta.tv_usec, + (long)inst->rusage.ru_utime.tv_sec, + (long)inst->rusage.ru_utime.tv_usec, + (long)inst->rusage.ru_stime.tv_sec, + (long)inst->rusage.ru_stime.tv_usec); } /* @@ -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]; @@ -128,7 +129,7 @@ int main(int argc, char *argv[]) printf("%32s ", d->d_name); if (fstat_at(dirfd(dir), dirname, d->d_name, &st, 0) == 0) - printf("%16jd bytes ", st.st_size); + printf("%16zd bytes ", st.st_size); else printf("%16s bytes ", "???"); diff --git a/lib/blkdev.c b/lib/blkdev.c index a57b3672b..f6df92d4f 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/exec_shell.c b/lib/exec_shell.c index 2b263644d..a7374bd33 100644 --- a/lib/exec_shell.c +++ b/lib/exec_shell.c @@ -20,6 +20,7 @@ #include <string.h> #include <unistd.h> #include <sys/types.h> +#include <libgen.h> #include "nls.h" #include "c.h" @@ -31,12 +32,15 @@ void exec_shell(void) { - const char *shell = getenv("SHELL"), *shell_basename; + const char *shell = getenv("SHELL"); + char *shellc = xstrdup(shell); + const char *shell_basename; char *arg0; + if (!shell) shell = DEFAULT_SHELL; - shell_basename = basename(shell); + shell_basename = basename(shellc); arg0 = xmalloc(strlen(shell_basename) + 2); arg0[0] = '-'; strcpy(arg0 + 1, shell_basename); diff --git a/lib/ismounted.c b/lib/ismounted.c index 135ac29d6..90952905d 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; diff --git a/lib/pager.c b/lib/pager.c index 9e09cd52b..330659eda 100644 --- a/lib/pager.c +++ b/lib/pager.c @@ -12,6 +12,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#include <signal.h> #include "c.h" #include "xalloc.h" diff --git a/lib/path.c b/lib/path.c index 316af471b..1a623bc6d 100644 --- a/lib/path.c +++ b/lib/path.c @@ -244,8 +244,6 @@ path_read_cpulist(int maxcpus, const char *path, ...) return set; } -#endif /* HAVE_CPU_SET_T */ - void path_set_prefix(const char *prefix) { @@ -253,3 +251,5 @@ path_set_prefix(const char *prefix) strncpy(pathbuf, prefix, sizeof(pathbuf)); pathbuf[sizeof(pathbuf) - 1] = '\0'; } + +#endif /* HAVE_CPU_SET_T */ diff --git a/lib/strutils.c b/lib/strutils.c index 30dc090b4..ac59de8ee 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -519,7 +519,7 @@ char *size_to_human_string(int options, uint64_t bytes) if (!dp || !*dp) dp = "."; - snprintf(buf, sizeof(buf), "%d%s%jd%s", dec, dp, frac, suffix); + snprintf(buf, sizeof(buf), "%d%s%" PRIu64 "%s", dec, dp, frac, suffix); } else snprintf(buf, sizeof(buf), "%d%s", dec, suffix); diff --git a/lib/sysfs.c b/lib/sysfs.c index 51ec2bfe2..53aba3af9 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -5,6 +5,7 @@ * Written by Karel Zak <kzak@redhat.com> */ #include <ctype.h> +#include <libgen.h> #include "c.h" #include "at.h" @@ -461,7 +462,7 @@ int sysfs_write_u64(struct sysfs_cxt *cxt, const char *attr, uint64_t num) if (fd < 0) return -errno; - len = snprintf(buf, sizeof(buf), "%ju", num); + len = snprintf(buf, sizeof(buf), "%" PRIu64, num); if (len < 0 || (size_t) len + 1 > sizeof(buf)) rc = -errno; else diff --git a/lib/timeutils.c b/lib/timeutils.c index 4f2f61d51..854ef6915 100644 --- a/lib/timeutils.c +++ b/lib/timeutils.c @@ -21,8 +21,6 @@ #include <assert.h> #include <ctype.h> #include <string.h> -#include <sys/sysinfo.h> -#include <sys/time.h> #include <time.h> #include "c.h" diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index 4d6099720..f9a937cf5 100644 --- a/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c @@ -312,8 +312,8 @@ try_again: if (state_fd >= 0) { rewind(state_f); len = fprintf(state_f, - "clock: %04x tv: %016lu %08lu adj: %08d\n", - clock_seq, last.tv_sec, last.tv_usec, adjustment); + "clock: %04x tv: %016ld %08ld adj: %08d\n", + clock_seq, (long)last.tv_sec, (long)last.tv_usec, adjustment); fflush(state_f); if (ftruncate(state_fd, len) < 0) { fprintf(state_f, " \n"); diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c index f25f5c90f..6991ecd53 100644 --- a/libuuid/src/uuid_time.c +++ b/libuuid/src/uuid_time.c @@ -163,7 +163,7 @@ main(int argc, char **argv) printf("Warning: not a time-based UUID, so UUID time " "decoding will likely not work!\n"); } - printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec, + printf("UUID time is: (%ld, %ld): %s\n", (long)tv.tv_sec, (long)tv.tv_usec, ctime(&time_reg)); return 0; diff --git a/sys-utils/ipcutils.h b/sys-utils/ipcutils.h index 26fbbcf4d..444065a83 100644 --- a/sys-utils/ipcutils.h +++ b/sys-utils/ipcutils.h @@ -35,11 +35,11 @@ # define SHM_INFO 14 struct shm_info { int used_ids; - ulong shm_tot; /* total allocated shm */ - ulong shm_rss; /* total resident shm */ - ulong shm_swp; /* total swapped shm */ - ulong swap_attempts; - ulong swap_successes; + unsigned long shm_tot; /* total allocated shm */ + unsigned long shm_rss; /* total resident shm */ + unsigned long shm_swp; /* total swapped shm */ + unsigned long swap_attempts; + unsigned long swap_successes; }; #endif diff --git a/term-utils/script.c b/term-utils/script.c index fcb583584..23ca89cdc 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -249,7 +249,8 @@ static void write_output(struct script_control *ctl, char *obuf, gettime_monotonic(&now); timersub(&now, &ctl->oldtime, &delta); - fprintf(ctl->timingfp, "%ld.%06ld %zd\n", delta.tv_sec, delta.tv_usec, bytes); + fprintf(ctl->timingfp, "%ld.%06ld %zd\n", + (long)delta.tv_sec, (long)delta.tv_usec, bytes); if (ctl->flush) fflush(ctl->timingfp); ctl->oldtime = now; |