diff mbox series

[1/5] hush: Print syntax error line with DEBUG_SHELL

Message ID 20210228234718.1208376-2-seanga2@gmail.com
State New
Delegated to: Tom Rini
Headers show
Series cmd: Add support for command substitution | expand

Commit Message

Sean Anderson Feb. 28, 2021, 11:47 p.m. UTC
This prints the filename (rather useless) and line (very useful) whenever a
syntax error occurs if DEBUG_SHELL is enabled.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 common/cli_hush.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Heinrich Schuchardt Feb. 28, 2021, 11:51 p.m. UTC | #1
Am 1. März 2021 00:47:14 MEZ schrieb Sean Anderson <seanga2@gmail.com>:
>This prints the filename (rather useless) and line (very useful)
>whenever a
>syntax error occurs if DEBUG_SHELL is enabled.

Please, use log_error() instead.

Best regards

Heinrich

>
>Signed-off-by: Sean Anderson <seanga2@gmail.com>
>---
>
> common/cli_hush.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
>diff --git a/common/cli_hush.c b/common/cli_hush.c
>index 1b9bef64b6..83329763c6 100644
>--- a/common/cli_hush.c
>+++ b/common/cli_hush.c
>@@ -372,15 +372,17 @@ static inline void debug_printf(const char
>*format, ...) { }
> #endif
> #define final_printf debug_printf
> 
>-#ifdef __U_BOOT__
>+#ifdef DEBUG_SHELL
>+static void __syntax(char *file, int line)
>+{
>+	error_msg("syntax error %s:%d\n", file, line);
>+}
>+
>+#define syntax_err() __syntax(__FILE__, __LINE__)
>+#else
> static void syntax_err(void) {
> 	 printf("syntax error\n");
> }
>-#else
>-static void __syntax(char *file, int line) {
>-	error_msg("syntax error %s:%d", file, line);
>-}
>-#define syntax() __syntax(__FILE__, __LINE__)
> #endif
> 
> #ifdef __U_BOOT__
Sean Anderson Feb. 28, 2021, 11:55 p.m. UTC | #2
On 2/28/21 6:51 PM, Heinrich Schuchardt wrote:
> Am 1. März 2021 00:47:14 MEZ schrieb Sean Anderson <seanga2@gmail.com>:
>> This prints the filename (rather useless) and line (very useful)
>> whenever a
>> syntax error occurs if DEBUG_SHELL is enabled.
> 
> Please, use log_error() instead.

The rest of this file uses DEBUG_SHELL already. This is done to reduce
the (torrent) of debugs which are only useful for someone debugging the
shell. If anything, this should be CONFIG_DEBUG_SHELL (and debug_printf
defined to log_debug with CONFIG_DEBUG_SHELL).

--Sean

> Best regards
> 
> Heinrich
> 
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> ---
>>
>> common/cli_hush.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/common/cli_hush.c b/common/cli_hush.c
>> index 1b9bef64b6..83329763c6 100644
>> --- a/common/cli_hush.c
>> +++ b/common/cli_hush.c
>> @@ -372,15 +372,17 @@ static inline void debug_printf(const char
>> *format, ...) { }
>> #endif
>> #define final_printf debug_printf
>>
>> -#ifdef __U_BOOT__
>> +#ifdef DEBUG_SHELL
>> +static void __syntax(char *file, int line)
>> +{
>> +	error_msg("syntax error %s:%d\n", file, line);
>> +}
>> +
>> +#define syntax_err() __syntax(__FILE__, __LINE__)
>> +#else
>> static void syntax_err(void) {
>> 	 printf("syntax error\n");
>> }
>> -#else
>> -static void __syntax(char *file, int line) {
>> -	error_msg("syntax error %s:%d", file, line);
>> -}
>> -#define syntax() __syntax(__FILE__, __LINE__)
>> #endif
>>
>> #ifdef __U_BOOT__
>
diff mbox series

Patch

diff --git a/common/cli_hush.c b/common/cli_hush.c
index 1b9bef64b6..83329763c6 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -372,15 +372,17 @@  static inline void debug_printf(const char *format, ...) { }
 #endif
 #define final_printf debug_printf
 
-#ifdef __U_BOOT__
+#ifdef DEBUG_SHELL
+static void __syntax(char *file, int line)
+{
+	error_msg("syntax error %s:%d\n", file, line);
+}
+
+#define syntax_err() __syntax(__FILE__, __LINE__)
+#else
 static void syntax_err(void) {
 	 printf("syntax error\n");
 }
-#else
-static void __syntax(char *file, int line) {
-	error_msg("syntax error %s:%d", file, line);
-}
-#define syntax() __syntax(__FILE__, __LINE__)
 #endif
 
 #ifdef __U_BOOT__