From a7419dbc59da5c8cc9e90b3d96bc947cad91ae16 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Fri, 24 Nov 2017 10:36:04 +0000 Subject: [PATCH] Replace use of snprintf with xsprintf --- src/basic/log.c | 4 ++-- src/core/job.c | 2 +- src/core/unit.c | 2 +- src/udev/collect/collect.c | 2 +- src/udev/udev-builtin-net_id.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/basic/log.c b/src/basic/log.c index 18a1ea0..1637a06 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -359,7 +359,7 @@ static int write_to_console( highlight = LOG_PRI(level) <= LOG_ERR && show_color; if (show_location) { - snprintf(location, sizeof(location), "(%s:%i) ", file, line); + xsprintf(location, "(%s:%i) ", file, line); iovec[n++] = IOVEC_MAKE_STRING(location); } @@ -798,7 +798,7 @@ static void log_assert( return; DISABLE_WARNING_FORMAT_NONLITERAL; - snprintf(buffer, sizeof buffer, format, text, file, line, func); + xsprintf(buffer, format, text, file, line, func); REENABLE_WARNING; log_abort_msg = buffer; diff --git a/src/core/job.c b/src/core/job.c index 46defae..2ea7834 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -777,7 +777,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) { /* The description might be longer than the buffer, but that's OK, we'll just truncate it here */ DISABLE_WARNING_FORMAT_NONLITERAL; - snprintf(buf, sizeof(buf), format, unit_description(u)); + xsprintf(buf, format, unit_description(u)); REENABLE_WARNING; switch (t) { diff --git a/src/core/unit.c b/src/core/unit.c index ae5b7b1..c419cae 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1680,7 +1680,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) { format = unit_get_status_message_format(u, t); DISABLE_WARNING_FORMAT_NONLITERAL; - snprintf(buf, sizeof buf, format, unit_description(u)); + xsprintf(buf, format, unit_description(u)); REENABLE_WARNING; mid = t == JOB_START ? "MESSAGE_ID=" SD_MESSAGE_UNIT_STARTING_STR : diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c index 7b5fdf5..17e6616 100644 --- a/src/udev/collect/collect.c +++ b/src/udev/collect/collect.c @@ -94,7 +94,7 @@ static int prepare(char *dir, char *filename) if (r < 0 && errno != EEXIST) return -errno; - snprintf(buf, sizeof buf, "%s/%s", dir, filename); + xsprintf(buf, "%s/%s", dir, filename); fd = open(buf, O_RDWR|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR); if (fd < 0) diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 803c33f..f3be27f 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -275,7 +275,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { goto out; } - snprintf(slots, sizeof slots, "%s/slots", udev_device_get_syspath(pci)); + xsprintf(slots, "%s/slots", udev_device_get_syspath(pci)); dir = opendir(slots); if (!dir) { err = -errno; @@ -294,7 +294,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { if (i < 1) continue; - snprintf(str, sizeof str, "%s/%s/address", slots, dent->d_name); + xsprintf(str, "%s/%s/address", slots, dent->d_name); if (read_one_line_file(str, &address) >= 0) { /* match slot address with device by stripping the function */ if (strneq(address, udev_device_get_sysname(names->pcidev), strlen(address))) -- 2.7.4