firmware-utils: fix -Wmaybe-uninitialized warnings
authorRafał Miłecki <rafal@milecki.pl>
Fri, 9 Apr 2021 07:21:25 +0000 (09:21 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Fri, 9 Apr 2021 08:46:15 +0000 (10:46 +0200)
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
tools/firmware-utils/src/asustrx.c
tools/firmware-utils/src/mkcasfw.c
tools/firmware-utils/src/mkcsysimg.c
tools/firmware-utils/src/mkdapimg.c
tools/firmware-utils/src/mkdapimg2.c
tools/firmware-utils/src/mkrtn56uimg.c

index b3daeedcfd00b6be1c759b30d1ff60bca1a67d3a..04af9a184a58c24ad8f552716d79799ddebab0f6 100644 (file)
@@ -150,7 +150,8 @@ static void usage() {
 int main(int argc, char **argv) {
        struct trx_header hdr;
        struct asustrx_tail tail = { };
-       FILE *in, *out;
+       FILE *out = NULL;
+       FILE *in = NULL;
        uint8_t buf[1024];
        size_t bytes;
        size_t length = 0;
index eb92c8e3ffc1fd779e8387da76e0af5f47f6c941..904000c78da3ccd318f2390e1703adc0b41b896a 100644 (file)
@@ -554,6 +554,10 @@ csum_get(struct csum_state *css)
                break;
        case CSUM_TYPE_32:
                ret = csum32_get(css);
+               break;
+       default:
+               ERR("invalid checksum size\n");
+               return 0;
        }
 
        return ret;
@@ -755,6 +759,9 @@ write_out_header(FILE *outfile)
                res = write_out_data(outfile, (uint8_t *)&tmp.nfs,
                                        sizeof(tmp.nfs), NULL);
                break;
+       default:
+               ERR("invalid header type\n");
+               return -EINVAL;
        }
 
        return res;
index 7c0002c40473fa43ebc39ccfb0eaa20e7472cbb0..e156f79153ae6625c93ad6e227b3fc847ec19047 100644 (file)
@@ -493,6 +493,9 @@ csum_get(struct csum_state *css)
        case CSUM_SIZE_16:
                ret = csum16_get(css);
                break;
+       default:
+               ERR("invalid checksum size\n");
+               return 0;
        }
 
        return ret;
index 640f42d7c6c91a8bfc423a1a1c0941c87f96548d..0031d83dd08ded11f03f42f52db6249450bfa2fe 100644 (file)
@@ -68,7 +68,8 @@ main(int ac, char *av[])
        int fixmode = 0;
        int have_regionversion = 0;
 
-       FILE *ifile, *ofile;
+       FILE *ifile = NULL;
+       FILE *ofile = NULL;
        int c;
        uint32_t cksum;
        uint32_t bcnt;
index 6b53c959b6b581a5df7d234acd5e9d1113a31596..1d09290a16b5248e20acfff023a64565b2c0ef02 100644 (file)
@@ -92,7 +92,8 @@ main(int ac, char *av[])
        char region[MAX_REG_LEN];
        int kernel = 0;
 
-       FILE *ifile, *ofile;
+       FILE *ifile = NULL;
+       FILE *ofile = NULL;
        int c;
 
        uint32_t cksum;
index 6b72e1e233b9d1a899aadd2c815dd8a14a167808..b6c891bbdcc9040bd7dde1bdd214a70e69b9d140 100644 (file)
@@ -251,7 +251,8 @@ int
 main(int argc, char **argv)
 {
        int             opt;
-       char            *filename, *progname;
+       char            *filename = NULL;
+       char            *progname;
        op_mode_t       opmode = NONE;
 
        progname = argv[0];