summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl>2014-05-15 18:42:28 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-05-15 19:34:56 -0400
commitf8e5fbd9c8b209e556c017bfb420a86e8181dfa7 (patch)
treee6488b61b93e5e69c161475a6c62f2bfbd146f00 /src
parentdb992ba3a71f320faab8f90de77ef081305917bb (diff)
Remove unnecessary casts in printfs
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-device-private.c2
-rw-r--r--src/libudev/libudev-device.c2
-rw-r--r--src/libudev/libudev-hwdb.c2
-rw-r--r--src/libudev/log.c4
-rw-r--r--src/libudev/time-util.c8
-rw-r--r--src/libudev/time-util.h2
-rw-r--r--src/libudev/util.h48
-rw-r--r--src/udev/udev-builtin-blkid.c4
-rw-r--r--src/udev/udevadm-monitor.c4
9 files changed, 57 insertions, 19 deletions
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index cb4947ff3b..637d064819 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -154,7 +154,7 @@ int udev_device_update_db(struct udev_device *udev_device)
}
if (udev_device_get_usec_initialized(udev_device) > 0)
- fprintf(f, "I:%llu\n", (unsigned long long)udev_device_get_usec_initialized(udev_device));
+ fprintf(f, "I:"USEC_FMT"\n", udev_device_get_usec_initialized(udev_device));
udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) {
if (!udev_list_entry_get_num(list_entry))
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 9f80f56d42..3a64f24fb8 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -1341,7 +1341,7 @@ void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t us
char num[32];
udev_device->usec_initialized = usec_initialized;
- snprintf(num, sizeof(num), "%llu", (unsigned long long)usec_initialized);
+ snprintf(num, sizeof(num), USEC_FMT, usec_initialized);
udev_device_add_property(udev_device, "USEC_INITIALIZED", num);
}
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index e9fb1c485b..7af230c40e 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -305,7 +305,7 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
udev_dbg(udev, "=== trie on-disk ===\n");
udev_dbg(udev, "tool version: %"PRIu64, le64toh(hwdb->head->tool_version));
- udev_dbg(udev, "file size: %8llu bytes\n", (unsigned long long) hwdb->st.st_size);
+ udev_dbg(udev, "file size: %8zu bytes\n", hwdb->st.st_size);
udev_dbg(udev, "header size %8"PRIu64" bytes\n", le64toh(hwdb->head->header_size));
udev_dbg(udev, "strings %8"PRIu64" bytes\n", le64toh(hwdb->head->strings_len));
udev_dbg(udev, "nodes %8"PRIu64" bytes\n", le64toh(hwdb->head->nodes_len));
diff --git a/src/libudev/log.c b/src/libudev/log.c
index a4e1bcef70..cd496cf6c5 100644
--- a/src/libudev/log.c
+++ b/src/libudev/log.c
@@ -327,7 +327,7 @@ static int write_to_syslog(
if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
return -EINVAL;
- snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
+ snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", getpid());
char_array_0(header_pid);
IOVEC_SET_STRING(iovec[0], header_priority);
@@ -375,7 +375,7 @@ static int write_to_kmsg(
snprintf(header_priority, sizeof(header_priority), "<%i>", level);
char_array_0(header_priority);
- snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
+ snprintf(header_pid, sizeof(header_pid), "["PID_FMT"]: ", getpid());
char_array_0(header_pid);
IOVEC_SET_STRING(iovec[0], header_priority);
diff --git a/src/libudev/time-util.c b/src/libudev/time-util.c
index f6c24e3f9b..d7682773c4 100644
--- a/src/libudev/time-util.c
+++ b/src/libudev/time-util.c
@@ -119,9 +119,9 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
if (j > 0) {
k = snprintf(p, l,
- "%s%llu.%0*llu%s",
+ "%s"USEC_FMT".%0*llu%s",
p > buf ? " " : "",
- (unsigned long long) a,
+ a,
j,
(unsigned long long) b,
table[i].suffix);
@@ -134,9 +134,9 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
/* No? Then let's show it normally */
if (!done) {
k = snprintf(p, l,
- "%s%llu%s",
+ "%s"USEC_FMT"%s",
p > buf ? " " : "",
- (unsigned long long) a,
+ a,
table[i].suffix);
t = b;
diff --git a/src/libudev/time-util.h b/src/libudev/time-util.h
index 0f7f6964ee..458994d40f 100644
--- a/src/libudev/time-util.h
+++ b/src/libudev/time-util.h
@@ -24,6 +24,8 @@
typedef uint64_t usec_t;
typedef uint64_t nsec_t;
+#define USEC_FMT "%" PRIu64
+
typedef struct dual_timestamp {
usec_t realtime;
usec_t monotonic;
diff --git a/src/libudev/util.h b/src/libudev/util.h
index 4e0f310889..a950f2658f 100644
--- a/src/libudev/util.h
+++ b/src/libudev/util.h
@@ -32,15 +32,51 @@
#include <unistd.h>
#include <sys/socket.h>
+#include "config.h"
+
+#if SIZEOF_PID_T == 4
+# define PID_FMT "%" PRIu32
+#elif SIZEOF_PID_T == 2
+# define PID_FMT "%" PRIu16
+#else
+# error Unknown pid_t size
+#endif
+
+#if SIZEOF_UID_T == 4
+# define UID_FMT "%" PRIu32
+#elif SIZEOF_UID_T == 2
+# define UID_FMT "%" PRIu16
+#else
+# error Unknown uid_t size
+#endif
+
+#if SIZEOF_GID_T == 4
+# define GID_FMT "%" PRIu32
+#elif SIZEOF_GID_T == 2
+# define GID_FMT "%" PRIu16
+#else
+# error Unknown gid_t size
+#endif
+
+#if SIZEOF_TIME_T == 8
+# define PRI_TIME PRIu64
+#elif SIZEOF_GID_T == 4
+# define PRI_TIME PRIu32
+#else
+# error Unknown time_t size
+#endif
+
+#if SIZEOF_RLIM_T == 8
+# define RLIM_FMT "%" PRIu64
+#elif SIZEOF_RLIM_T == 4
+# define RLIM_FMT "%" PRIu32
+#else
+# error Unknown rlim_t size
+#endif
+
#include "macro.h"
#include "missing.h"
-union dirent_storage {
- struct dirent de;
- uint8_t storage[offsetof(struct dirent, d_name) +
- ((NAME_MAX + 1 + sizeof(long)) & ~(sizeof(long) - 1))];
-};
-
/* What is interpreted as whitespace? */
#define WHITESPACE " \t\n\r"
#define NEWLINE "\n\r"
diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c
index 24adb71b17..91ce794c99 100644
--- a/src/udev/udev-builtin-blkid.c
+++ b/src/udev/udev-builtin-blkid.c
@@ -190,9 +190,9 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t
if (err < 0)
goto out;
- log_debug("probe %s %sraid offset=%llu",
+ log_debug("probe %s %sraid offset=%"PRIu64,
udev_device_get_devnode(dev),
- noraid ? "no" : "", (unsigned long long) offset);
+ noraid ? "no" : "", offset);
err = probe_superblocks(pr);
if (err < 0)
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index b2f7f6ba4c..a54aa82c73 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -48,9 +48,9 @@ static void print_device(struct udev_device *device, const char *source, int pro
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- printf("%-6s[%llu.%06u] %-8s %s (%s)\n",
+ printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
source,
- (unsigned long long) ts.tv_sec, (unsigned int) ts.tv_nsec/1000,
+ ts.tv_sec, ts.tv_nsec/1000,
udev_device_get_action(device),
udev_device_get_devpath(device),
udev_device_get_subsystem(device));