diff mbox

[08/13] error: don't set sep when print progname

Message ID 1382058681-14957-9-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia Oct. 18, 2013, 1:11 a.m. UTC
The behavior to set sep brings trouble to modification later,
the logic is not changed by add tailing space in fprintf().

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 util/qemu-error.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Comments

Paolo Bonzini Oct. 18, 2013, 9:43 a.m. UTC | #1
Il 18/10/2013 03:11, Wenchao Xia ha scritto:
> The behavior to set sep brings trouble to modification later,
> the logic is not changed by add tailing space in fprintf().
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  util/qemu-error.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/util/qemu-error.c b/util/qemu-error.c
> index 0ccd3e9..d1e858a 100644
> --- a/util/qemu-error.c
> +++ b/util/qemu-error.c
> @@ -161,8 +161,7 @@ static void error_print_loc(void)
>      const char *const *argp;
>  
>      if (!cur_mon && progname) {
> -        fprintf(stderr, "%s:", progname);
> -        sep = " ";
> +        fprintf(stderr, "%s: ", progname);
>      }
>      switch (cur_loc->kind) {
>      case LOC_CMDLINE:
> @@ -181,7 +180,7 @@ static void error_print_loc(void)
>          error_printf(" ");
>          break;
>      default:
> -        error_printf("%s", sep);
> +        break;
>      }
>  }
>  
> 

This changes behavior for LOC_FILE.

Before:

$ cat xyz.cfg
[device "abc"]
        driver = def
$ qemu-system-x86_64 -readconfig xyz.cfg
qemu-system-x86_64:xyz.cfg:2: parse error

After:

$ qemu-system-x86_64 -readconfig xyz.cfg
qemu-system-x86_64: xyz.cfg:2: parse error

Could even be an improvement, but you need to note it in the commit message.

Paolo
Markus Armbruster Oct. 18, 2013, 11:40 a.m. UTC | #2
Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 18/10/2013 03:11, Wenchao Xia ha scritto:
>> The behavior to set sep brings trouble to modification later,
>> the logic is not changed by add tailing space in fprintf().
>> 
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>  util/qemu-error.c |    5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/util/qemu-error.c b/util/qemu-error.c
>> index 0ccd3e9..d1e858a 100644
>> --- a/util/qemu-error.c
>> +++ b/util/qemu-error.c
>> @@ -161,8 +161,7 @@ static void error_print_loc(void)
>>      const char *const *argp;
>>  
>>      if (!cur_mon && progname) {
>> -        fprintf(stderr, "%s:", progname);
>> -        sep = " ";
>> +        fprintf(stderr, "%s: ", progname);
>>      }
>>      switch (cur_loc->kind) {
>>      case LOC_CMDLINE:
>> @@ -181,7 +180,7 @@ static void error_print_loc(void)
>>          error_printf(" ");
>>          break;
>>      default:
>> -        error_printf("%s", sep);
>> +        break;
>>      }
>>  }
>>  
>> 
>
> This changes behavior for LOC_FILE.
>
> Before:
>
> $ cat xyz.cfg
> [device "abc"]
>         driver = def
> $ qemu-system-x86_64 -readconfig xyz.cfg
> qemu-system-x86_64:xyz.cfg:2: parse error
>
> After:
>
> $ qemu-system-x86_64 -readconfig xyz.cfg
> qemu-system-x86_64: xyz.cfg:2: parse error
>
> Could even be an improvement, but you need to note it in the commit message.

No, it is not an improvement.  The old format matches exactly how other
report errors with location, e.g. jade.  Please leave it that way,
Wayne Xia Oct. 21, 2013, 3:31 a.m. UTC | #3
于 2013/10/18 19:40, Markus Armbruster 写道:
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
>> Il 18/10/2013 03:11, Wenchao Xia ha scritto:
>>> The behavior to set sep brings trouble to modification later,
>>> the logic is not changed by add tailing space in fprintf().
>>>
>>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>> ---
>>>  util/qemu-error.c |    5 ++---
>>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/util/qemu-error.c b/util/qemu-error.c
>>> index 0ccd3e9..d1e858a 100644
>>> --- a/util/qemu-error.c
>>> +++ b/util/qemu-error.c
>>> @@ -161,8 +161,7 @@ static void error_print_loc(void)
>>>      const char *const *argp;
>>>  
>>>      if (!cur_mon && progname) {
>>> -        fprintf(stderr, "%s:", progname);
>>> -        sep = " ";
>>> +        fprintf(stderr, "%s: ", progname);
>>>      }
>>>      switch (cur_loc->kind) {
>>>      case LOC_CMDLINE:
>>> @@ -181,7 +180,7 @@ static void error_print_loc(void)
>>>          error_printf(" ");
>>>          break;
>>>      default:
>>> -        error_printf("%s", sep);
>>> +        break;
>>>      }
>>>  }
>>>  
>>>
>> This changes behavior for LOC_FILE.
>>
>> Before:
>>
>> $ cat xyz.cfg
>> [device "abc"]
>>         driver = def
>> $ qemu-system-x86_64 -readconfig xyz.cfg
>> qemu-system-x86_64:xyz.cfg:2: parse error
>>
>> After:
>>
>> $ qemu-system-x86_64 -readconfig xyz.cfg
>> qemu-system-x86_64: xyz.cfg:2: parse error
>>
>> Could even be an improvement, but you need to note it in the commit message.
> No, it is not an improvement.  The old format matches exactly how other
> report errors with location, e.g. jade.  Please leave it that way,
>
I'll check whether there is way to leave the logic as it was.
diff mbox

Patch

diff --git a/util/qemu-error.c b/util/qemu-error.c
index 0ccd3e9..d1e858a 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -161,8 +161,7 @@  static void error_print_loc(void)
     const char *const *argp;
 
     if (!cur_mon && progname) {
-        fprintf(stderr, "%s:", progname);
-        sep = " ";
+        fprintf(stderr, "%s: ", progname);
     }
     switch (cur_loc->kind) {
     case LOC_CMDLINE:
@@ -181,7 +180,7 @@  static void error_print_loc(void)
         error_printf(" ");
         break;
     default:
-        error_printf("%s", sep);
+        break;
     }
 }