fstools: Replace strerror(errno) with %m format.
authorRosen Penev <rosenp@gmail.com>
Sun, 10 Dec 2017 04:54:41 +0000 (20:54 -0800)
committerJohn Crispin <john@phrozen.org>
Tue, 12 Dec 2017 10:52:53 +0000 (11:52 +0100)
Saves 1472 bytes under glibc. No other difference.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
block.c
jffs2reset.c
libfstools/find.c
libfstools/mount.c
libfstools/mtd.c
libfstools/overlay.c
snapshot.c

diff --git a/block.c b/block.c
index d7a9c5f..ab130b9 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1052,8 +1052,8 @@ static int mount_device(struct probe_info *pr, int type)
 
                err = handle_mount(pr->dev, target, pr->type, m);
                if (err)
 
                err = handle_mount(pr->dev, target, pr->type, m);
                if (err)
-                       ULOG_ERR("mounting %s (%s) as %s failed (%d) - %s\n",
-                                pr->dev, pr->type, target, errno, strerror(errno));
+                       ULOG_ERR("mounting %s (%s) as %s failed (%d) - %m\n",
+                                pr->dev, pr->type, target, errno);
                else
                        handle_swapfiles(true);
                return err;
                else
                        handle_swapfiles(true);
                return err;
@@ -1071,8 +1071,8 @@ static int mount_device(struct probe_info *pr, int type)
 
                err = handle_mount(pr->dev, target, pr->type, NULL);
                if (err)
 
                err = handle_mount(pr->dev, target, pr->type, NULL);
                if (err)
-                       ULOG_ERR("mounting %s (%s) as %s failed (%d) - %s\n",
-                                pr->dev, pr->type, target, errno, strerror(errno));
+                       ULOG_ERR("mounting %s (%s) as %s failed (%d) - %m\n",
+                                pr->dev, pr->type, target, errno);
                else
                        handle_swapfiles(true);
                return err;
                else
                        handle_swapfiles(true);
                return err;
@@ -1104,8 +1104,8 @@ static int umount_device(struct probe_info *pr)
 
        err = umount2(mp, MNT_DETACH);
        if (err)
 
        err = umount2(mp, MNT_DETACH);
        if (err)
-               ULOG_ERR("unmounting %s (%s)  failed (%d) - %s\n",
-                        pr->dev, mp, errno, strerror(errno));
+               ULOG_ERR("unmounting %s (%s)  failed (%d) - %m\n",
+                        pr->dev, mp, errno);
        else
                ULOG_INFO("unmounted %s (%s)\n",
                          pr->dev, mp);
        else
                ULOG_INFO("unmounted %s (%s)\n",
                          pr->dev, mp);
@@ -1134,8 +1134,8 @@ static int mount_action(char *action, char *device, int type)
                        err = umount2(mount_point, MNT_DETACH);
 
                if (err)
                        err = umount2(mount_point, MNT_DETACH);
 
                if (err)
-                       ULOG_ERR("umount of %s failed (%d) - %s\n",
-                                mount_point, errno, strerror(errno));
+                       ULOG_ERR("umount of %s failed (%d) - %m\n",
+                                mount_point, errno);
 
                free(mount_point);
                return 0;
 
                free(mount_point);
                return 0;
