From patchwork Fri Jan 4 18:12:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1020864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=208.118.235.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43WY7M5smSz9s55 for ; Sat, 5 Jan 2019 05:23:11 +1100 (AEDT) Received: from localhost ([127.0.0.1]:38005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gfU7h-0004Jo-N8 for incoming@patchwork.ozlabs.org; Fri, 04 Jan 2019 13:23:09 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gfTxS-00021z-Dv for qemu-devel@nongnu.org; Fri, 04 Jan 2019 13:12:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gfTxQ-0003Au-68 for qemu-devel@nongnu.org; Fri, 04 Jan 2019 13:12:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38276) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gfTxP-0003AO-UM; Fri, 04 Jan 2019 13:12:32 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CD47637FF; Fri, 4 Jan 2019 18:12:31 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-119.brq.redhat.com [10.40.204.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E42965D9C6; Fri, 4 Jan 2019 18:12:25 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 4 Jan 2019 19:12:06 +0100 Message-Id: <20190104181208.7809-2-philmd@redhat.com> In-Reply-To: <20190104181208.7809-1-philmd@redhat.com> References: <20190104181208.7809-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 04 Jan 2019 18:12:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/3] util/cutils: Move size_to_str() from "qemu-common.h" to "cutils.h" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Thomas Huth , David Hildenbrand , qemu-trivial@nongnu.org, Cornelia Huck , Michael Roth , Markus Armbruster , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , David Gibson , Paolo Bonzini , Stefano Garzarella , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The size_to_str() function doesn't need to be in a generic header. It makes also sens to find this function in the same header than the opposite string to size functions: qemu_strtosz*(). Note than this function is already implemented in util/cutils.c. Since we introduce a new function in a header, we document it, using the previous comment from the source file. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Reviewed-by: David Gibson Reviewed-by: Stefano Garzarella Reviewed-by: Cornelia Huck --- include/qemu-common.h | 1 - include/qemu/cutils.h | 13 +++++++++++++ qapi/string-output-visitor.c | 2 +- util/cutils.c | 6 ------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index ed60ba251d..760527294f 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -153,7 +153,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 d2dad3057c..9ee40470e3 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -157,6 +157,19 @@ 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); +/** + * size_to_str: + * + * Return human readable string for size @val. + * Use IEC binary units like KiB, MiB, and so forth. + * + * @val: The value to format. + * Can be anything that uint64_t allows (no more than "16 EiB"). + * + * Caller is responsible for passing it to g_free(). + */ +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..edf268b373 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -11,9 +11,9 @@ */ #include "qemu/osdep.h" -#include "qemu-common.h" #include "qapi/string-output-visitor.h" #include "qapi/visitor-impl.h" +#include "qemu/cutils.h" #include "qemu/host-utils.h" #include #include "qemu/range.h" diff --git a/util/cutils.c b/util/cutils.c index e098debdc0..a8a3a3ba3b 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -816,12 +816,6 @@ const char *qemu_ether_ntoa(const MACAddr *mac) return ret; } -/* - * Return human readable string for size @val. - * @val can be anything that uint64_t allows (no more than "16 EiB"). - * Use IEC binary units like KiB, MiB, and so forth. - * Caller is responsible for passing it to g_free(). - */ char *size_to_str(uint64_t val) { static const char *suffixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" };