Add a die() macro to exit with an error message
authorLoïMinier <loic.minier@linaro.org>
Mon, 14 Mar 2011 07:31:42 +0000 (13:01 +0530)
committerAnand Gadiyar <gadiyar@ti.com>
Mon, 14 Mar 2011 08:22:28 +0000 (13:52 +0530)
Signed-off-by: LoïMinier <loic.minier@linaro.org>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
scripts/signGP.c

index ae3ddb8..d013592 100644 (file)
@@ -236,6 +236,8 @@ static struct ch_chsettings_nochram config_header
 #endif
 
 
+#define die(...) do { printf(__VA_ARGS__); exit(1); } while (0);
+
 int main(int argc, char *argv[])
 {
        int     i;
@@ -266,8 +268,7 @@ int main(int argc, char *argv[])
        /* Open the input file. */
        ifile = fopen(ifname, "rb");
        if (ifile == NULL) {
-               printf("Cannot open %s\n", ifname);
-               return 1;
+               die("Cannot open %s\n", ifname);
        }
 
        /* Get file length. */
@@ -277,9 +278,8 @@ int main(int argc, char *argv[])
        /* Open the output file and write it. */
        ofile = fopen(ofname, "wb");
        if (ofile == NULL) {
-               printf("Cannot open %s\n", ofname);
                fclose(ifile);
-               return 1;
+               die("Cannot open %s\n", ofname);
        }
 
        /* Pad 1 sector of zeroes. */