Skip to contentSkip to conversation

dtc: Show the usage text if no parameter is passed

PATCH In review Fabio Estevam 3 participants 4 messages Oct 18, 2017 – Oct 19, 2017 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dtc: Show the usage text if no parameter is passed

From: Fabio Estevam <[email protected]>

When dtc is called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

---
 dtc.c | 2 ++
 1 file changed, 2 insertions(+)
dtc.c +2 -0
index 5ed873c..6308a63 100644
@@ -269,6 +269,8 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if (argc == 1)
+		usage(NULL);
 	if (argc > (optind+1))
 		usage("missing files");
 	else if (argc < (optind+1))
Signature · 1 line
2.7.4
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

When dtc is called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

I think it is valid to do:
dtc < in > out

This doesn't hang:

$ dtc < /dev/null
Error: <stdin>:0.0 syntax error
FATAL ERROR: Unable to parse input tree

The help though isn't clear that input file is optional.

Rob

#4 lore raw
In reply to a message not in the archive
Quoted 7 lines · Rob Herring
Quoted 5 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

When dtc is called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

Quoted 7 lines

I think it is valid to do:
dtc < in > out

This doesn't hang:

$ dtc < /dev/null
Error: <stdin>:0.0 syntax error
FATAL ERROR: Unable to parse input tree

These examples do not have argc == 1.

If 'dtc' is called with no arguments than the application never exits.

#6 lore raw
In reply to a message not in the archive
Quoted 11 lines · Fabio Estevam
Quoted 10 lines · Rob Herring
Quoted 5 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

When dtc is called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

I think it is valid to do:
dtc < in > out

Quoted 6 lines
Quoted 4 lines

This doesn't hang:

$ dtc < /dev/null
Error: <stdin>:0.0 syntax error
FATAL ERROR: Unable to parse input tree

These examples do not have argc == 1.

Yes they do. Everything after the < is processed by the shell and doesn't appear to dtc as a parameter.

Quoted 2 lines

If 'dtc' is called with no arguments than the application never exits.

If dtc is called with no arguments it attempts to read a dts from standard input and send a dtb to standard output. It exits when input finishes. So, if you press ^D after starting it, it will exit (with an error, because you haven't put in a valid dts).

Signature · 4 lines
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