From patchwork Wed Sep 21 16:07:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607955 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2479387pvb; Wed, 21 Sep 2022 09:13:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jmhlX9XgiLteBDjKh1tbLBH322nTsEx1OMJ2I9NvIjAPTwXdAhnZMtO5sFy8Dt3Xrcbam X-Received: by 2002:a05:622a:4d2:b0:35c:ffc8:93a5 with SMTP id q18-20020a05622a04d200b0035cffc893a5mr5982694qtx.426.1663776791521; Wed, 21 Sep 2022 09:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663776791; cv=none; d=google.com; s=arc-20160816; b=cA0+/HGBakkdF5TdlG5F4eupTH+O+lEpe7dcydJsdwmigvVV0wBjbwDzDERSRoZtDO SroIBu1agiBqhgH5fsg5+aoSB4bSyyqbaYaPSnmpIG0xI7bQ7uSoG5H1PUQ4eW3odrha kngmnQ+TYkyshpYiNf4nTRLXdw4P9ScO6XWTim3YNouUEbsD8QmkWIm1iKfw7Kb2gBvr yyQzvuXDMec1a8HQtl3xBFffP0tM9YBzWwzsq6e8yMeDr6fvwoo5HAUggqILCUToUybr /tf5KofpILH9ddkUKrzV+uzs2ySahCPK0kDErqSpgS13RYSiFPEKEq/3Yw/3fkkSfyon 4Ugg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=TA8Yj6CZvSyA14aXYOCoSRvt8qr7ymU4fyatZFIWtTeSbeuUbjC0Guc3GQ5JHRrfOf YSEt2jP3Mk2Gkpx1GjLDM3yuglnB3doJHbEs3k/c3jgIbY7hiBe0FVvTDHb9iZMHXk1/ Kxbz8DMvdzcPOUQCzfXIFRnDRc4CpIx8ozPeXJPoL3dbOgc7GpL0dycxJuNUXiQxIMsZ ZCdKmmlMcY3SCyADJw4IgZZrpdYztK376lTozGleJLjRd5Xc0Tkafat3A3ZqUakkAJ8I Girl4JE6EZ8/OU+qs7AyorAUIWHRVGHUL+pJNHYJ87AAXL+CqmA3f+l0IKnHhxJ7dPvy x9LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nFovbVLe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gm7-20020a056214268700b0047962d5ee41si2057673qvb.20.2022.09.21.09.13.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:13:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nFovbVLe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2LX-00022X-0w for patch@linaro.org; Wed, 21 Sep 2022 12:13:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gf-0003CN-4M for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:09 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:38556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gc-0000bz-Td for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:08 -0400 Received: by mail-wm1-x336.google.com with SMTP id h130-20020a1c2188000000b003b4cadadce7so8115336wmh.3 for ; Wed, 21 Sep 2022 09:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=nFovbVLeQ0CpUgz3+0ZZmlctw68fEUENHUHoV2c7/XVCS9EX2Y2mnkoYN650CgtPuM 3aeYxDlaBZFEMkRfdRerP7avReFugQ1mE9J5+xhimBAEJvFRH6na6gGVSqhSoq5sdl11 L1/tVid2jDEuhiMGq3Gj1l6vqitPxOEcJCOiJE1zG4u3e2SdU5GnHYH+sV6+rRmXQ9f1 Tj04x0fTHhS8foMhDri8ioEkQHh6L0CQfM1RpatGX9plCKDEc5jrdDMc1Rt7LwpfbxB4 l/XpXCW0//k6/Q0PavPmZRbLaoFbtcfGKXPgvYhORYMm62JQ5MqX/RMzxePgrNXiRAvu 8Gpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=XLwZpqus2aRfJDRzTRO/Ahj6g1yNk3fYZaKnL6LXvPV5QivAKNWARNdFXUIFAw3GQX 5gOnzXVbft0Gnoxz9kXAq5ik22xTadLZK70Tx99yj50mZM4p24JWdXF2n+Y+rNgJhx9W 0khWP6lDaNWHt3PV0vG8stuyi1zHm3sCNGtG6nZC3syj20BS+rN9BBA7Mimjj3X/CZk4 Dya+v37g7hQY4kRa24k7MCQjRZUjdWnxiKQr1ANAkti2bC8M2Hq++19DGn+s4CjtbV9b sVB54n70Y1dypAfKIx09pzIfxpjRghkyFKMJEunuCDrPN05kXMYLizLN4WEGVoA2GKoB pzIQ== X-Gm-Message-State: ACrzQf0WOV8uptzqv4ZDvfFe7b6RvNCeO2qZsVx6C3+v7E/HpduoeBLp uGOSAeyA+8U1wTqcRMk1C2c7YA== X-Received: by 2002:a7b:c8d5:0:b0:3b4:76bc:5dae with SMTP id f21-20020a7bc8d5000000b003b476bc5daemr6514563wml.122.1663776483266; Wed, 21 Sep 2022 09:08:03 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id w12-20020a05600c474c00b003a5f3f5883dsm3367007wmo.17.2022.09.21.09.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:02 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 421BA1FFB8; Wed, 21 Sep 2022 17:08:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Richard Henderson , Kevin Wolf , Hanna Reitz , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-block@nongnu.org (open list:Block layer core), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PATCH v1 01/10] monitor: expose monitor_puts to rest of code Date: Wed, 21 Sep 2022 17:07:52 +0100 Message-Id: <20220921160801.1490125-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This helps us construct strings elsewhere before echoing to the monitor. It avoids having to jump through hoops like: monitor_printf(mon, "%s", s->str); It will be useful in following patches but for now convert all existing plain "%s" printfs to use the _puts api. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf --- v2 - s/monitor_printf(mon, "%s"/monitor_puts(mon, / --- docs/devel/writing-monitor-commands.rst | 2 +- include/monitor/monitor.h | 1 + monitor/monitor-internal.h | 1 - block/monitor/block-hmp-cmds.c | 10 +++++----- hw/misc/mos6522.c | 2 +- monitor/hmp-cmds.c | 8 ++++---- monitor/hmp.c | 2 +- target/i386/helper.c | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-monitor-commands.rst index 4aa2bb904d..2fefedcd98 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -716,7 +716,7 @@ message. Here's the implementation of the "info roms" HMP command:: if (hmp_handle_error(mon, err)) { return; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } Also, you have to add the function's prototype to the hmp.h file. diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index a4b40e8391..737e750670 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -31,6 +31,7 @@ void monitor_resume(Monitor *mon); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); +int monitor_puts(Monitor *mon, const char *str); int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3); diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index caa2e90ef2..a2cdbbf646 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -174,7 +174,6 @@ extern int mon_refcount; extern HMPCommand hmp_cmds[]; -int monitor_puts(Monitor *mon, const char *str); void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush, bool use_io_thread); void monitor_data_destroy(Monitor *mon); diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index bfb3c043a0..939a520d17 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -638,16 +638,16 @@ static void print_block_info(Monitor *mon, BlockInfo *info, assert(!info || !info->has_inserted || info->inserted == inserted); if (info && *info->device) { - monitor_printf(mon, "%s", info->device); + monitor_puts(mon, info->device); if (inserted && inserted->has_node_name) { monitor_printf(mon, " (%s)", inserted->node_name); } } else { assert(info || inserted); - monitor_printf(mon, "%s", - inserted && inserted->has_node_name ? inserted->node_name - : info && info->has_qdev ? info->qdev - : ""); + monitor_puts(mon, + inserted && inserted->has_node_name ? inserted->node_name + : info && info->has_qdev ? info->qdev + : ""); } if (inserted) { diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index f9e646350e..fe38c44426 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -595,7 +595,7 @@ void hmp_info_via(Monitor *mon, const QDict *qdict) if (hmp_handle_error(mon, err)) { return; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } static const MemoryRegionOps mos6522_ops = { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c6cd6f91dd..f90eea8d01 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -730,7 +730,7 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) monitor_printf(mon, " "); if (dev->class_info->has_desc) { - monitor_printf(mon, "%s", dev->class_info->desc); + monitor_puts(mon, dev->class_info->desc); } else { monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class); } @@ -2258,12 +2258,12 @@ static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value) if (unit && value->base == 10 && value->exponent >= -18 && value->exponent <= 18 && value->exponent % 3 == 0) { - monitor_printf(mon, "%s", si_prefix(value->exponent)); + monitor_puts(mon, si_prefix(value->exponent)); } else if (unit && value->base == 2 && value->exponent >= 0 && value->exponent <= 60 && value->exponent % 10 == 0) { - monitor_printf(mon, "%s", iec_binary_prefix(value->exponent)); + monitor_puts(mon, iec_binary_prefix(value->exponent)); } else if (value->exponent) { /* Use exponential notation and write the unit's English name */ monitor_printf(mon, "* %d^%d%s", @@ -2273,7 +2273,7 @@ static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value) } if (value->has_unit) { - monitor_printf(mon, "%s", unit ? unit : StatsUnit_str(value->unit)); + monitor_puts(mon, unit ? unit : StatsUnit_str(value->unit)); } /* Print bucket size for linear histograms */ diff --git a/monitor/hmp.c b/monitor/hmp.c index a3375d0341..43fd69f984 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1094,7 +1094,7 @@ static void hmp_info_human_readable_text(Monitor *mon, return; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } static void handle_hmp_command_exec(Monitor *mon, diff --git a/target/i386/helper.c b/target/i386/helper.c index fa409e9c44..b954ccda50 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -415,7 +415,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) if (need_reset) { emit_guest_memory_failure(MEMORY_FAILURE_ACTION_RESET, ar, recursive); - monitor_printf(params->mon, "%s", msg); + monitor_puts(params->mon, msg); qemu_log_mask(CPU_LOG_RESET, "%s\n", msg); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); return;