libfstools: handle gzip return value in block_volume_format
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 17 Jul 2022 09:44:24 +0000 (11:44 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Sun, 17 Jul 2022 09:44:24 +0000 (11:44 +0200)
Fix the following compilation warning:
libfstools/common.c: In function 'block_volume_format':
libfstools/common.c:120:17: error: ignoring return value of 'system' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  120 |                 system(str);
      |                 ^~~~~~~~~~~

Correctly handle return value from gzip and print an error on such case.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
libfstools/common.c

index 1b22d2cb19aefe1b928fad6045210b2656c1c16d..55c1b8745d0a955fa3bc6cdf0a31223fdd8483fb 100644 (file)
@@ -117,7 +117,11 @@ int block_volume_format(struct volume *v, uint64_t offset, const char *bdev)
        switch (volume_identify(v)) {
        case FS_TARGZ:
                snprintf(str, sizeof(str), "gzip -cd %s > /tmp/sysupgrade.tar", v->blk);
-               system(str);
+               ret = system(str);
+               if (ret < 0) {
+                       ULOG_ERR("failed extracting %s\n", v->blk);
+                       break;
+               }
                /* fall-through */
        case FS_NONE:
                ULOG_INFO("overlay filesystem in %s has not been formatted yet\n", v->blk);