Skip to contentSkip to conversation

commands/led.c: fix return codes

PATCH In review Antony Pavlov 2 participants 3 messages Aug 2, 2011 – Aug 3, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commands/led.c: fix return codes

---
 commands/led.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
commands/led.c +4 -4
index 360ce7c..afb3fd3 100644
@@ -45,7 +45,7 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 					led->max_value);
 			i++;
 		}
-		return 0;
+		return COMMAND_SUCCESS;
 	}
 
 	if (argc != 3)
@@ -54,7 +54,7 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 	led = led_by_name_or_number(argv[1]);
 	if (!led) {
 		printf("no such LED: %s\n", argv[1]);
-		return 1;
+		return COMMAND_ERROR;
 	}
 
 	value = simple_strtoul(argv[optind + 1], NULL, 0);
@@ -62,10 +62,10 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 	ret = led_set(led, value);
 	if (ret < 0) {
 		perror("led");
-		return 1;
+		return COMMAND_ERROR;
 	}
 
-	return 0;
+	return COMMAND_SUCCESS;
 }
 
 /**
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

commands/led.c

Quoted 6 lines · Antony Pavlov
---
 commands/led.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
commands/led.c +0 -0

As of now noone uses the COMMAND_ERROR/COMMAND_SUCCESS macros. I'm not sure they are the way to go anyway. What I would rather like to see is that commands can return the standard error values, but this requires changes in hush.c (and the simple parser), because hush currently has its own (strange) way of interpreting return codes.

Sascha

Quoted 43 lines

index 360ce7c..afb3fd3 100644

commands/led.c +4 -4
@@ -45,7 +45,7 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 					led->max_value);
 			i++;
 		}
-		return 0;
+		return COMMAND_SUCCESS;
 	}
 
 	if (argc != 3)
@@ -54,7 +54,7 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 	led = led_by_name_or_number(argv[1]);
 	if (!led) {
 		printf("no such LED: %s\n", argv[1]);
-		return 1;
+		return COMMAND_ERROR;
 	}
 
 	value = simple_strtoul(argv[optind + 1], NULL, 0);
@@ -62,10 +62,10 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 	ret = led_set(led, value);
 	if (ret < 0) {
 		perror("led");
-		return 1;
+		return COMMAND_ERROR;
 	}
 
-	return 0;
+	return COMMAND_SUCCESS;
 }
 
 /**
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 1/1 commands/led.c: fix return code

---
 commands/led.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
commands/led.c +1 -1
index 7fd9d44..6bda797 100644
@@ -40,7 +40,7 @@ static int do_led(struct command *cmdtp, int argc, char *argv[])
 		led = led_by_number(i);
 		if (!led) {
 			printf("no registered LEDs\n");
-			return COMMAND_ERROR;
+			return 1;
 		}
 
 		printf("registered LEDs:\n");
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox