]> Git Repo - imx_flashconf.git/commitdiff
error checking main
authorJesse Taube <[email protected]>
Sat, 22 Jan 2022 00:44:36 +0000 (19:44 -0500)
committerJesse Taube <[email protected]>
Sat, 22 Jan 2022 00:47:33 +0000 (19:47 -0500)
imx-flashconf.c
mk.sh

index 5ff02da701f818a50a9deddc7859c8445b3b327e..1b2cd42747735868ac6083c02707370fa00cc734 100644 (file)
@@ -19,8 +19,8 @@ void prepend(FILE *, size_t);
 void list(const flash_configs *);
 int main(int argc, char *argv[]){
 
 void list(const flash_configs *);
 int main(int argc, char *argv[]){
 
-       char name[32];
-       char fname[32];
+       char name[32] = {};
+       const char * fname;
        int opt;
        size_t index = 0;
        size_t padding = 0x1000; // default offset for nor
        int opt;
        size_t index = 0;
        size_t padding = 0x1000; // default offset for nor
@@ -44,7 +44,7 @@ int main(int argc, char *argv[]){
                                strncpy(name,optarg,32);
                                break;
                        case 'o':
                                strncpy(name,optarg,32);
                                break;
                        case 'o':
-                               strncpy(fname,optarg,32);
+                               fname = optarg;
                                break;
                        case 'b':
                                bin = strtol(optarg, NULL, 0);
                                break;
                        case 'b':
                                bin = strtol(optarg, NULL, 0);
@@ -69,7 +69,9 @@ int main(int argc, char *argv[]){
                puts("Need an output file name.");
        if(!strnlen(name,32))
                puts("Need a flash config name.");
                puts("Need an output file name.");
        if(!strnlen(name,32))
                puts("Need a flash config name.");
-       if(!strnlen(name,32) || !strnlen(fname,32))
+       if(strnlen(name,32) == 32)
+               puts("Flash config name too long.");
+       if(!strnlen(name,32) || !strnlen(fname,32) || strnlen(name,32) == 32)
                help(-3);
 
        index = get_name_match(configs,name);
                help(-3);
 
        index = get_name_match(configs,name);
diff --git a/mk.sh b/mk.sh
index 64b77908fc80408aaa32e76961dae568b8ee8a04..3a0d800ceea82c8f0ff515d4dbfa50ffb2967eca 100755 (executable)
--- a/mk.sh
+++ b/mk.sh
@@ -1,2 +1,2 @@
 #!/usr/bin/bash
 #!/usr/bin/bash
-gcc -Wall imx-flashconf.c flash_confs.c -o imx-flashconf
\ No newline at end of file
+gcc -Wall imx-flashconf.c flash_confs.c -o imx-flashconf
This page took 0.029125 seconds and 4 git commands to generate.