@@ -1360,8 +1360,8 @@ static int check_extroot(char *path)
                        if (stat(tag, &s)) {
                                fp = fopen(tag, "w+");
                                if (!fp) {
                        if (stat(tag, &s)) {
                                fp = fopen(tag, "w+");
                                if (!fp) {
-                                       ULOG_ERR("extroot: failed to write UUID to %s: %d (%s)\n",
-                                                tag, errno, strerror(errno));
+                                       ULOG_ERR("extroot: failed to write UUID to %s: %d (%m)\n",
+                                                tag, errno);
                                        /* return 0 to continue boot regardless of error */
                                        return 0;
                                }
                                        /* return 0 to continue boot regardless of error */
                                        return 0;
                                }
@@ -1372,14 +1372,14 @@ static int check_extroot(char *path)
 
                        fp = fopen(tag, "r");
                        if (!fp) {
 
                        fp = fopen(tag, "r");
                        if (!fp) {
-                               ULOG_ERR("extroot: failed to read UUID from %s: %d (%s)\n",
-                                        tag, errno, strerror(errno));
+                               ULOG_ERR("extroot: failed to read UUID from %s: %d (%m)\n",
+                                        tag, errno);
                                return -1;
                        }
 
                        if (!fgets(uuid, sizeof(uuid), fp))
                                return -1;
                        }
 
                        if (!fgets(uuid, sizeof(uuid), fp))
-                               ULOG_ERR("extroot: failed to read UUID from %s: %d (%s)\n",
-                                        tag, errno, strerror(errno));
+                               ULOG_ERR("extroot: failed to read UUID from %s: %d (%m)\n",
+                                        tag, errno);
                        fclose(fp);
 
                        if (*uuid && !strcasecmp(uuid, pr->uuid))
                        fclose(fp);
 
                        if (*uuid && !strcasecmp(uuid, pr->uuid))
@@ -1457,8 +1457,8 @@ static int mount_extroot(char *cfg)
                            (m->options) ? (m->options) : (""));
 
                if (err) {
                            (m->options) ? (m->options) : (""));
 
                if (err) {
-                       ULOG_ERR("extroot: mounting %s (%s) on %s failed: %d (%s)\n",
-                                pr->dev, pr->type, path, errno, strerror(errno));
+                       ULOG_ERR("extroot: mounting %s (%s) on %s failed: %d (%m)\n",
+                                pr->dev, pr->type, path, errno);
                } else if (m->overlay) {
                        err = check_extroot(path);
                        if (err)
                } else if (m->overlay) {
                        err = check_extroot(path);
                        if (err)
index 9a31fdd..dbe0498 100644 (file)
@@ -83,7 +83,7 @@ static int jffs2_mark(struct volume *v)
        close(fd);
 
        if (sz != 4) {
        close(fd);
 
        if (sz != 4) {
-               ULOG_ERR("writing %s failed: %s\n", v->blk, strerror(errno));
+               ULOG_ERR("writing %s failed: %m\n", v->blk);
                return -1;
        }
 
                return -1;
        }
 
index fcc47a7..b383f57 100644 (file)
@@ -223,7 +223,7 @@ find_filesystem(char *fs)
        int ret = -1;
 
        if (!fp) {
        int ret = -1;
 
        if (!fp) {
-               ULOG_ERR("opening /proc/filesystems failed: %s\n", strerror(errno));
+               ULOG_ERR("opening /proc/filesystems failed: %m\n");
                goto out;
        }
 
                goto out;
        }
 
index 551f4e7..4dc6e3a 100644 (file)
@@ -54,7 +54,7 @@ mount_move(char *oldroot, char *newroot, char *dir)
        ret = mount(olddir, newdir, NULL, MS_NOATIME | MS_MOVE, NULL);
 
 /*     if (ret)
        ret = mount(olddir, newdir, NULL, MS_NOATIME | MS_MOVE, NULL);
 
 /*     if (ret)
-               ULOG_ERR("failed %s %s: %s\n", olddir, newdir, strerror(errno));*/
+               ULOG_ERR("failed %s %s: %m\n", olddir, newdir);*/
 
        return ret;
 }
 
        return ret;
 }
@@ -73,7 +73,7 @@ pivot(char *new, char *old)
        ret = pivot_root(new, pivotdir);
 
        if (ret < 0) {
        ret = pivot_root(new, pivotdir);
 
        if (ret < 0) {
-               ULOG_ERR("pivot_root failed %s %s: %s\n", new, pivotdir, strerror(errno));
+               ULOG_ERR("pivot_root failed %s %s: %m\n", new, pivotdir);
                return -1;
        }
 
                return -1;
        }
 
@@ -136,8 +136,7 @@ fopivot(char *rw_root, char *ro_root)
                /* Mainlined overlayfs has been renamed to "overlay", try that first */
                if (mount(overlay, "/mnt", "overlay", MS_NOATIME, mount_options)) {
                        if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, mount_options)) {
                /* Mainlined overlayfs has been renamed to "overlay", try that first */
                if (mount(overlay, "/mnt", "overlay", MS_NOATIME, mount_options)) {
                        if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, mount_options)) {
-                               ULOG_ERR("mount failed: %s, options %s\n",
-                                        strerror(errno), mount_options);
+                               ULOG_ERR("mount failed: %s, options %m\n", mount_options);
                                return -1;
                        }
                }
                                return -1;
                        }
                }
index 2603a15..77c71ee 100644 (file)
@@ -198,7 +198,7 @@ static int mtd_volume_identify(struct volume *v)
        sz = read(p->fd, &deadc0de, sizeof(deadc0de));
 
        if (sz != sizeof(deadc0de)) {
        sz = read(p->fd, &deadc0de, sizeof(deadc0de));
 
        if (sz != sizeof(deadc0de)) {
-               ULOG_ERR("reading %s failed: %s\n", v->name, strerror(errno));
+               ULOG_ERR("reading %s failed: %m\n", v->name);
                return -1;
        }
 
                return -1;
        }
 
