linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: linuxppc-dev@ozlabs.org
Cc: jdl@jdl.com
Subject: [DTC] small ftdump cleanup patch
Date: Thu, 3 Jan 2008 09:40:57 -0500	[thread overview]
Message-ID: <20080103144056.GB28644@windriver.com> (raw)

Here is a small patch to clean up the usage info and the error returns
for ftdump -- not sure what the future holds for ftdump vs. simply using
"dtc -I dtb -O dts someblob.dtb" ...

Paul.


diff --git a/ftdump.c b/ftdump.c
index 53343d7..49bc7cf 100644
--- a/ftdump.c
+++ b/ftdump.c
@@ -8,6 +8,8 @@
 #include <ctype.h>
 #include <netinet/in.h>
 #include <byteswap.h>
+#include <errno.h>
+#include <libgen.h>
 
 #include <fdt.h>
 
@@ -165,21 +167,22 @@ int main(int argc, char *argv[])
 	char buf[16384];	/* 16k max */
 	int size;
 
-	if (argc < 2) {
-		fprintf(stderr, "supply input filename\n");
-		return 5;
+	if (argc != 2) {
+		fprintf(stderr, "Usage: %s filename.dtb\n", basename(argv[0]));
+		fprintf(stderr, "\t-dump binary device tree blob contents.\n");
+		return EINVAL;
 	}
 
 	fp = fopen(argv[1], "rb");
 	if (fp == NULL) {
 		fprintf(stderr, "unable to open %s\n", argv[1]);
-		return 10;
+		return errno;
 	}
 
 	size = fread(buf, 1, sizeof(buf), fp);
 	if (size == sizeof(buf)) {	/* too large */
 		fprintf(stderr, "file too large\n");
-		return 10;
+		return EFBIG;
 	}
 
 	dump_blob(buf);

             reply	other threads:[~2008-01-03 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-03 14:40 Paul Gortmaker [this message]
2008-01-03 14:53 ` [DTC] small ftdump cleanup patch Jon Loeliger
2008-01-03 14:59   ` Paul Gortmaker
2008-01-03 23:25 ` David Gibson

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=20080103144056.GB28644@windriver.com \
    --to=paul.gortmaker@windriver.com \
    --cc=jdl@jdl.com \
    --cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).