Types used for pids and uids in various interfaces are unpredictable.
Too bad.
user = uid_to_name(i->uid);
- printf("%sUser: %s (%d)\n",
+ printf("%sUser: %s ("UID_FMT")\n",
prefix, strna(user), i->uid);
}
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);
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);
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)
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);
}
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);
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);
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;
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;
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");
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;
}
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);
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;
}
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;
}
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;
}
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;
}
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");
if (!p)
return;
- if (sscanf(p, "(%" PRIi64 ".%" PRIi64 ":%" PRIi64 "):%n",
+ if (sscanf(p, "(%" PRIu64 ".%" PRIu64 ":%" PRIu64 "):%n",
&seconds,
&msec,
&id,
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;
}
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(),
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 */
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));
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))) {
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 {
/*
}
} 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;
}
}
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;
}
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;
}
}
}
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;
}
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),
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++;
if (r < 0)
return r;
- if (asprintf(&printed, "%d", uid) < 0)
+ if (asprintf(&printed, UID_FMT, uid) < 0)
return -ENOMEM;
break;
}}
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);
}
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
static int hibernation_partition_size(size_t *size, size_t *used) {
_cleanup_fclose_ FILE *f;
- int i;
+ unsigned i;
assert(size);
assert(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) {
#endif
#if SIZEOF_TIME_T == 8
-# define PRI_TIME PRIu64
+# define PRI_TIME PRIi64
#elif SIZEOF_TIME_T == 4
# define PRI_TIME PRIu32
#else
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) {
&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;
}
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"));
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);
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);
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 */
#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);
/* 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);
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;
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) {
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';
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;
}
}
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;
}
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;
}
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);
}
}
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) {
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);
}
}
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;
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)
}
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);
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;
}
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);
}
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;
}
}
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;
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);
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;
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;
}
}