* [Qemu-devel] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h"
@ 2019-09-03 12:05 Philippe Mathieu-Daudé
2019-09-03 18:57 ` [Qemu-devel] [Qemu-block] " John Snow
2019-09-19 9:57 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
0 siblings, 2 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-09-03 12:05 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, qemu-block, qemu-trivial, Markus Armbruster,
Philippe Mathieu-Daudé,
Michael Roth, Peter Xu, Max Reitz
"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é <philmd@redhat.com>
---
There are only 5 users, is it worthwhile renaming it qemu_sztostrt()?
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
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(-)
diff --git a/block/qapi.c b/block/qapi.c
index 15f1030264..7ee2ee065d 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -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"
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 0235cd3b91..8d84db90b0 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -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
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 12301340a4..b54c847e0f 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -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")
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 7ab64468d9..0d93605d77 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -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"
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h"
2019-09-03 12:05 [Qemu-devel] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h" Philippe Mathieu-Daudé
@ 2019-09-03 18:57 ` John Snow
2019-09-04 2:16 ` Peter Xu
2019-09-19 9:57 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
1 sibling, 1 reply; 4+ messages in thread
From: John Snow @ 2019-09-03 18:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Kevin Wolf, qemu-block, qemu-trivial, Markus Armbruster,
Peter Xu, Michael Roth, Max Reitz
On 9/3/19 8:05 AM, Philippe Mathieu-Daudé wrote:
> "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é <philmd@redhat.com>
> ---
> There are only 5 users, is it worthwhile renaming it qemu_sztostrt()?
(On the other hand, "size_to_str" is easy to read and "sztostrt" looks
like someone sneezed with their hand on the keyboard.)
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> 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(-)
>
> diff --git a/block/qapi.c b/block/qapi.c
> index 15f1030264..7ee2ee065d 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -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.
Reviewed-by: John Snow <jsnow@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h"
2019-09-03 18:57 ` [Qemu-devel] [Qemu-block] " John Snow
@ 2019-09-04 2:16 ` Peter Xu
0 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2019-09-04 2:16 UTC (permalink / raw)
To: John Snow
Cc: Kevin Wolf, Michael Roth, qemu-block, qemu-trivial, qemu-devel,
Markus Armbruster, Max Reitz, Philippe Mathieu-Daudé
On Tue, Sep 03, 2019 at 02:57:31PM -0400, John Snow wrote:
[...]
> Seems proper. It must be an oversight to begin with that we declared it
> in qemu-common but defined it in cutils.
Porbably true..
>
> Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Thanks,
--
Peter Xu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h"
2019-09-03 12:05 [Qemu-devel] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h" Philippe Mathieu-Daudé
2019-09-03 18:57 ` [Qemu-devel] [Qemu-block] " John Snow
@ 2019-09-19 9:57 ` Laurent Vivier
1 sibling, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2019-09-19 9:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Kevin Wolf, qemu-block, qemu-trivial, Markus Armbruster,
Peter Xu, Max Reitz
Le 03/09/2019 à 14:05, Philippe Mathieu-Daudé a écrit :
> "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é <philmd@redhat.com>
> ---
> There are only 5 users, is it worthwhile renaming it qemu_sztostrt()?
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> 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(-)
>
> diff --git a/block/qapi.c b/block/qapi.c
> index 15f1030264..7ee2ee065d 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -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"
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 0235cd3b91..8d84db90b0 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -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
> diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
> index 12301340a4..b54c847e0f 100644
> --- a/include/qemu/cutils.h
> +++ b/include/qemu/cutils.h
> @@ -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")
>
> diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
> index 7ab64468d9..0d93605d77 100644
> --- a/qapi/string-output-visitor.c
> +++ b/qapi/string-output-visitor.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-19 9:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03 12:05 [Qemu-devel] [PATCH] cutils: Move size_to_str() from "qemu-common.h" to "qemu/cutils.h" Philippe Mathieu-Daudé
2019-09-03 18:57 ` [Qemu-devel] [Qemu-block] " John Snow
2019-09-04 2:16 ` Peter Xu
2019-09-19 9:57 ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
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).