Skip to contentSkip to conversation

aplay: Show usage if no parameter is passed

PATCH In review Fabio Estevam 2 participants 3 messages Nov 12, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 aplay: Show usage if no parameter is passed

From: Fabio Estevam <[email protected]>

When aplay/arecord are called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

---
 aplay/aplay.c |    5 +++++
 1 file changed, 5 insertions(+)
aplay/aplay.c +5 -0
index 741979a..9cc5063 100644
@@ -519,6 +519,11 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+	if (argc == 1) {
+		usage(command);
+		return 0;
+	}
+
 	chunk_size = -1;
 	rhwparams.format = DEFAULT_FORMAT;
 	rhwparams.rate = DEFAULT_SPEED;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 ac3dec: Show usage if no parameter is passed

From: Fabio Estevam <[email protected]>

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

Instead of hanging, print the usage and exit.

---
 ac3dec/ac3dec.c |    5 +++++
 1 file changed, 5 insertions(+)
ac3dec/ac3dec.c +5 -0
index 00c4f1a..f1423e3 100644
@@ -130,6 +130,11 @@ int main(int argc,char *argv[])
 	out_config.spdif = SPDIF_NONE;
 	out_config.hdmi = 0;
 
+	if (argc == 1) {
+		help();
+		return 0;
+	}
+
 	morehelp = 0;
 	while (1) {
 		int c;
Signature · 1 line
1.7.9.5
#2 lore raw
In reply to Fabio Estevam

aplay/aplay.c int main(int argc, char *argv[]) · line 525

Quoted 8 lines · Fabio Estevam

When aplay/arecord are called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

aplay/aplay.c +4 -0
+	if (argc == 1) {
+		usage(command);
+		return 0;
+	}

It's possible to call it with "aplay < somefile".
Better add a check like isatty(fileno(stdin)).

Regards,
Clemens