qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vl: Print maxmem in hex format for error message
@ 2014-09-16  2:36 zhanghailiang
  2014-09-16  2:42 ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: zhanghailiang @ 2014-09-16  2:36 UTC (permalink / raw)
  To: qemu-trivial; +Cc: zhanghailiang, luonengjun, qemu-devel, peter.huangpeng

In error message, maxmem is printed in Dec but ram_size in Hex.
It is better to print them in same format.
Also use error_report instead of fprintf.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 vl.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/vl.c b/vl.c
index 5db0d08..ea60f93 100644
--- a/vl.c
+++ b/vl.c
@@ -3358,34 +3358,34 @@ int main(int argc, char **argv, char **envp)
 
                     sz = qemu_opt_get_size(opts, "maxmem", 0);
                     if (sz < ram_size) {
-                        fprintf(stderr, "qemu: invalid -m option value: maxmem "
-                                "(%" PRIu64 ") <= initial memory ("
-                                RAM_ADDR_FMT ")\n", sz, ram_size);
+                        error_report("qemu: invalid -m option value: maxmem "
+                                "(0x%" PRIx64 ") <= initial memory (0x"
+                                RAM_ADDR_FMT ")", sz, ram_size);
                         exit(EXIT_FAILURE);
                     }
 
                     slots = qemu_opt_get_number(opts, "slots", 0);
                     if ((sz > ram_size) && !slots) {
-                        fprintf(stderr, "qemu: invalid -m option value: maxmem "
-                                "(%" PRIu64 ") more than initial memory ("
+                        error_report("qemu: invalid -m option value: maxmem "
+                                "(0x%" PRIx64 ") more than initial memory (0x"
                                 RAM_ADDR_FMT ") but no hotplug slots where "
-                                "specified\n", sz, ram_size);
+                                "specified", sz, ram_size);
                         exit(EXIT_FAILURE);
                     }
 
                     if ((sz <= ram_size) && slots) {
-                        fprintf(stderr, "qemu: invalid -m option value:  %"
+                        error_report("qemu: invalid -m option value:  %"
                                 PRIu64 " hotplug slots where specified but "
-                                "maxmem (%" PRIu64 ") <= initial memory ("
-                                RAM_ADDR_FMT ")\n", slots, sz, ram_size);
+                                "maxmem (0x%" PRIx64 ") <= initial memory (0x"
+                                RAM_ADDR_FMT ")", slots, sz, ram_size);
                         exit(EXIT_FAILURE);
                     }
                     maxram_size = sz;
                     ram_slots = slots;
                 } else if ((!maxmem_str && slots_str) ||
                            (maxmem_str && !slots_str)) {
-                    fprintf(stderr, "qemu: invalid -m option value: missing "
-                            "'%s' option\n", slots_str ? "maxmem" : "slots");
+                     error_report("qemu: invalid -m option value: missing "
+                            "'%s' option", slots_str ? "maxmem" : "slots");
                     exit(EXIT_FAILURE);
                 }
                 break;
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: Print maxmem in hex format for error message
  2014-09-16  2:36 [Qemu-devel] [PATCH] vl: Print maxmem in hex format for error message zhanghailiang
@ 2014-09-16  2:42 ` Eric Blake
  2014-09-16  2:51   ` zhanghailiang
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2014-09-16  2:42 UTC (permalink / raw)
  To: zhanghailiang, qemu-trivial; +Cc: luonengjun, qemu-devel, peter.huangpeng

[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]

On 09/15/2014 08:36 PM, zhanghailiang wrote:
> In error message, maxmem is printed in Dec but ram_size in Hex.
> It is better to print them in same format.
> Also use error_report instead of fprintf.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>  vl.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 5db0d08..ea60f93 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3358,34 +3358,34 @@ int main(int argc, char **argv, char **envp)
>  
>                      sz = qemu_opt_get_size(opts, "maxmem", 0);
>                      if (sz < ram_size) {
> -                        fprintf(stderr, "qemu: invalid -m option value: maxmem "
> -                                "(%" PRIu64 ") <= initial memory ("
> -                                RAM_ADDR_FMT ")\n", sz, ram_size);
> +                        error_report("qemu: invalid -m option value: maxmem "
> +                                "(0x%" PRIx64 ") <= initial memory (0x"
> +                                RAM_ADDR_FMT ")", sz, ram_size);
>                          exit(EXIT_FAILURE);
>                      }
>  
>                      slots = qemu_opt_get_number(opts, "slots", 0);
>                      if ((sz > ram_size) && !slots) {
> -                        fprintf(stderr, "qemu: invalid -m option value: maxmem "
> -                                "(%" PRIu64 ") more than initial memory ("
> +                        error_report("qemu: invalid -m option value: maxmem "

doesn't error_report already prepend  a variation of "qemu", making your
"qemu: " redundant?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: Print maxmem in hex format for error message
  2014-09-16  2:42 ` Eric Blake
@ 2014-09-16  2:51   ` zhanghailiang
  0 siblings, 0 replies; 3+ messages in thread
From: zhanghailiang @ 2014-09-16  2:51 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-trivial, luonengjun, qemu-devel, peter.huangpeng

On 2014/9/16 10:42, Eric Blake wrote:
> On 09/15/2014 08:36 PM, zhanghailiang wrote:
>> In error message, maxmem is printed in Dec but ram_size in Hex.
>> It is better to print them in same format.
>> Also use error_report instead of fprintf.
>>
>> Signed-off-by: zhanghailiang<zhang.zhanghailiang@huawei.com>
>> ---
>>   vl.c | 22 +++++++++++-----------
>>   1 file changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 5db0d08..ea60f93 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -3358,34 +3358,34 @@ int main(int argc, char **argv, char **envp)
>>
>>                       sz = qemu_opt_get_size(opts, "maxmem", 0);
>>                       if (sz<  ram_size) {
>> -                        fprintf(stderr, "qemu: invalid -m option value: maxmem "
>> -                                "(%" PRIu64 ")<= initial memory ("
>> -                                RAM_ADDR_FMT ")\n", sz, ram_size);
>> +                        error_report("qemu: invalid -m option value: maxmem "
>> +                                "(0x%" PRIx64 ")<= initial memory (0x"
>> +                                RAM_ADDR_FMT ")", sz, ram_size);
>>                           exit(EXIT_FAILURE);
>>                       }
>>
>>                       slots = qemu_opt_get_number(opts, "slots", 0);
>>                       if ((sz>  ram_size)&&  !slots) {
>> -                        fprintf(stderr, "qemu: invalid -m option value: maxmem "
>> -                                "(%" PRIu64 ") more than initial memory ("
>> +                        error_report("qemu: invalid -m option value: maxmem "
>
> doesn't error_report already prepend  a variation of "qemu", making your
> "qemu: " redundant?
>

Yes, you are right, i will remove them, thanks;)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-16  2:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-16  2:36 [Qemu-devel] [PATCH] vl: Print maxmem in hex format for error message zhanghailiang
2014-09-16  2:42 ` Eric Blake
2014-09-16  2:51   ` zhanghailiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).