From: Lennart Poettering Date: Fri, 21 Apr 2023 10:39:28 +0000 (+0200) Subject: tre-wide: use FORMAT_DEVNUM() a bit more X-Git-Tag: v254-rc1~667^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F27352%2Fhead;p=thirdparty%2Fsystemd.git tre-wide: use FORMAT_DEVNUM() a bit more --- diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index f82a90dc1b2..a8a451ee1a8 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -23,6 +23,7 @@ #include "bus-locator.h" #include "bus-util.h" #include "constants.h" +#include "devnum-util.h" #include "exec-util.h" #include "fd-util.h" #include "fileio.h" @@ -45,13 +46,14 @@ static SleepOperation arg_operation = _SLEEP_OPERATION_INVALID; static int write_hibernate_location_info(const HibernateLocation *hibernate_location) { char offset_str[DECIMAL_STR_MAX(uint64_t)]; - char resume_str[DECIMAL_STR_MAX(unsigned) * 2 + STRLEN(":")]; + const char *resume_str; int r; assert(hibernate_location); assert(hibernate_location->swap); - xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); + resume_str = FORMAT_DEVNUM(hibernate_location->devno); + r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); if (r < 0) return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index 27ab57e119f..f5b22480404 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -439,7 +439,7 @@ static int merge_hierarchy( if (!f) return log_oom(); - r = write_string_filef(f, WRITE_STRING_FILE_CREATE, "%u:%u", major(st.st_dev), minor(st.st_dev)); + r = write_string_file(f, FORMAT_DEVNUM(st.st_dev), WRITE_STRING_FILE_CREATE); if (r < 0) return log_error_errno(r, "Failed to write '%s': %m", f);