diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-10-10 08:11:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-10-11 16:46:25 +0200 |
commit | b6c514bd1c2e13955ddd6a26df2c33ae74f17d0b (patch) | |
tree | c15bcedb9f2f15e41abc69f4bad3a06a92ae7add /common | |
parent | 15111afb387482035fc64ca5b621ec6c933ac7f8 (diff) | |
download | barebox-b6c514bd1c2e13955ddd6a26df2c33ae74f17d0b.tar.gz barebox-b6c514bd1c2e13955ddd6a26df2c33ae74f17d0b.tar.xz |
treewide: replace errno_str() with %m printf format specifier
Both errno_str() and printf("%m" end up calling strerror(). %m is
more convenient to use, so switch over all instances to it.
No functional change.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20221010061122.2084009-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/elf.c | 13 | ||||
-rw-r--r-- | common/envfs-core.c | 3 | ||||
-rw-r--r-- | common/environment.c | 11 | ||||
-rw-r--r-- | common/firmware.c | 5 | ||||
-rw-r--r-- | common/misc.c | 2 | ||||
-rw-r--r-- | common/uimage.c | 4 |
6 files changed, 17 insertions, 21 deletions
diff --git a/common/elf.c b/common/elf.c index f10fb77953..eec62cad61 100644 --- a/common/elf.c +++ b/common/elf.c @@ -109,7 +109,7 @@ static int load_elf_to_memory(struct elf_image *elf) if (elf->filename) { fd = open(elf->filename, O_RDONLY); if (fd < 0) { - pr_err("could not open: %s\n", errno_str()); + pr_err("could not open: %m\n"); return -errno; } } @@ -133,8 +133,7 @@ static int load_elf_to_memory(struct elf_image *elf) } if (read_full(fd, dst, p_filesz) < 0) { - pr_err("could not read elf segment: %s\n", - errno_str()); + pr_err("could not read elf segment: %m\n"); close(fd); return -errno; } @@ -256,13 +255,13 @@ static struct elf_image *elf_check_init(const char *filename) /* First pass is to read elf header only */ fd = open(filename, O_RDONLY); if (fd < 0) { - pr_err("could not open: %s\n", errno_str()); + pr_err("could not open: %m\n"); ret = -errno; goto err_free_elf; } if (read_full(fd, &hdr, sizeof(hdr)) < 0) { - pr_err("could not read elf header: %s\n", errno_str()); + pr_err("could not read elf header: %m\n"); close(fd); ret = -errno; goto err_free_elf; @@ -290,13 +289,13 @@ static struct elf_image *elf_check_init(const char *filename) */ fd = open(filename, O_RDONLY); if (fd < 0) { - pr_err("could not open: %s\n", errno_str()); + pr_err("could not open: %m\n"); ret = -errno; goto err_free_hdr_buf; } if (read_full(fd, elf->hdr_buf, hdr_size) < 0) { - pr_err("could not read elf program headers: %s\n", errno_str()); + pr_err("could not read elf program headers: %m\n"); ret = -errno; close(fd); goto err_free_hdr_buf; diff --git a/common/envfs-core.c b/common/envfs-core.c index 0984d53873..20b3e647d3 100644 --- a/common/envfs-core.c +++ b/common/envfs-core.c @@ -24,7 +24,6 @@ #include <environment.h> #include <libfile.h> #else -# define errno_str(x) ("void") #define pr_info(fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__) #define pr_warn(fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__) #endif @@ -151,7 +150,7 @@ int envfs_load_data(struct envfs_super *super, void *buf, size_t size, fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644); free(str); if (fd < 0) { - printf("Open %s\n", errno_str()); + printf("Open %m\n"); ret = fd; goto out; } diff --git a/common/environment.c b/common/environment.c index 0d31f5b4f7..e8c487c1a2 100644 --- a/common/environment.c +++ b/common/environment.c @@ -27,7 +27,6 @@ #include <globalvar.h> #include <libfile.h> #else -# define errno_str(x) ("void") #define EXPORT_SYMBOL(x) #endif @@ -297,7 +296,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) envfd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (envfd < 0) { - printf("could not open %s: %s\n", filename, errno_str()); + printf("could not open %s: %m\n", filename); ret = -errno; goto out1; } @@ -306,7 +305,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { - printf("could not unprotect %s: %s\n", filename, errno_str()); + printf("could not unprotect %s: %m\n", filename); goto out; } @@ -314,7 +313,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { - printf("could not erase %s: %s\n", filename, errno_str()); + printf("could not erase %s: %m\n", filename); goto out; } @@ -337,7 +336,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) /* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */ if (ret && errno != ENOSYS && errno != EOPNOTSUPP) { - printf("could not protect %s: %s\n", filename, errno_str()); + printf("could not protect %s: %m\n", filename); goto out; } @@ -385,7 +384,7 @@ int envfs_load(const char *filename, const char *dir, unsigned flags) envfd = open(filename, O_RDONLY); if (envfd < 0) { - printf("environment load %s: %s\n", filename, errno_str()); + printf("environment load %s: %m\n", filename); if (errno == ENOENT) printf("Maybe you have to create the partition.\n"); return -1; diff --git a/common/firmware.c b/common/firmware.c index b87d7da38f..e4ad6ac867 100644 --- a/common/firmware.c +++ b/common/firmware.c @@ -272,8 +272,7 @@ int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *firmware) firmwarefd = open(firmware, O_RDONLY); if (firmwarefd < 0) { - printf("could not open %s: %s\n", firmware, - errno_str()); + printf("could not open %s: %m\n", firmware); ret = firmwarefd; goto out; } @@ -282,7 +281,7 @@ int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *firmware) devicefd = open(dst, O_WRONLY); if (devicefd < 0) { - printf("could not open %s: %s\n", dst, errno_str()); + printf("could not open %s: %m\n", dst); ret = devicefd; goto out; } diff --git a/common/misc.c b/common/misc.c index e0e32f47c5..0c4bbe361d 100644 --- a/common/misc.c +++ b/common/misc.c @@ -114,7 +114,7 @@ EXPORT_SYMBOL(errno_str); void perror(const char *s) { #ifdef CONFIG_ERRNO_MESSAGES - printf("%s: %s\n", s, errno_str()); + printf("%s: %m\n", s); #else printf("%s returned with %d\n", s, errno); #endif diff --git a/common/uimage.c b/common/uimage.c index 42e9d9023f..72c37b7d15 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -98,7 +98,7 @@ struct uimage_handle *uimage_open(const char *filename) fd = open(filename, O_RDONLY); if (fd < 0) { - printf("could not open: %s\n", errno_str()); + printf("could not open: %m\n"); free(copy); return NULL; } @@ -109,7 +109,7 @@ struct uimage_handle *uimage_open(const char *filename) handle->copy = copy; if (read(fd, header, sizeof(*header)) < 0) { - printf("could not read: %s\n", errno_str()); + printf("could not read: %m\n"); goto err_out; } |