From 885adeea79cf0936687c91d7220321ada1dcfbad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lo=C3=AFMinier?= Date: Mon, 14 Mar 2011 13:01:42 +0530 Subject: [PATCH] Add a die() macro to exit with an error message MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: LoïMinier Signed-off-by: Anand Gadiyar --- scripts/signGP.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/signGP.c b/scripts/signGP.c index ae3ddb8..d013592 100644 --- a/scripts/signGP.c +++ b/scripts/signGP.c @@ -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. */ -- 2.39.5