* [DTC] small ftdump cleanup patch
@ 2008-01-03 14:40 Paul Gortmaker
2008-01-03 14:53 ` Jon Loeliger
2008-01-03 23:25 ` David Gibson
0 siblings, 2 replies; 4+ messages in thread
From: Paul Gortmaker @ 2008-01-03 14:40 UTC (permalink / raw)
To: linuxppc-dev; +Cc: jdl
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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [DTC] small ftdump cleanup patch
2008-01-03 14:40 [DTC] small ftdump cleanup patch Paul Gortmaker
@ 2008-01-03 14:53 ` Jon Loeliger
2008-01-03 14:59 ` Paul Gortmaker
2008-01-03 23:25 ` David Gibson
1 sibling, 1 reply; 4+ messages in thread
From: Jon Loeliger @ 2008-01-03 14:53 UTC (permalink / raw)
To: Paul Gortmaker; +Cc: linuxppc-dev
So, like, the other day Paul Gortmaker mumbled:
> 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.
Paul,
Any chance of a signed-off-by line?
Thanks,
jdl
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [DTC] small ftdump cleanup patch
2008-01-03 14:53 ` Jon Loeliger
@ 2008-01-03 14:59 ` Paul Gortmaker
0 siblings, 0 replies; 4+ messages in thread
From: Paul Gortmaker @ 2008-01-03 14:59 UTC (permalink / raw)
To: Jon Loeliger; +Cc: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 382 bytes --]
Jon Loeliger wrote:
> So, like, the other day Paul Gortmaker mumbled:
>
>> 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.
>>
>
> Paul,
>
> Any chance of a signed-off-by line?
>
Sure, here is the whole thing.
Paul.
[-- Attachment #2: 0001-ftdump-minor-usage-and-error-return-cleanup.txt --]
[-- Type: text/plain, Size: 1381 bytes --]
>From cef80fcd1efddaebcb366fb897430260cebb0c84 Mon Sep 17 00:00:00 2001
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Thu, 3 Jan 2008 09:56:09 -0500
Subject: [PATCH] ftdump: minor usage and error return cleanup
Improve the usage info and use standard error return values in ftdump.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
ftdump.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
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);
--
1.5.0.rc1.gf4b6c
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [DTC] small ftdump cleanup patch
2008-01-03 14:40 [DTC] small ftdump cleanup patch Paul Gortmaker
2008-01-03 14:53 ` Jon Loeliger
@ 2008-01-03 23:25 ` David Gibson
1 sibling, 0 replies; 4+ messages in thread
From: David Gibson @ 2008-01-03 23:25 UTC (permalink / raw)
To: Paul Gortmaker; +Cc: linuxppc-dev, jdl
On Thu, Jan 03, 2008 at 09:40:57AM -0500, Paul Gortmaker wrote:
> 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" ...
I expect ftdump to stay around for the forseeable future as a
hacking/debugging tool; the idea is that it will be able to tell you
at least something about a malformed or corrupted dtb, whereas dtc is
likely to choke before producing any output. Any non-debugging use is
likely a mistake, though.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-03 23:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 14:40 [DTC] small ftdump cleanup patch Paul Gortmaker
2008-01-03 14:53 ` Jon Loeliger
2008-01-03 14:59 ` Paul Gortmaker
2008-01-03 23:25 ` David Gibson
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).