From patchwork Thu Sep 29 11:42:12 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: 610601 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp903027pvb; Thu, 29 Sep 2022 06:49:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5fzOaG8HFG6NrOjJd/13SMqiODrRIGGFe5EWLRMsjonZ4sL1L2Q0yvzXhOZk20aYqzvaB2 X-Received: by 2002:a05:622a:5cd:b0:35d:5de5:b1f1 with SMTP id d13-20020a05622a05cd00b0035d5de5b1f1mr2485286qtb.650.1664459385080; Thu, 29 Sep 2022 06:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664459385; cv=none; d=google.com; s=arc-20160816; b=X18vs4flMY34t/XnTvXpFAlgPpCOZp33wj1HYbXYmnNInm4ej0UBauYcYJJne0GHhU uSQAXbqURSDFmG7ZpAV8CI4UqGKbeSz4GLbEISFxL+F29rnfli+f0aa8P9tiKeemWIgv dOSAsO7VGwvkNQFrOoK8lDQJ0M+G8B4t57S9/EPKewuZ8KHeSBZCBpFioBb6TDMy9zM1 m5SPA11oSytc0JPjeUMQsjInrz90JjPszMVOobp22AbqmPuM0exRrbezlRnjtgCe/Wt6 yboJ+yFmUCicjzVtc7V3f4OuJFBPFJqBbx/WLbWyyVrJA4R+KKaglon+Oz5JFp35DCH6 4rhg== 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=7WPSIzCpU739utGIxIW8d/QKBIKYSf+S3FUKe5DP39M=; b=CM8b4fKD7yqEuV/lUUMyNq/wi1l/t0o08n8BAsMF7O+CZ/aW0Pa2TDWAX9ABBbePvY 0uWhzHTuD5tBkvJBPYRPOMCfu6XqsPQsM0JRZOWra123DgngFZZE2jyLxCqDBFRWRX5R kKA0k0Cyi3oLO1zOm5yl050p6e0pRiQWF3vGMsgZeJU7veyzgxwO5iLzMKNBrvrvwjnI 2nWO6xOc0d9B2HYcPCRW8K9rWgN213y050E7sYIpe6lcdzSYAcRs4E162M4CzmaLAlfY nt/kFlWEWYSPTF1fQ/B76+nAM2s5t5eUNMKkuKBri+MuoMlqxBFsEMz1YEMgTZd6KBKP 31JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ICUUs6O0; 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 f7-20020a05620a408700b006b4811cfa51si1523113qko.763.2022.09.29.06.49.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Sep 2022 06:49:45 -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=ICUUs6O0; 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]:39252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odtv6-0005DP-I3 for patch@linaro.org; Thu, 29 Sep 2022 09:49:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odsCx-0007Qx-RD for qemu-devel@nongnu.org; Thu, 29 Sep 2022 08:00:05 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:39451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odsCs-0004MK-NB for qemu-devel@nongnu.org; Thu, 29 Sep 2022 08:00:03 -0400 Received: by mail-wm1-x32d.google.com with SMTP id e10-20020a05600c4e4a00b003b4eff4ab2cso3077856wmq.4 for ; Thu, 29 Sep 2022 04:59:55 -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=7WPSIzCpU739utGIxIW8d/QKBIKYSf+S3FUKe5DP39M=; b=ICUUs6O0F4723C0e56t7Ti87SDrbHedabOP/kSuzG4i0ZkWT+PFqLnk6oReYZAI8+S bkcaeB06nEmP5RhU5Pf8htBKns4q0xEdZXjGW8KOvdJMUANQ+mlAiWe7pSCYLVCYT9UK oqIUx37iBlvPPrMjQX2eBYiDcQKh7o4k0WpKULQXaG3qoJhFleBpHjjejlMUqojCclIz jKyqDhOjJlT8d+b6yOhu/COHihQWGkbF9V7JMkefMFuk4+tghkyfYyriyXagiznc7So8 8omD5BxDWJJ/iPqD1bXthDARPEKZlflXSw+KbDypsaA0Sqxkd0xkwwcDKvyi67pPBnKw jazA== 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=7WPSIzCpU739utGIxIW8d/QKBIKYSf+S3FUKe5DP39M=; b=ZcbkxTfpJln0IgapHQQYDVgq39kAga9NpDdZQlg+zWyj91OmcYdCP3uZdIG9JQZRbH boofyB7eK32MFqI/r8c+5kyd+z83RMWprLl7MYNaoqpn9R149s/+PU/KXqHC8w3wZwXz xq5rsEWeh+ibivfs0LuVKOHMcQFQTnYJOkj9fV4+Yjrm/hgoZOGLstGNtru0rcQsbmp8 Q1zyTtrEmsLT4ukyAsWdyDZZPzpXz7K7EpiQH2nJZMun1O01/9NXMTmN8c4kcS4iH3iW VyCBeLzUW12KnfO10Wr11HdheG/nm1lUFw0Ug6nCP4zHz5Ne7PPnXOehYuY/H4+Zy8Wf SnHw== X-Gm-Message-State: ACrzQf0SlRo+/vIy7r0kJg3iI1q01Cofzd+P5Erfdl9jjAHv6EnmrznK GvbZfh8HbfxltMdFDeg6HLrhNA== X-Received: by 2002:a05:600c:2d05:b0:3b4:7788:9944 with SMTP id x5-20020a05600c2d0500b003b477889944mr10580826wmf.57.1664452793992; Thu, 29 Sep 2022 04:59:53 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id w11-20020adfd4cb000000b0022cd27bc8c1sm1918290wrk.9.2022.09.29.04.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 04:59:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 001C61FFD3; Thu, 29 Sep 2022 12:42:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: fam@euphon.net, berrange@redhat.com, f4bug@amsat.org, aurelien@aurel32.net, pbonzini@redhat.com, stefanha@redhat.com, crosa@redhat.com, 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=C3=A9e?= , Richard Henderson , Kevin Wolf , Markus Armbruster , Hanna Reitz , Mark Cave-Ayland , "Dr. David Alan Gilbert" , qemu-block@nongnu.org (open list:Block layer core), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PATCH v1 32/51] monitor: expose monitor_puts to rest of code Date: Thu, 29 Sep 2022 12:42:12 +0100 Message-Id: <20220929114231.583801-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220929114231.583801-1-alex.bennee@linaro.org> References: <20220929114231.583801-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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: Kevin Wolf Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220921160801.1490125-2-alex.bennee@linaro.org> --- 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;