@@ -275,7 +275,7 @@ static int mtd_volume_init(struct volume *v)
 
        ret = ioctl(p->fd, MEMGETINFO, &mtdinfo);
        if (ret) {
 
        ret = ioctl(p->fd, MEMGETINFO, &mtdinfo);
        if (ret) {
-               ULOG_ERR("ioctl(%d, MEMGETINFO) failed: %s\n", p->fd, strerror(errno));
+               ULOG_ERR("ioctl(%d, MEMGETINFO) failed: %m\n", p->fd);
        } else {
                struct erase_info_user mtdlock;
 
        } else {
                struct erase_info_user mtdlock;
 
index 5a49da2..7ada5ff 100644 (file)
@@ -102,12 +102,12 @@ static int
 overlay_mount(struct volume *v, char *fs)
 {
        if (mkdir("/tmp/overlay", 0755)) {
 overlay_mount(struct volume *v, char *fs)
 {
        if (mkdir("/tmp/overlay", 0755)) {
-               ULOG_ERR("failed to mkdir /tmp/overlay: %s\n", strerror(errno));
+               ULOG_ERR("failed to mkdir /tmp/overlay: %m\n");
                return -1;
        }
 
        if (mount(v->blk, "/tmp/overlay", fs, MS_NOATIME, NULL)) {
                return -1;
        }
 
        if (mount(v->blk, "/tmp/overlay", fs, MS_NOATIME, NULL)) {
-               ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %s\n", fs, v->blk, strerror(errno));
+               ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %m\n", fs, v->blk);
                return -1;
        }
 
                return -1;
        }
 
@@ -129,27 +129,27 @@ switch2jffs(struct volume *v)
        ret = mount(v->blk, "/rom/overlay", "jffs2", MS_NOATIME, NULL);
        unlink("/tmp/.switch_jffs2");
        if (ret) {
        ret = mount(v->blk, "/rom/overlay", "jffs2", MS_NOATIME, NULL);
        unlink("/tmp/.switch_jffs2");
        if (ret) {
-               ULOG_ERR("failed - mount -t jffs2 %s /rom/overlay: %s\n", v->blk, strerror(errno));
+               ULOG_ERR("failed - mount -t jffs2 %s /rom/overlay: %m\n", v->blk);
                return -1;
        }
 
        if (mount("none", "/", NULL, MS_NOATIME | MS_REMOUNT, 0)) {
                return -1;
        }
 
        if (mount("none", "/", NULL, MS_NOATIME | MS_REMOUNT, 0)) {
-               ULOG_ERR("failed - mount -o remount,ro none: %s\n", strerror(errno));
+               ULOG_ERR("failed - mount -o remount,ro none: %m\n");
                return -1;
        }
 
        if (system("cp -a /tmp/root/* /rom/overlay")) {
                return -1;
        }
 
        if (system("cp -a /tmp/root/* /rom/overlay")) {
-               ULOG_ERR("failed - cp -a /tmp/root/* /rom/overlay: %s\n", strerror(errno));
+               ULOG_ERR("failed - cp -a /tmp/root/* /rom/overlay: %m\n");
                return -1;
        }
 
        if (pivot("/rom", "/mnt")) {
                return -1;
        }
 
        if (pivot("/rom", "/mnt")) {
-               ULOG_ERR("failed - pivot /rom /mnt: %s\n", strerror(errno));
+               ULOG_ERR("failed - pivot /rom /mnt: %m\n");
                return -1;
        }
 
        if (mount_move("/mnt", "/tmp/root", "")) {
                return -1;
        }
 
        if (mount_move("/mnt", "/tmp/root", "")) {
-               ULOG_ERR("failed - mount -o move /mnt /tmp/root %s\n", strerror(errno));
+               ULOG_ERR("failed - mount -o move /mnt /tmp/root %m\n");
                return -1;
        }
 
                return -1;
        }
 
@@ -267,13 +267,13 @@ static int overlay_mount_fs(struct volume *v)
        char *fstype = overlay_fs_name(volume_identify(v));
 
        if (mkdir("/tmp/overlay", 0755)) {
        char *fstype = overlay_fs_name(volume_identify(v));
 
        if (mkdir("/tmp/overlay", 0755)) {
-               ULOG_ERR("failed to mkdir /tmp/overlay: %s\n", strerror(errno));
+               ULOG_ERR("failed to mkdir /tmp/overlay: %m\n");
                return -1;
        }
 
        if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, NULL)) {
                return -1;
        }
 
        if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, NULL)) {
-               ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %s\n",
-                        fstype, v->blk, strerror(errno));
+               ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %m\n",
+                        fstype, v->blk);
                return -1;
        }
 
                return -1;
        }
 
index bb44cd3..df555e2 100644 (file)
@@ -136,7 +136,7 @@ snapshot_mark(int argc, char **argv)
        close(fd);
 
        if (sz != 1) {
        close(fd);
 
        if (sz != 1) {
-               ULOG_ERR("writing %s failed: %s\n", v->blk, strerror(errno));
+               ULOG_ERR("writing %s failed: %m\n", v->blk);
                return -1;
        }
 
                return -1;
        }