cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h"
PATCH 1/1 cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h"
"qemu/cutils.h" contains various qemu_strtosz_*() functions useful to convert strings to size. It seems natural to have the opposite usage (from size to string) there too.
The function definition is already in util/cutils.c.
---
There are only 5 users, is it worthwhile renaming it qemu_sztostrt()?
--- block/qapi.c | 2 +- include/qemu-common.h | 1 - include/qemu/cutils.h | 2 ++ qapi/string-output-visitor.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-)
block/qapi.c +1 -1
@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/cutils.h" #include "block/qapi.h" #include "block/block_int.h" #include "block/throttle-groups.h"
include/qemu-common.h +0 -1
@@ -123,7 +123,6 @@ void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);int parse_debug_env (const char *name,int max,int initial);const char *qemu_ether_ntoa (const MACAddr *mac); -char *size_to_str (uint64_t val);void page_size_init (void );/* returns non-zero if dump is in progress, otherwise zero is
include/qemu/cutils.h +2 -0
@@ -155,6 +155,8 @@ int qemu_strtosz(const char *nptr, const char **end, uint64_t *result);int qemu_strtosz_MiB (const char *nptr,const char **end,uint64_t *result);int qemu_strtosz_metric (const char *nptr,const char **end,uint64_t *result); +char *size_to_str (uint64_t val); +/* used to print char* safely */ #define STR_OR_NULL (str) ((str) ? (str) : "null")
qapi/string-output-visitor.c +1 -1
@@ -11,7 +11,7 @@*/ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/cutils.h" #include "qapi/string-output-visitor.h" #include "qapi/visitor-impl.h" #include "qemu/host-utils.h"
Signature · 1 line
2.20.1
Quoted 9 lines · Philippe Mathieu-Daudé
"
qemu/cutils.h" contains various qemu_strtosz_*() functions useful to convert strings to size. It seems natural to have the opposite usage (from size to string) there too.The function definition is already in
util/cutils.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
There are only 5 users, is it worthwhile renaming itqemu_sztostrt()?
(On the other hand, "size_to_str" is easy to read and "sztostrt" looks like someone sneezed with their hand on the keyboard.)
Quoted 13 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- block/qapi.c | 2 +- include/qemu-common.h | 1 - include/qemu/cutils.h | 2 ++ qapi/string-output-visitor.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-)block/qapi.c +0
-0
block/qapi.c line 26
Quoted 5 lines
block/qapi.c +1
-1@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/cutils.h"
I guess that's a more targeted inclusion. (That was the last thing we needed in there?)
Seems proper. It must be an oversight to begin with that we declared it in qemu-common but defined it in cutils.
Peter Xu
Reviewed-byOn Tue, Sep 03, 2019 at 02:57:31PM -0400, John Snow wrote:
[...]
Quoted 2 lines
Seems proper. It must be an oversight to begin with that we declared it in qemu-common but defined it in cutils.
Porbably true..
Quoted 2 lines
Reviewed-by John Snow <[email protected]>
Thanks,
Signature · 1 line
Peter Xu
Laurent Vivier
AppliedLe 03/09/2019 à 14:05, Philippe Mathieu-Daudé a écrit :
Quoted 61 lines
"
qemu/cutils.h" contains various qemu_strtosz_*() functions useful to convert strings to size. It seems natural to have the opposite usage (from size to string) there too.The function definition is already in
util/cutils.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
There are only 5 users, is it worthwhile renaming itqemu_sztostrt()?Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- block/qapi.c | 2 +- include/qemu-common.h | 1 - include/qemu/cutils.h | 2 ++ qapi/string-output-visitor.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-)block/qapi.c +1
-1@@ -23,7 +23,7 @@*/ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/cutils.h" #include "block/qapi.h" #include "block/block_int.h" #include "block/throttle-groups.h" include/qemu-common.h +0
-1@@ -123,7 +123,6 @@ void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);int parse_debug_env (const char *name,int max,int initial);const char *qemu_ether_ntoa (const MACAddr *mac); -char *size_to_str (uint64_t val);void page_size_init (void );/* returns non-zero if dump is in progress, otherwise zero is include/qemu/cutils.h +2
-0@@ -155,6 +155,8 @@ int qemu_strtosz(const char *nptr, const char **end, uint64_t *result);int qemu_strtosz_MiB (const char *nptr,const char **end,uint64_t *result);int qemu_strtosz_metric (const char *nptr,const char **end,uint64_t *result); +char *size_to_str (uint64_t val); +/* used to print char* safely */ #define STR_OR_NULL (str) ((str) ? (str) : "null")qapi/string-output-visitor.c +0
-0
qapi/string-output-visitor.c line 17
Quoted 8 lines
qapi/string-output-visitor.c +1
-1@@ -11,7 +11,7 @@*/ #include "qemu/osdep.h" -#include "qemu-common.h" +#include "qemu/cutils.h" #include "qapi/string-output-visitor.h" #include "qapi/visitor-impl.h" #include "qemu/host-utils.h"
Applied to my trivial-patches branch.
Thanks,
Laurent