public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [PATCH i-g-t 3/3] tools/intel_bios_reader: print errors to stderr, return EXIT_FAILURE
Date: Thu, 12 May 2016 15:38:00 +0300	[thread overview]
Message-ID: <1463056680-6642-3-git-send-email-jani.nikula@intel.com> (raw)
In-Reply-To: <1463056680-6642-1-git-send-email-jani.nikula@intel.com>

Be consistent with exit status and printing errors to stderr.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 59a90e234582..4c4ab666fc55 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -101,7 +101,7 @@ static struct bdb_block *find_section(struct context *context, int section_id)
 	block = malloc(sizeof(*block));
 	if (!block) {
 		fprintf(stderr, "out of memory\n");
-		exit(-1);
+		exit(EXIT_FAILURE);
 	}
 
 	/* walk the sections looking for section_id */
@@ -1551,14 +1551,15 @@ int main(int argc, char **argv)
 
 	fd = open(filename, O_RDONLY);
 	if (fd == -1) {
-		printf("Couldn't open \"%s\": %s\n", filename, strerror(errno));
-		return 1;
+		fprintf(stderr, "Couldn't open \"%s\": %s\n",
+			filename, strerror(errno));
+		return EXIT_FAILURE;
 	}
 
 	if (stat(filename, &finfo)) {
-		printf("failed to stat \"%s\": %s\n", filename,
-		       strerror(errno));
-		return 1;
+		fprintf(stderr, "Failed to stat \"%s\": %s\n",
+			filename, strerror(errno));
+		return EXIT_FAILURE;
 	}
 	size = finfo.st_size;
 
@@ -1568,9 +1569,9 @@ int main(int argc, char **argv)
 		VBIOS = malloc (size);
 		while ((ret = read(fd, VBIOS + len, size - len))) {
 			if (ret < 0) {
-				printf("failed to read \"%s\": %s\n", filename,
-				       strerror(errno));
-				return 1;
+				fprintf(stderr, "Failed to read \"%s\": %s\n",
+					filename, strerror(errno));
+				return EXIT_FAILURE;
 			}
 
 			len += ret;
@@ -1582,8 +1583,9 @@ int main(int argc, char **argv)
 	} else {
 		VBIOS = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
 		if (VBIOS == MAP_FAILED) {
-			printf("failed to map \"%s\": %s\n", filename, strerror(errno));
-			return 1;
+			fprintf(stderr, "Failed to map \"%s\": %s\n",
+				filename, strerror(errno));
+			return EXIT_FAILURE;
 		}
 	}
 
@@ -1597,14 +1599,14 @@ int main(int argc, char **argv)
 	}
 
 	if (!vbt) {
-		printf("VBT signature missing\n");
-		return 1;
+		fprintf(stderr, "VBT signature missing\n");
+		return EXIT_FAILURE;
 	}
 
 	bdb_off = vbt_off + vbt->bdb_offset;
 	if (bdb_off >= size - sizeof(struct bdb_header)) {
-		printf("Invalid VBT found, BDB points beyond end of data block\n");
-		return 1;
+		fprintf(stderr, "Invalid VBT found, BDB points beyond end of data block\n");
+		return EXIT_FAILURE;
 	}
 
 	context.vbt = vbt;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-05-12 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 12:37 [PATCH i-g-t 1/3] tools/intel_bios_reader: abstract header information dumping Jani Nikula
2016-05-12 12:37 ` [PATCH i-g-t 2/3] tools/intel_bios_reader: clean up VBT/BDB header dumping Jani Nikula
2016-05-12 12:38 ` Jani Nikula [this message]
2016-05-13 13:52 ` [PATCH i-g-t 1/3] tools/intel_bios_reader: abstract header information dumping Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463056680-6642-3-git-send-email-jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox