chiark / gitweb /
Assorted format fixes
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 21 Jan 2015 03:22:15 +0000 (22:22 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Jan 2015 06:14:52 +0000 (01:14 -0500)
Types used for pids and uids in various interfaces are unpredictable.
Too bad.

37 files changed:
src/bus-proxyd/bus-xml-policy.c
src/core/automount.c
src/core/dbus-manager.c
src/core/manager.c
src/hwdb/hwdb.c
src/journal-remote/journal-remote-parse.c
src/journal-remote/journal-remote.c
src/journal-remote/journal-upload.c
src/journal/compress.c
src/journal/journal-send.c
src/journal/journald-audit.c
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd/sd-bus/bus-dump.c
src/libsystemd/sd-hwdb/sd-hwdb.c
src/libsystemd/sd-rtnl/rtnl-message.c
src/libudev/libudev-device.c
src/libudev/libudev-monitor.c
src/login/logind-seat.c
src/login/pam_systemd.c
src/login/test-inhibit.c
src/shared/install-printf.c
src/shared/log.c
src/shared/sleep-config.c
src/shared/util.h
src/systemctl/systemctl.c
src/test/test-strxcpyx.c
src/test/test-util.c
src/udev/udev-builtin-blkid.c
src/udev/udev-builtin-input_id.c
src/udev/udev-builtin-keyboard.c
src/udev/udev-builtin-net_id.c
src/udev/udev-ctrl.c
src/udev/udev-event.c
src/udev/udev-node.c
src/udev/udevadm-hwdb.c
src/udev/udevadm-info.c
src/udev/udevd.c

index f7f3388..f6ac0c0 100644 (file)
@@ -1129,7 +1129,7 @@ static void dump_items(PolicyItem *items, const char *prefix) {
 
                         user = uid_to_name(i->uid);
 
-                        printf("%sUser: %s (%d)\n",
+                        printf("%sUser: %s ("UID_FMT")\n",
                                prefix, strna(user), i->uid);
                 }
 
@@ -1138,7 +1138,7 @@ static void dump_items(PolicyItem *items, const char *prefix) {
 
                         group = gid_to_name(i->gid);
 
-                        printf("%sGroup: %s (%d)\n",
+                        printf("%sGroup: %s ("GID_FMT")\n",
                                prefix, strna(group), i->gid);
                 }
                 printf("%s-\n", prefix);
index 90beb4d..51f7373 100644 (file)
@@ -758,7 +758,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
 
                         get_process_comm(packet.v5_packet.pid, &p);
                         log_unit_info(UNIT(a)->id,
-                                       "Got automount request for %s, triggered by "PID_FMT" (%s)",
+                                       "Got automount request for %s, triggered by %"PRIu32" (%s)",
                                        a->where, packet.v5_packet.pid, strna(p));
                 } else
                         log_unit_debug(UNIT(a)->id, "Got direct mount request on %s", a->where);
index 6181ba8..8ba665d 100644 (file)
@@ -407,7 +407,7 @@ static int method_get_unit_by_pid(sd_bus *bus, sd_bus_message *message, void *us
 
         u = manager_get_unit_by_pid(m, pid);
         if (!u)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_UNIT_FOR_PID, "PID %u does not belong to any loaded unit.", pid);
+                return sd_bus_error_setf(error, BUS_ERROR_NO_UNIT_FOR_PID, "PID "PID_FMT" does not belong to any loaded unit.", pid);
 
         r = mac_selinux_unit_access_check(u, message, "status", error);
         if (r < 0)
index 64ff464..947d431 100644 (file)
@@ -2215,7 +2215,7 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) {
 
         m->n_reloading ++;
 
-        fprintf(f, "current-job-id=%i\n", m->current_job_id);
+        fprintf(f, "current-job-id=%"PRIu32"\n", m->current_job_id);
         fprintf(f, "taint-usr=%s\n", yes_no(m->taint_usr));
         fprintf(f, "n-installed-jobs=%u\n", m->n_installed_jobs);
         fprintf(f, "n-failed-jobs=%u\n", m->n_failed_jobs);
index 4fce30d..ff12208 100644 (file)
@@ -420,7 +420,7 @@ static int trie_store(struct trie *trie, const char *filename) {
         }
 
         log_debug("=== trie on-disk ===");
-        log_debug("size:             %8"PRIu64" bytes", size);
+        log_debug("size:             %8"PRIi64" bytes", size);
         log_debug("header:           %8zu bytes", sizeof(struct trie_header_f));
         log_debug("nodes:            %8"PRIu64" bytes (%8"PRIu64")",
                   t.nodes_count * sizeof(struct trie_node_f), t.nodes_count);
index 76407f7..d9dea8d 100644 (file)
@@ -37,7 +37,7 @@ void source_free(RemoteSource *source) {
         free(source->buf);
         iovw_free_contents(&source->iovw);
 
-        log_debug("Writer ref count %u", source->writer->n_ref);
+        log_debug("Writer ref count %i", source->writer->n_ref);
         writer_unref(source->writer);
 
         sd_event_source_unref(source->event);
@@ -125,8 +125,8 @@ static int get_line(RemoteSource *source, char **line, size_t *size) {
                          source->size - source->filled);
                 if (n < 0) {
                         if (errno != EAGAIN && errno != EWOULDBLOCK)
-                                log_error_errno(errno, "read(%d, ..., %zd): %m", source->fd,
-                                          source->size - source->filled);
+                                log_error_errno(errno, "read(%d, ..., %zu): %m", source->fd,
+                                                source->size - source->filled);
                         return -errno;
                 } else if (n == 0)
                         return 0;
@@ -186,8 +186,8 @@ static int fill_fixed_size(RemoteSource *source, void **data, size_t size) {
                          source->size - source->filled);
                 if (n < 0) {
                         if (errno != EAGAIN && errno != EWOULDBLOCK)
-                                log_error_errno(errno, "read(%d, ..., %zd): %m", source->fd,
-                                          source->size - source->filled);
+                                log_error_errno(errno, "read(%d, ..., %zu): %m", source->fd,
+                                                source->size - source->filled);
                         return -errno;
                 } else if (n == 0)
                         return 0;
index 5050616..244d83d 100644 (file)
@@ -1021,7 +1021,7 @@ static int dispatch_raw_source_event(sd_event_source *event,
                 if (remaining > 0)
                         log_warning("Premature EOF. %zu bytes lost.", remaining);
                 remove_source(s, source->fd);
-                log_info("%zd active sources remaining", s->active);
+                log_info("%zu active sources remaining", s->active);
                 return 0;
         } else if (r == -E2BIG) {
                 log_error("Entry too big, skipped");
index 50332ed..75bb434 100644 (file)
@@ -296,7 +296,7 @@ static size_t fd_input_callback(void *buf, size_t size, size_t nmemb, void *user
                 return 0;
 
         r = read(u->input, buf, size * nmemb);
-        log_debug("%s: allowed %zu, read %zu", __func__, size*nmemb, r);
+        log_debug("%s: allowed %zu, read %zd", __func__, size*nmemb, r);
 
         if (r > 0)
                 return r;
@@ -505,15 +505,15 @@ static int perform_upload(Uploader *u) {
         }
 
         if (status >= 300) {
-                log_error("Upload to %s failed with code %lu: %s",
+                log_error("Upload to %s failed with code %ld: %s",
                           u->url, status, strna(u->answer));
                 return -EIO;
         } else if (status < 200) {
-                log_error("Upload to %s finished with unexpected code %lu: %s",
+                log_error("Upload to %s finished with unexpected code %ld: %s",
                           u->url, status, strna(u->answer));
                 return -EIO;
         } else
-                log_debug("Upload finished successfully with code %lu: %s",
+                log_debug("Upload finished successfully with code %ld: %s",
                           status, strna(u->answer));
 
         free(u->last_cursor);
index 9440fcd..6923753 100644 (file)
@@ -356,7 +356,7 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 
         ret = lzma_easy_encoder(&s, LZMA_PRESET_DEFAULT, LZMA_CHECK_CRC64);
         if (ret != LZMA_OK) {
-                log_error("Failed to initialize XZ encoder: code %d", ret);
+                log_error("Failed to initialize XZ encoder: code %u", ret);
                 return -EINVAL;
         }
 
@@ -391,7 +391,7 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 
                 ret = lzma_code(&s, action);
                 if (ret != LZMA_OK && ret != LZMA_STREAM_END) {
-                        log_error("Compression failed: code %d", ret);
+                        log_error("Compression failed: code %u", ret);
                         return -EBADMSG;
                 }
 
@@ -512,7 +512,7 @@ int decompress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 
         ret = lzma_stream_decoder(&s, UINT64_MAX, 0);
         if (ret != LZMA_OK) {
-                log_error("Failed to initialize XZ decoder: code %d", ret);
+                log_error("Failed to initialize XZ decoder: code %u", ret);
                 return -ENOMEM;
         }
 
@@ -538,7 +538,7 @@ int decompress_stream_xz(int fdf, int fdt, off_t max_bytes) {
 
                 ret = lzma_code(&s, action);
                 if (ret != LZMA_OK && ret != LZMA_STREAM_END) {
-                        log_error("Decompression failed: code %d", ret);
+                        log_error("Decompression failed: code %u", ret);
                         return -EBADMSG;
                 }
 
index 56a96c5..65fefd2 100644 (file)
@@ -384,7 +384,7 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
                                 memcpy(buffer + 8 + k - 2, ": ", 2);
                         }
 
-                        snprintf(error, sizeof(error), "ERRNO=%u", _saved_errno_);
+                        snprintf(error, sizeof(error), "ERRNO=%i", _saved_errno_);
                         char_array_0(error);
 
                         IOVEC_SET_STRING(iov[skip+0], "PRIORITY=3");
index 9d21738..c2f1545 100644 (file)
@@ -360,7 +360,7 @@ static void process_audit_string(Server *s, int type, const char *data, size_t s
         if (!p)
                 return;
 
-        if (sscanf(p, "(%" PRIi64 ".%" PRIi64 ":%" PRIi64 "):%n",
+        if (sscanf(p, "(%" PRIu64 ".%" PRIu64 ":%" PRIu64 "):%n",
                    &seconds,
                    &msec,
                    &id,
index dbecad4..65e888a 100644 (file)
@@ -1613,7 +1613,7 @@ int sd_dhcp_client_start(sd_dhcp_client *client) {
 
         r = client_start(client);
         if (r >= 0)
-                log_dhcp_client(client, "STARTED on ifindex %u", client->index);
+                log_dhcp_client(client, "STARTED on ifindex %i", client->index);
 
         return r;
 }
index afdf52f..8fba7ac 100644 (file)
@@ -69,7 +69,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
 
         if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
                 fprintf(f,
-                        "%s%s%s Type=%s%s%s  Endian=%c  Flags=%u  Version=%u  Priority=%lli",
+                        "%s%s%s Type=%s%s%s  Endian=%c  Flags=%u  Version=%u  Priority=%"PRIi64,
                         m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
                         m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
                         m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_highlight_off(),
@@ -77,7 +77,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
                         m->header->endian,
                         m->header->flags,
                         m->header->version,
-                        (long long) m->priority);
+                        m->priority);
 
                 /* Display synthetic message serial number in a more readable
                  * format than (uint32_t) -1 */
index a16807f..61c7b44 100644 (file)
@@ -324,7 +324,7 @@ _public_ int sd_hwdb_new(sd_hwdb **ret) {
 
         log_debug("=== trie on-disk ===");
         log_debug("tool version:          %"PRIu64, le64toh(hwdb->head->tool_version));
-        log_debug("file size:        %8"PRIu64" bytes", hwdb->st.st_size);
+        log_debug("file size:        %8"PRIi64" bytes", hwdb->st.st_size);
         log_debug("header size       %8"PRIu64" bytes", le64toh(hwdb->head->header_size));
         log_debug("strings           %8"PRIu64" bytes", le64toh(hwdb->head->strings_len));
         log_debug("nodes             %8"PRIu64" bytes", le64toh(hwdb->head->nodes_len));
index 4846133..1f44c34 100644 (file)
@@ -1366,7 +1366,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
                         if (ucred->pid == 0)
                                 auth = true;
                         else
-                                log_debug("rtnl: ignoring message from pid %u", ucred->pid);
+                                log_debug("rtnl: ignoring message from PID "PID_FMT, ucred->pid);
                 } else if (cmsg->cmsg_level == SOL_NETLINK &&
                            cmsg->cmsg_type == NETLINK_PKTINFO &&
                            cmsg->cmsg_len == CMSG_LEN(sizeof(struct nl_pktinfo))) {
index 825a0e1..a7446bf 100644 (file)
@@ -1686,7 +1686,7 @@ const char *udev_device_get_id_filename(struct udev_device *udev_device)
                                 udev_device->id_filename = NULL;
                 } else if (udev_device_get_ifindex(udev_device) > 0) {
                         /* use netdev ifindex -- n3 */
-                        if (asprintf(&udev_device->id_filename, "n%u", udev_device_get_ifindex(udev_device)) < 0)
+                        if (asprintf(&udev_device->id_filename, "n%i", udev_device_get_ifindex(udev_device)) < 0)
                                 udev_device->id_filename = NULL;
                 } else {
                         /*
index da2b634..4cfb2f6 100644 (file)
@@ -620,8 +620,8 @@ retry:
                 }
         } else if (snl.nl.nl_groups == UDEV_MONITOR_KERNEL) {
                 if (snl.nl.nl_pid > 0) {
-                        log_debug("multicast kernel netlink message from pid %d ignored",
-                             snl.nl.nl_pid);
+                        log_debug("multicast kernel netlink message from PID %"PRIu32" ignored",
+                                  snl.nl.nl_pid);
                         return NULL;
                 }
         }
@@ -634,7 +634,7 @@ retry:
 
         cred = (struct ucred *)CMSG_DATA(cmsg);
         if (cred->uid != 0) {
-                log_debug("sender uid=%d, message ignored", cred->uid);
+                log_debug("sender uid="UID_FMT", message ignored", cred->uid);
                 return NULL;
         }
 
index 8eb5e3e..197138c 100644 (file)
@@ -201,7 +201,7 @@ int seat_preallocate_vts(Seat *s) {
 
                 q = vt_allocate(i);
                 if (q < 0) {
-                        log_error_errno(q, "Failed to preallocate VT %i: %m", i);
+                        log_error_errno(q, "Failed to preallocate VT %u: %m", i);
                         r = q;
                 }
         }
index d5b29c8..d7a708f 100644 (file)
@@ -344,7 +344,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         }
 
         if (seat && !streq(seat, "seat0") && vtnr != 0) {
-                pam_syslog(handle, LOG_DEBUG, "Ignoring vtnr %d for %s which is not seat0", vtnr, seat);
+                pam_syslog(handle, LOG_DEBUG, "Ignoring vtnr %"PRIu32" for %s which is not seat0", vtnr, seat);
                 vtnr = 0;
         }
 
@@ -367,7 +367,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
 
         if (debug)
                 pam_syslog(handle, LOG_DEBUG, "Asking logind to create session: "
-                           "uid=%u pid=%u service=%s type=%s class=%s desktop=%s seat=%s vtnr=%u tty=%s display=%s remote=%s remote_user=%s remote_host=%s",
+                           "uid="UID_FMT" pid="PID_FMT" service=%s type=%s class=%s desktop=%s seat=%s vtnr=%"PRIu32" tty=%s display=%s remote=%s remote_user=%s remote_host=%s",
                            pw->pw_uid, getpid(),
                            strempty(service),
                            type, class, strempty(desktop),
index 5379ffc..274687d 100644 (file)
@@ -73,7 +73,7 @@ static void print_inhibitors(sd_bus *bus) {
         assert_se(r >= 0);
 
         while ((r = sd_bus_message_read(reply, "(ssssuu)", &what, &who, &why, &mode, &uid, &pid)) > 0) {
-                printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<"UID_FMT"> pid=<"PID_FMT">\n",
+                printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<%"PRIu32"> pid=<%"PRIu32">\n",
                        what, who, why, mode, uid, pid);
 
                 n++;
index 1ee1243..d853f17 100644 (file)
@@ -103,7 +103,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
                 if (r < 0)
                         return r;
 
-                if (asprintf(&printed, "%d", uid) < 0)
+                if (asprintf(&printed, UID_FMT, uid) < 0)
                         return -ENOMEM;
                 break;
         }}
index f8c16de..a870415 100644 (file)
@@ -330,7 +330,7 @@ static int write_to_console(
         highlight = LOG_PRI(level) <= LOG_ERR && show_color;
 
         if (show_location) {
-                snprintf(location, sizeof(location), "(%s:%u) ", file, line);
+                snprintf(location, sizeof(location), "(%s:%i) ", file, line);
                 char_array_0(location);
                 IOVEC_SET_STRING(iovec[n++], location);
         }
@@ -1050,7 +1050,7 @@ void log_received_signal(int level, const struct signalfd_siginfo *si) {
                 get_process_comm(si->ssi_pid, &p);
 
                 log_full(level,
-                         "Received SIG%s from PID "PID_FMT" (%s).",
+                         "Received SIG%s from PID %"PRIu32" (%s).",
                          signal_to_string(si->ssi_signo),
                          si->ssi_pid, strna(p));
         } else
index ae14c6b..1064fd5 100644 (file)
@@ -167,7 +167,7 @@ int can_sleep_disk(char **types) {
 
 static int hibernation_partition_size(size_t *size, size_t *used) {
         _cleanup_fclose_ FILE *f;
-        int i;
+        unsigned i;
 
         assert(size);
         assert(used);
@@ -190,8 +190,8 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
                 k = fscanf(f,
                            "%ms "   /* device/file */
                            "%ms "   /* type of swap */
-                           "%zd "   /* swap size */
-                           "%zd "   /* used */
+                           "%zu "   /* swap size */
+                           "%zu "   /* used */
                            "%*i\n", /* priority */
                            &dev, &type, &size_field, &used_field);
                 if (k != 4) {
index 2d03ac8..179c961 100644 (file)
@@ -69,7 +69,7 @@
 #endif
 
 #if SIZEOF_TIME_T == 8
-#  define PRI_TIME PRIu64
+#  define PRI_TIME PRIi64
 #elif SIZEOF_TIME_T == 4
 #  define PRI_TIME PRIu32
 #else
index c02a76c..cdc1a50 100644 (file)
@@ -3399,7 +3399,7 @@ static void print_status_info(
                         continue;
 
                 argv = strv_join(p->argv, " ");
-                printf("  Process: %u %s=%s ", p->pid, p->name, strna(argv));
+                printf("  Process: "PID_FMT" %s=%s ", p->pid, p->name, strna(argv));
 
                 good = is_clean_exit_lsb(p->code, p->status, NULL);
                 if (!good) {
@@ -4292,7 +4292,7 @@ static int get_unit_dbus_path_by_pid(
                         &reply,
                         "u", pid);
         if (r < 0) {
-                log_error("Failed to get unit for PID "PID_FMT": %s", pid, bus_error_message(&error, r));
+                log_error("Failed to get unit for PID %"PRIu32": %s", pid, bus_error_message(&error, r));
                 return r;
         }
 
index cb23092..a7c8e12 100644 (file)
@@ -48,7 +48,7 @@ static void test_strpcpyf(void) {
         size_t space_left;
 
         space_left = sizeof(target);
-        space_left = strpcpyf(&s, space_left, "space left: %zd. ", space_left);
+        space_left = strpcpyf(&s, space_left, "space left: %zu. ", space_left);
         space_left = strpcpyf(&s, space_left, "foo%s", "bar");
 
         assert_se(streq(target, "space left: 25. foobar"));
index 8471d31..a37316b 100644 (file)
@@ -603,7 +603,7 @@ static void test_get_process_comm(void) {
 
         r = get_process_environ(me, &env);
         assert_se(r >= 0 || r == -EACCES);
-        log_info("self strlen(environ): '%zd'", strlen(env));
+        log_info("self strlen(environ): '%zu'", strlen(env));
 
         if (!detect_container(NULL))
                 assert_se(get_ctty_devnr(1, &h) == -ENOENT);
index 548985e..03e3dc2 100644 (file)
@@ -273,7 +273,7 @@ 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=%"PRIu64,
+        log_debug("probe %s %sraid offset=%"PRIi64,
                   udev_device_get_devnode(dev),
                   noraid ? "no" : "", offset);
 
index 26c7232..46f1c53 100644 (file)
@@ -111,7 +111,7 @@ static void get_cap_mask(struct udev_device *dev,
 
         if (test) {
                 /* printf pattern with the right unsigned long number of hex chars */
-                snprintf(text, sizeof(text), "  bit %%4u: %%0%zilX\n", 2 * sizeof(unsigned long));
+                snprintf(text, sizeof(text), "  bit %%4u: %%0%zulX\n", 2 * sizeof(unsigned long));
                 log_debug("%s decoded bit map:", attr);
                 val = bitmask_size / sizeof (unsigned long);
                 /* skip over leading zeros */
index 118e797..d8ee4cb 100644 (file)
 
 #include "udev.h"
 
-static const struct key *keyboard_lookup_key(const char *str, unsigned int len);
+static const struct key *keyboard_lookup_key(const char *str, unsigned len);
 #include "keyboard-keys-from-name.h"
 #include "keyboard-keys-to-name.h"
 
-static int install_force_release(struct udev_device *dev, const unsigned int *release, unsigned int release_count) {
+static int install_force_release(struct udev_device *dev, const unsigned *release, unsigned release_count) {
         struct udev_device *atkbd;
         const char *cur;
         char codes[4096];
         char *s;
         size_t l;
-        unsigned int i;
+        unsigned i;
         int ret;
 
         atkbd = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
@@ -57,7 +57,7 @@ static int install_force_release(struct udev_device *dev, const unsigned int *re
 
         /* append new codes */
         for (i = 0; i < release_count; i++)
-                l = strpcpyf(&s, l, ",%d", release[i]);
+                l = strpcpyf(&s, l, ",%u", release[i]);
 
         log_debug("keyboard: updating force-release list with '%s'", codes);
         ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
@@ -69,16 +69,16 @@ static int install_force_release(struct udev_device *dev, const unsigned int *re
 static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], bool test) {
         struct udev_list_entry *entry;
         struct {
-                unsigned int scan;
-                unsigned int key;
+                unsigned scan;
+                unsigned key;
         } map[1024];
-        unsigned int map_count = 0;
-        unsigned int release[1024];
-        unsigned int release_count = 0;
+        unsigned map_count = 0;
+        unsigned release[1024];
+        unsigned release_count = 0;
 
         udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
                 const char *key;
-                unsigned int scancode, keycode_num;
+                unsigned scancode, keycode_num;
                 char *endptr;
                 const char *keycode;
                 const struct key *k;
@@ -130,7 +130,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
         if (map_count > 0 || release_count > 0) {
                 const char *node;
                 int fd;
-                unsigned int i;
+                unsigned i;
 
                 node = udev_device_get_devnode(dev);
                 if (!node) {
index 2e08467..c310111 100644 (file)
@@ -191,12 +191,12 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
         s = names->pci_path;
         l = sizeof(names->pci_path);
         if (domain > 0)
-                l = strpcpyf(&s, l, "P%d", domain);
-        l = strpcpyf(&s, l, "p%ds%d", bus, slot);
+                l = strpcpyf(&s, l, "P%u", domain);
+        l = strpcpyf(&s, l, "p%us%u", bus, slot);
         if (func > 0 || is_pci_multifunction(names->pcidev))
-                l = strpcpyf(&s, l, "f%d", func);
+                l = strpcpyf(&s, l, "f%u", func);
         if (dev_port > 0)
-                l = strpcpyf(&s, l, "d%d", dev_port);
+                l = strpcpyf(&s, l, "d%u", dev_port);
         if (l == 0)
                 names->pci_path[0] = '\0';
 
index 9cece4a..538b342 100644 (file)
@@ -198,7 +198,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
                 goto err;
         }
         if (ucred.uid > 0) {
-                log_error("sender uid=%i, message ignored", ucred.uid);
+                log_error("sender uid="UID_FMT", message ignored", ucred.uid);
                 goto err;
         }
 
@@ -386,7 +386,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
         }
 
         if (cred->uid != 0) {
-                log_error("sender uid=%i, message ignored", cred->uid);
+                log_error("sender uid="UID_FMT", message ignored", cred->uid);
                 goto err;
         }
 
index 6b18430..beb0943 100644 (file)
@@ -218,14 +218,14 @@ subst:
                 case SUBST_MAJOR: {
                         char num[UTIL_PATH_SIZE];
 
-                        sprintf(num, "%d", major(udev_device_get_devnum(dev)));
+                        sprintf(num, "%u", major(udev_device_get_devnum(dev)));
                         l = strpcpy(&s, l, num);
                         break;
                 }
                 case SUBST_MINOR: {
                         char num[UTIL_PATH_SIZE];
 
-                        sprintf(num, "%d", minor(udev_device_get_devnum(dev)));
+                        sprintf(num, "%u", minor(udev_device_get_devnum(dev)));
                         l = strpcpy(&s, l, num);
                         break;
                 }
@@ -509,7 +509,7 @@ static void spawn_read(struct udev_event *event,
                                                 memcpy(&result[respos], buf, count);
                                                 respos += count;
                                         } else {
-                                                log_error("'%s' ressize %zd too short", cmd, ressize);
+                                                log_error("'%s' ressize %zu too short", cmd, ressize);
                                         }
                                 }
 
@@ -580,7 +580,7 @@ static int spawn_wait(struct udev_event *event,
                         goto out;
                 }
                 if (fdcount == 0) {
-                        log_warning("slow: '%s' [%u]", cmd, pid);
+                        log_warning("slow: '%s' ["PID_FMT"]", cmd, pid);
 
                         fdcount = poll(pfd, 1, timeout);
                         if (fdcount < 0) {
@@ -591,7 +591,7 @@ static int spawn_wait(struct udev_event *event,
                                 goto out;
                         }
                         if (fdcount == 0) {
-                                log_error("timeout: killing '%s' [%u]", cmd, pid);
+                                log_error("timeout: killing '%s' ["PID_FMT"]", cmd, pid);
                                 kill(pid, SIGKILL);
                         }
                 }
@@ -613,20 +613,20 @@ static int spawn_wait(struct udev_event *event,
                                 if (waitpid(pid, &status, WNOHANG) < 0)
                                         break;
                                 if (WIFEXITED(status)) {
-                                        log_debug("'%s' [%u] exit with return code %i", cmd, pid, WEXITSTATUS(status));
+                                        log_debug("'%s' ["PID_FMT"] exit with return code %i", cmd, pid, WEXITSTATUS(status));
                                         if (WEXITSTATUS(status) != 0)
                                                 err = -1;
                                 } else if (WIFSIGNALED(status)) {
-                                        log_error("'%s' [%u] terminated by signal %i (%s)", cmd, pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
+                                        log_error("'%s' ["PID_FMT"] terminated by signal %i (%s)", cmd, pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
                                         err = -1;
                                 } else if (WIFSTOPPED(status)) {
-                                        log_error("'%s' [%u] stopped", cmd, pid);
+                                        log_error("'%s' ["PID_FMT"] stopped", cmd, pid);
                                         err = -1;
                                 } else if (WIFCONTINUED(status)) {
-                                        log_error("'%s' [%u] continued", cmd, pid);
+                                        log_error("'%s' ["PID_FMT"] continued", cmd, pid);
                                         err = -1;
                                 } else {
-                                        log_error("'%s' [%u] exit with status 0x%04x", cmd, pid, status);
+                                        log_error("'%s' ["PID_FMT"] exit with status 0x%04x", cmd, pid, status);
                                         err = -1;
                                 }
                                 pid = 0;
index 499feef..793b484 100644 (file)
@@ -341,7 +341,7 @@ void udev_node_add(struct udev_device *dev, bool apply,
         char filename[UTIL_PATH_SIZE];
         struct udev_list_entry *list_entry;
 
-        log_debug("handling device node '%s', devnum=%s, mode=%#o, uid=%d, gid=%d",
+        log_debug("handling device node '%s', devnum=%s, mode=%#o, uid="UID_FMT", gid="GID_FMT,
                   udev_device_get_devnode(dev), udev_device_get_id_filename(dev), mode, uid, gid);
 
         if (node_permissions_apply(dev, apply, mode, uid, gid, seclabel_list) < 0)
index 7a2114a..d65e40c 100644 (file)
@@ -401,7 +401,7 @@ static int trie_store(struct trie *trie, const char *filename) {
         }
 
         log_debug("=== trie on-disk ===");
-        log_debug("size:             %8"PRIu64" bytes", size);
+        log_debug("size:             %8"PRIi64" bytes", size);
         log_debug("header:           %8zu bytes", sizeof(struct trie_header_f));
         log_debug("nodes:            %8"PRIu64" bytes (%8"PRIu64")",
                   t.nodes_count * sizeof(struct trie_node_f), t.nodes_count);
index f52a03d..0bab01a 100644 (file)
@@ -162,12 +162,12 @@ static int stat_device(const char *name, bool export, const char *prefix) {
         if (export) {
                 if (prefix == NULL)
                         prefix = "INFO_";
-                printf("%sMAJOR=%d\n"
-                       "%sMINOR=%d\n",
+                printf("%sMAJOR=%u\n"
+                       "%sMINOR=%u\n",
                        prefix, major(statbuf.st_dev),
                        prefix, minor(statbuf.st_dev));
         } else
-                printf("%d:%d\n", major(statbuf.st_dev), minor(statbuf.st_dev));
+                printf("%u:%u\n", major(statbuf.st_dev), minor(statbuf.st_dev));
         return 0;
 }
 
index 009e395..009e2fe 100644 (file)
@@ -158,7 +158,7 @@ static void worker_unref(struct worker *worker) {
         worker->refcount--;
         if (worker->refcount > 0)
                 return;
-        log_debug("worker [%u] cleaned up", worker->pid);
+        log_debug("worker ["PID_FMT"] cleaned up", worker->pid);
         worker_cleanup(worker);
 }
 
@@ -414,7 +414,7 @@ out:
                 event->state = EVENT_RUNNING;
                 udev_list_node_append(&worker->node, &worker_list);
                 children++;
-                log_debug("seq %llu forked new worker [%u]", udev_device_get_seqnum(event->dev), pid);
+                log_debug("seq %llu forked new worker ["PID_FMT"]", udev_device_get_seqnum(event->dev), pid);
                 break;
         }
 }
@@ -431,7 +431,8 @@ static void event_run(struct event *event) {
 
                 count = udev_monitor_send_device(monitor, worker->monitor, event->dev);
                 if (count < 0) {
-                        log_error_errno(errno, "worker [%u] did not accept message %zi (%m), kill it", worker->pid, count);
+                        log_error_errno(errno, "worker ["PID_FMT"] did not accept message %zi (%m), kill it",
+                                        worker->pid, count);
                         kill(worker->pid, SIGKILL);
                         worker->state = WORKER_KILLED;
                         continue;
@@ -869,26 +870,26 @@ static void handle_signal(struct udev *udev, int signo) {
 
                                 if (worker->pid != pid)
                                         continue;
-                                log_debug("worker [%u] exit", pid);
+                                log_debug("worker ["PID_FMT"] exit", pid);
 
                                 if (WIFEXITED(status)) {
                                         if (WEXITSTATUS(status) != 0)
-                                                log_error("worker [%u] exit with return code %i",
+                                                log_error("worker ["PID_FMT"] exit with return code %i",
                                                           pid, WEXITSTATUS(status));
                                 } else if (WIFSIGNALED(status)) {
-                                        log_error("worker [%u] terminated by signal %i (%s)",
+                                        log_error("worker ["PID_FMT"] terminated by signal %i (%s)",
                                                   pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
                                 } else if (WIFSTOPPED(status)) {
-                                        log_error("worker [%u] stopped", pid);
+                                        log_error("worker ["PID_FMT"] stopped", pid);
                                 } else if (WIFCONTINUED(status)) {
-                                        log_error("worker [%u] continued", pid);
+                                        log_error("worker ["PID_FMT"] continued", pid);
                                 } else {
-                                        log_error("worker [%u] exit with status 0x%04x", pid, status);
+                                        log_error("worker ["PID_FMT"] exit with status 0x%04x", pid, status);
                                 }
 
                                 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
                                         if (worker->event) {
-                                                log_error("worker [%u] failed while handling '%s'",
+                                                log_error("worker ["PID_FMT"] failed while handling '%s'",
                                                           pid, worker->event->devpath);
                                                 worker->event->exitcode = -32;
                                                 event_queue_delete(worker->event);
@@ -1409,7 +1410,7 @@ int main(int argc, char *argv[]) {
 
                                 if ((ts - worker->event_start_usec) > arg_event_timeout_warn_usec) {
                                         if ((ts - worker->event_start_usec) > arg_event_timeout_usec) {
-                                                log_error("worker [%u] %s timeout; kill it", worker->pid, worker->event->devpath);
+                                                log_error("worker ["PID_FMT"] %s timeout; kill it", worker->pid, worker->event->devpath);
                                                 kill(worker->pid, SIGKILL);
                                                 worker->state = WORKER_KILLED;
 
@@ -1420,7 +1421,7 @@ int main(int argc, char *argv[]) {
                                                 event_queue_delete(worker->event);
                                                 worker->event = NULL;
                                         } else if (!worker->event_warned) {
-                                                log_warning("worker [%u] %s is taking a long time", worker->pid, worker->event->devpath);
+                                                log_warning("worker ["PID_FMT"] %s is taking a long time", worker->pid, worker->event->devpath);
                                                 worker->event_warned = true;
                                         }
                                 }