From patchwork Fri Aug 19 15:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598503 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1499767mae; Fri, 19 Aug 2022 08:44:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR6hJP1aNQYMrFVCXNtTZtQ2R9cdO2wENL4Mpw42sMSGHRvwyBH4yAya6FH9RKAClWmYbKg4 X-Received: by 2002:a05:6214:20cb:b0:496:ae67:2121 with SMTP id 11-20020a05621420cb00b00496ae672121mr6834408qve.95.1660923843171; Fri, 19 Aug 2022 08:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923843; cv=none; d=google.com; s=arc-20160816; b=ar/fnajKTJa5ggL0Wn6Ai9sAKxPp+VQr2LKe6g5FnUmyL/geDJigkSp4qNWUS/N1VV VPNH1O4J6wA9LX4UsMkrf7Wzw1CKHORgnTl0bBpIzQcuWK7zSy1BwvS74aZsGmcjW+i/ A13lVIbXXnUgo2yn/t5KwKvjQinTukrbWICWS7X5t/pee/1uGDkDdN1zQd27sOQ59Agz tT20WAxOWBTOuULMLZtXvyJaQLSzWjAyA2fIS1H4fvXl0Ifl6OaWBJZzL2NI365EPncS dC0SK3RSCuOcp4KLpKwiadI1VMzZuaNZAeuhs8diM0qsb4bOWzLtFiqMCLr7PT0SyGG3 SPYg== 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=Xeh2vqFOTw5s3hqoNhblRj1bcX1xyzRqQ8DX799pYws=; b=dRL7aUye/azBke57AmrFYLNzcU5gTtb7JQ5+98ZtjccfTapRTxOl6SltUmRDzVtk9k L+I4xP51KfHfoEFzyVqzHGOAi/tmwsUh7q8Z7LvCgRiYxb7tCzt1HmgTGt2oVJtCYx5g JONWRxSafesTou0ejMjxAII02N/01ckzMS0yjp/Z60dfcBbgS/o9C5lxF6SyN6EqN3GV pmKoT2pEO10KmnCRdAQrjCZcwOi9ngg2QRGjz8MhGJrkuz3ZLjTeTH3nrNZsZX9JM/WH mNsVVy6NoYyjVW12zcVD+vU9KR3FJk+UunEBqt9cJS/HDtc8iRYY31Ime5KfV7P6wtYv pdRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lTiOZM14; 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 cb10-20020a05622a1f8a00b003449d633eafsi932797qtb.100.2022.08.19.08.44.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:44:03 -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=lTiOZM14; 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]:46760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4AE-0003bE-OM for patch@linaro.org; Fri, 19 Aug 2022 11:44:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP468-0005dh-1I for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:35353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP45y-00063h-3e for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:47 -0400 Received: by mail-wr1-x432.google.com with SMTP id bs25so5624730wrb.2 for ; Fri, 19 Aug 2022 08:39:37 -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; bh=Xeh2vqFOTw5s3hqoNhblRj1bcX1xyzRqQ8DX799pYws=; b=lTiOZM14C4pzD56g9hfva+qxBUzAabBWDLJN5hR2r8kR9DGDCGl9eBb37fdOHRGpUR w8y2AR8hA3b4fZi27JxSkFjT2oprxw9C6nGqd4yjE4Eafp0//ZITFsbdfi9qyTffPTkj DbD0bFwOW28DlJGhQAVHKoBV5V8pUhAziQSFVvpctj6+hao4KHGfcWKIypYlGKrPqndn bYysnjn3QaOpgzMngCOga8dF1+atqw/eQ/PmhxwhxJ+sCw1O+oT7CLSSPpfYsUJMNM3n 5tPj4S48j7KTHY3MyJNH5kN0wlBokmlwOnr6WUgzzLa2k3OwxmEQb1WVGTklXQHczk5s 3khA== 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; bh=Xeh2vqFOTw5s3hqoNhblRj1bcX1xyzRqQ8DX799pYws=; b=Lb+qlxHzR14NBmm8z7gxhJWjzFFd8bqYnjn4dhC4y9tv0UkyDm/kiYvHOPE67SiimA rckkbo5jxKvM0hzTkupvgoKYcERvq2/41xoCWfcV1s9kQAaohyAQ8USUqXklKuwhaJ5h ykOcFn21d4iJRJGWCsaw/SjjjAMrdXhjW+5bQvAXpyIgQpB8sY2gO3kfBdf4NJ40KiHl dDp+O5VzSlME7Z2RAm+09N5K6ON465uutlKmGUm2A8R11knWQiTpN5Mh7N2kWfIsfLhk NvrSuWzxFb5PGeLypcD9GlwNJawpi0rs2MSyddjagymDwSBogmtGLbzomDUUCoUOQgxt +08Q== X-Gm-Message-State: ACgBeo0mvtYZCR9nnvv2v8C1iMOyb2vd4s/OsTtbVuglJtw0c1AZnG7p 5rAbLuJTuKxBx4UEkoV+1pMnDYN9fcOXAw== X-Received: by 2002:a05:6000:1541:b0:222:cf65:18d7 with SMTP id 1-20020a056000154100b00222cf6518d7mr4464252wry.659.1660923575950; Fri, 19 Aug 2022 08:39:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 01/11] chardev/baum: Replace magic values by X_MAX / Y_MAX definitions Date: Fri, 19 Aug 2022 16:39:21 +0100 Message-Id: <20220819153931.3147384-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Philippe Mathieu-Daudé Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Reviewed-by: Samuel Thibault Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- chardev/baum.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chardev/baum.c b/chardev/baum.c index 79d618e3504..6d538808a0f 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -87,6 +87,9 @@ #define BUF_SIZE 256 +#define X_MAX 84 +#define Y_MAX 1 + struct BaumChardev { Chardev parent; @@ -244,11 +247,11 @@ static int baum_deferred_init(BaumChardev *baum) brlapi_perror("baum: brlapi__getDisplaySize"); return 0; } - if (baum->y > 1) { - baum->y = 1; + if (baum->y > Y_MAX) { + baum->y = Y_MAX; } - if (baum->x > 84) { - baum->x = 84; + if (baum->x > X_MAX) { + baum->x = X_MAX; } con = qemu_console_lookup_by_index(0); From patchwork Fri Aug 19 15:39:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598500 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1498460mae; Fri, 19 Aug 2022 08:41:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ZaX9N5uP5JJbYUJxkJbHWoCXtyk9oxKA1Uw37sEgw03hsKnm4baCI8hh7cAIYFSJlMq/K X-Received: by 2002:a0c:8045:0:b0:476:dbbe:f169 with SMTP id 63-20020a0c8045000000b00476dbbef169mr6767300qva.90.1660923708899; Fri, 19 Aug 2022 08:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923708; cv=none; d=google.com; s=arc-20160816; b=lXMvmkDaa0Ex7I0iGj51JLJkzLoJMrBkKm7ktgMLfdmSbinikiTqSbNYc8oyKMI7er qJ0DIqf/8FAE5z3fIgYaYS4+PyMEmb9zId9cyer7vPAtO+XRUO7+fF5m0t7T3rJyriVs B7ILD/ZMEMFJYpzLggX1qxUAoqy3BFad6bJNTQnhym7apHNulP4U0VwGVboXgXN1N7zy 5odFj/NCiAcdp4iU77ywLzmWPgs+JsJn7GqrYFq5xVQPzyXpzdg9JypwIxjzyMv7t2gn XgEa5Vdd0vHYBVWgN2yYMmrjs/NoVncEqTE4TbgfuETXQUbMs2Ntgm9RUEoQpGTtmb5I HiEA== 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=R4g5feK2z3NYihYvidLiAk+gMsDmpPE7GLZDlbfsxQI=; b=gqwJ0o3J4i7ehtDlDQ1wE6nhEi+QrDPcUbJhYAPSd2HU24CkJxtSFficVX3pnKlo6M CVbS4tIFb6jJg7DK6JnfA7XtZL6JEcPpzqAhOQh3peHHK/4Isqt6jQdJ0Ufj98xI2gmL dqKHboksfFynHvjouk9bg1w6GWNOy2U9UX8xKEix88h4W/KqvIC4curF39d175RKK0AU 8MFjFB7UxKdC+79YyCjXS1i7F/cyIUshBjHJRnoRlXLwGcoHFmjoNAr0YBiHhyVgzHHj sDdGKlWChbkM1F9TwlsPXTnbzM5Jo7qP4E/RALy6MlZHwTXwZn7GTIWfb8S2xtBFPKq1 SH0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YL0d7agI; 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 t6-20020a05621421a600b00496abd6235fsi1855421qvc.273.2022.08.19.08.41.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:41:48 -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=YL0d7agI; 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]:41944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP484-0006TE-G7 for patch@linaro.org; Fri, 19 Aug 2022 11:41:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP468-0005fc-OO for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:50718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP461-00063r-UE for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: by mail-wm1-x334.google.com with SMTP id j26so2456067wms.0 for ; Fri, 19 Aug 2022 08:39:38 -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; bh=R4g5feK2z3NYihYvidLiAk+gMsDmpPE7GLZDlbfsxQI=; b=YL0d7agIlU3Gu7SEV4msDIQ0A9m23HFVPqhjqj/JMPAqT6no4uQchN1UFVyu5YWdFE LMJstOkLhUP7Mco5jD+wDmX9657xw4XEPf6BujjCHkEULeutXkG4gNGH5ZEWXoqRkZ3V gwFQ4ygRSDjNFhxg7FWGWYHFX6blZMANGRBscmDIBqbYo+JGkWDKWraWSU+oGzFymW3P uB3iQPrTgHiep10S5vuSqAYjwAe/Cyi85M4FLmS2yDE/pe3iUAIZILgkKut+hEk3kVcM boQcnFPCU7EM82c4KhJHmk/pNh9GdyxtqtBSEuU5cpI17ZY1WJWyoKMSz24Za0Lne2zs CDJg== 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; bh=R4g5feK2z3NYihYvidLiAk+gMsDmpPE7GLZDlbfsxQI=; b=xBWPCTEBPs7xm7GNU7j1/0iKXLzHqln65nZP/FTJ6pS6jDcSkED8hLNd6hZ3Ccjapb twFJKEXfe+TfWqxxCHVYcANOVg/vs0rpkP0zVa6y2lYoRuUJx+5tDukhe3q06lhJTLcN IPA43VOgyHJLeRZ64xREnR5khbWyfQmpAsN3Uw2Mgc/QyMADTUcWdEwvh7Wuk0mzjvBk OcfdBzUMPDa5Ly6NGYr+5ny6bWfKajDGigbaXAOLL9FEG5Lt/L43ZCuN+B3hJW44vR4g AgzB+5pN4wIhamIbT3oGIDd5zRSq6bV11rOotWihIIJ7V306bTKoCR7sifazqOmHNwxU gN6w== X-Gm-Message-State: ACgBeo0Rbsigv6VLf/dAqNGDJ9RUaID4V3Un76j6xRoMnQtdrI32BUSp RJyRDY5wCtw7K2dL3v7BxAkCsezjgzgicg== X-Received: by 2002:a05:600c:5010:b0:3a6:804:5b08 with SMTP id n16-20020a05600c501000b003a608045b08mr8126624wmr.10.1660923577315; Fri, 19 Aug 2022 08:39:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 02/11] chardev/baum: Use definitions to avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:22 +0100 Message-Id: <20220819153931.3147384-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Philippe Mathieu-Daudé We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not a big value, it is actually 84). Instead of having the compiler use variable-length array, declare an array able to hold the maximum 'x * y'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Reviewed-by: Samuel Thibault Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- chardev/baum.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chardev/baum.c b/chardev/baum.c index 6d538808a0f..6a210ffd815 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -383,9 +383,9 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len) switch (req) { case BAUM_REQ_DisplayData: { - uint8_t cells[baum->x * baum->y], c; - uint8_t text[baum->x * baum->y]; - uint8_t zero[baum->x * baum->y]; + uint8_t cells[X_MAX * Y_MAX], c; + uint8_t text[X_MAX * Y_MAX]; + uint8_t zero[X_MAX * Y_MAX]; int cursor = BRLAPI_CURSOR_OFF; int i; @@ -408,7 +408,7 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len) } timer_del(baum->cellCount_timer); - memset(zero, 0, sizeof(zero)); + memset(zero, 0, baum->x * baum->y); brlapi_writeArguments_t wa = { .displayNumber = BRLAPI_DISPLAY_DEFAULT, From patchwork Fri Aug 19 15:39:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598499 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1498456mae; Fri, 19 Aug 2022 08:41:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cmKeLlsVna5iOQ9FBnWoxZIoSRhQUpjdJI3rn3nh3dssu7Z8SYVHaLEkfxi/3yhfxf/J5 X-Received: by 2002:a05:620a:12e6:b0:6bb:a583:76a4 with SMTP id f6-20020a05620a12e600b006bba58376a4mr5530635qkl.424.1660923708544; Fri, 19 Aug 2022 08:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923708; cv=none; d=google.com; s=arc-20160816; b=XWFb/upzbSssdHNutXtCSLChacaxIpvVnVrIkTdkNBwfJERsjmhKReU9VqBJoiPub4 GGQYcoSlsWPltnwBC3uiqiKkRKqQ64MVVxgk3tBjWr48A8+3VnSBtoUkmHdqc8VE5ZCz oOFZaeKaxvEtTYszf4Y4pkEA317Mra5ljhe2mr/BvEtB/3dzsfJWOeJtVAw2X2ykdVcI J4ybWU2m0wM45IZutp/jmf8l6hr7Hxn7ev0yJUuUxYBj8JrsJmZhMqW4NFc9y5ZNmovO avkzQ+as74DJf/mZvPRaaqDpEx8vPMYlkSXrRj8hZu+mXLTwu3LYTszpcmE83t6EIECF mjEA== 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=wQwzIcXEd8CDalnfbzxRsvGcMSl1lPN2VEyNH0COQ4g=; b=V2Q9lsIXUP69/LcpCbeIL3TO8ddsROeHQKa5wNQfTp97bYLK2985hnrKIOQEJC6AqB NzrPaeZdwy51xfNHjXyttKdBIrr7wMGTAL1FRrzc2IEt4rYEPrQerdw0keI6pGQ86G7w q9LOoDHqZMityZAc1gSPRGSw6gt7fp3T/w2M4Kz+dZoMXAX4e28UeSvqT5Y5d3oOx0Up UsXSF16Glmi4KhQHynii33Ml+Tde143hMOhfM1PAV4RUoaB/M0mdCtAPtMW6pZnPq7xn vmUJ0LhMPV+YtBfYnqRX8HGZkI//ojIaCVkJq5S7kidxLT1exOsOf1EK2qKVmi3XQFhs vRsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q6HzCqbT; 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 u7-20020a37ab07000000b006bb2661f405si1923634qke.301.2022.08.19.08.41.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:41:48 -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=q6HzCqbT; 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]:60644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP484-0006Mx-3k for patch@linaro.org; Fri, 19 Aug 2022 11:41:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP466-0005bE-HI for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:46 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:37840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP461-000648-6n for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:46 -0400 Received: by mail-wr1-x42c.google.com with SMTP id n7so5625006wrv.4 for ; Fri, 19 Aug 2022 08:39:39 -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; bh=wQwzIcXEd8CDalnfbzxRsvGcMSl1lPN2VEyNH0COQ4g=; b=q6HzCqbT4CxQJgU/Nb6o3oeyUw2LATV+pyhvZw383EKY1FJay+0TS8805bWHjrpxu/ BJU3gwW8rqNEiKb3G+qEkUgSNzwcX+TJ509b4Mp8LIxkwoEopizFVtsaHyje7O4mY9xL tSwCvWbM8KBJFRZ6caejCRras6d5ASizmHcmXcZFRdUprQq9h0RQz5sW5GJUEHDcwITc d7stwSNC+UFtFmAi6hlmMqygehSEhLC/J8cdeT8mgwCLt7IZ9loGRWcOnjrkG6c19MXz K7BQgYcU+JPh/5ydndEfNHZtXZE/AJ6mbXxmm0XgB2PMkHTD2gZCg/m8HgspaeS9KSxB /7Fg== 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; bh=wQwzIcXEd8CDalnfbzxRsvGcMSl1lPN2VEyNH0COQ4g=; b=HevEyGDqVjkFtM+slIWKfG8O5Kh28DZGRxGyHgs5CVXwwWZowP58x2zn9dagbQIcfX cIk3RsXy3abXrFlGgBwh77TL/+ithN84jkVtOOIDOEsEeeRDJaiaabi0H+7KOx9cmEz1 Afa7Hjz1Wmwn1Cg5oh2x23yUHjrMPcGu3ZqCrDFGRLcC9FfuPLe8u23sHxQjiizX/CXx sCfKwrL4j/UqzSFlmUgePUnRaecqqrzvgsjW/569F7RCmXQ61XG/XK0BsrkpsymsS69d V43ZjD7xtKQwRQvgkfrqQNZvUiHQ2VY7nOFqksuhDn0wo1ljvYOyy1ANx9STmh4hRk1F okWw== X-Gm-Message-State: ACgBeo2oc7kD2tOVH3KJ/wUx1rmmuDMiuBL8OBKE9OhGp/aXaQfNvaVb s2/qoozpeYWAlirhkAuiNWBmP9lcWdLPEA== X-Received: by 2002:a5d:668c:0:b0:225:333e:15f3 with SMTP id l12-20020a5d668c000000b00225333e15f3mr3442249wru.494.1660923578689; Fri, 19 Aug 2022 08:39:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 03/11] chardev/baum: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:23 +0100 Message-Id: <20220819153931.3147384-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Reviewed-by: Samuel Thibault Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- chardev/baum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chardev/baum.c b/chardev/baum.c index 6a210ffd815..0a0d12661a4 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -299,7 +299,8 @@ static void baum_chr_accept_input(struct Chardev *chr) static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len) { Chardev *chr = CHARDEV(baum); - uint8_t io_buf[1 + 2 * len], *cur = io_buf; + g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len); + uint8_t *cur = io_buf; int room; *cur++ = ESC; while (len--) From patchwork Fri Aug 19 15:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598507 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1502438mae; Fri, 19 Aug 2022 08:47:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GR2n53SxpbS+bZZHqJI9QwQrbIFt+iHpjESk1kq+63lGwJSj7pSRTFgtzI8KjQPLsKbci X-Received: by 2002:a05:6214:5093:b0:477:4dce:80af with SMTP id kk19-20020a056214509300b004774dce80afmr6968974qvb.69.1660924075046; Fri, 19 Aug 2022 08:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660924075; cv=none; d=google.com; s=arc-20160816; b=MLOeCN9pFAlK07mQU+57iCohcAkj8gxEz04bU0nT99NCVdhjbCrkxiU40mb7hP3oJ4 hb/3uJ3Dlmt2XMmqKwVFIA2X79RLVkuy164u57HZ3DQPaIhbM/Tlff6FVMdSvT0atSSD YrHQlgQak1b9G7AxbhhWrW9C+eRiRrWAfcD1SV1KWt8hdcBR5Lmz1gfSuLcTsXeuf9dy 6TzgF29J787vwGf29iGqqkQ+QmzdBPGn5jThy2iuvHJwinE14z6g4FFUT4ycHA4a2kxL FN+CejKjXIh5yCD+gB+xtV3NyiPLl8121/NipHJyTJcXELDfYoqs1bt5ksRCn88ZvW0x JUlg== 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=Zg9fu5qHwdrrZhY9h0fcERwtTu8sDUqtYMAjp6fh9AE=; b=RqPzfdq6WbQL8w/g4Nb0iXfaCJzrQkSH99YDEDUV6+Lo/zw1wi/q1MgIPqr/h17Lt9 3NZFr6etgAueHS8lFsMaQmu9mjbzEp8fD59bY1roLNiBKQlnOV2wT1c88Uq/RhBgdSPj /xpu0QplDBiNla/pBcwq4TWmtOhbUjGaDdxbuOlNNpyYYPdSV+hE1EjSoGAgU9lycjEX QbHY9+M08j6lz0w4GCJyBXJ7tIrWQ/gyOC+3NSRxBxdmvvuLhdhrj5QGcIO6lkGlDuIv 0GUYhdcvrDadNsPlNDbv7Rjj/2knohoQHCugQr58sMBFS5v5OHhWnAJZHaP/0LNk6mZu CiOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gVjmmY/h"; 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 y25-20020a37f619000000b006bac73a0feasi1976119qkj.466.2022.08.19.08.47.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:47:55 -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="gVjmmY/h"; 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]:45574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4Dy-0000qk-Gk for patch@linaro.org; Fri, 19 Aug 2022 11:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP468-0005fH-L4 for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:40745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP463-00064H-IW for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: by mail-wr1-x42d.google.com with SMTP id h5so4808899wru.7 for ; Fri, 19 Aug 2022 08:39:41 -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; bh=Zg9fu5qHwdrrZhY9h0fcERwtTu8sDUqtYMAjp6fh9AE=; b=gVjmmY/hxoqNMWTlk4nX/AeiWWNR626hHESiulMtw709ydBi4zvE+eZZ9EAP45cWgD C0GGnbzJOXYEN9icePhlG73AzCvExVZhHKbDh5b3FOwfhaN9whwWpvRd4Q0+qy8pn/Vb XPo/EqIblD0LOqw2HiCxSWmj+F+5NCRhZaNmf1XI+LAQpFFf9vOlihCSQqgaCR+jsMce dVQstpq44+mX7D4o0IuUWwSucL3GJOreLTWzl4Ya4a9DjxSxk0y9cIiSTLodUVrKwbIO O82pzxKNBe78L36vrQ2JUkCvNKsVtVIX7+tU7hCXaeIhPcEPXMZJRF7hzkaf8kZECil6 464Q== 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; bh=Zg9fu5qHwdrrZhY9h0fcERwtTu8sDUqtYMAjp6fh9AE=; b=JiBXT1tcV6Ac5D+dpHCFe9TvhxB2Phq1ujXc5wswKGoLliaes4o8dvsmfA/L3lF8VR 3vOV/8iCdjjx4lfEP6zDUIteuEaUQ51ZtxVYB0fyCugURm/geBrY8A5aJm9UDg5rrHAA sjmZejmnPkDebCn9At1DWDTrhlq7IC2VmW7+TfHwGhcXXsMa1TziNd2vE7Cc3yLQysc9 JL5OLkmc0F3DR5ISuIt0me64KWeNTNCXJ4wxpsJzdue+x2CKShfy42AiO29h9mGZ46YE M5L+W/gNPolKsfW65xEUNEVAMHrTI7aHtepCIYl9vOONf9iIF7MQvfhazojRq8N2lXXB v0Eg== X-Gm-Message-State: ACgBeo0efClFe1goHFqPrrT7dFGe/QM11IMT1X+AI3y+Y2XBVAl60JZl z4UHBjnTUqDUaqIVlvPpTB5vWT4k8WmqEA== X-Received: by 2002:adf:f18d:0:b0:225:3a78:cef0 with SMTP id h13-20020adff18d000000b002253a78cef0mr1933636wro.578.1660923580049; Fri, 19 Aug 2022 08:39:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 04/11] io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1 Date: Fri, 19 Aug 2022 16:39:24 +0100 Message-Id: <20220819153931.3147384-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" From: Philippe Mathieu-Daudé The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in qio_channel_websock_handshake_send_res_ok() expands to a call to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't realize the string is const, so consider combined_key[] being a variable-length array. To remove the variable-length array, we provide it a hint to the compiler by using sizeof() - 1 instead of strlen(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- io/channel-websock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/channel-websock.c b/io/channel-websock.c index 9619906ac36..fb4932ade70 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -32,7 +32,7 @@ #define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24 #define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" -#define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID) +#define QIO_CHANNEL_WEBSOCK_GUID_LEN (sizeof(QIO_CHANNEL_WEBSOCK_GUID) - 1) #define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol" #define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version" From patchwork Fri Aug 19 15:39:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598502 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1499734mae; Fri, 19 Aug 2022 08:43:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6UhtzRshfNhz28qmorHwqB/mR05sMojFwNnRBVutfEzz6T5LYsGQylwikDpeRa9Yi4tKXH X-Received: by 2002:ac8:5908:0:b0:344:5f5b:5497 with SMTP id 8-20020ac85908000000b003445f5b5497mr6923112qty.632.1660923839743; Fri, 19 Aug 2022 08:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923839; cv=none; d=google.com; s=arc-20160816; b=ISmna+gEGrG4GAq7jqbD0w8ATmkzyiszBMM4eHZjKFE+SmX6UwP0+Q46/jA5jp4OU7 Mw176zrfIVkykAjtpUrdHfXn0yxOSAkpPmkNpchX8CLTMRFmljm6i3XeU7Xb3WOUrgR1 Vh37jUf5N6BY1h2WqX6tqigZWZRnWKd2UUa07x1kKFCu93WwPVdCTgpVdx66SxCYHsyP kDl5ECOE2Xtd5gXfUP2jnWLSLK3qI7AchgPK3GTM605K+7fvAf4SJV5CnqRcbp7hms1F tCZDs6PkiIyaJosBARrzzdwY/JYjj9kI3O3mDuW9/mS24vOUqg0YAtWYYmzPen0rcpjm uyow== 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=cl6TQtvSxV7arO6sC6GB32F3upDS/NEMszQzruWKRcc=; b=EHVmNMP6QVT2TA3Ooos7f6yVlX4uqazpUvr+O5NACbP0zplTFLbNLm8az9XkgMIsWL GWu2Wt8XPRyXH6F3u4LC+sQQNV6uBLshvBNketSyary2KRRLa9TMYvMF/aAHzThbQ4BB UiPTDQT/QSFY/sHKKWb5Pn5mATjtcDgpt+X0G/ru5zczqrr+GNzBqAkl4NEfH4m5j4Dz +udiCSmrJ2WzHvSeHAsF79fSOBf2VSA8VckhvWOUGjvua++26pa1OzvlcJGUQeFDSYXg 4E6s2JuXKEDr8DWY+qNLD8wIZrMYpQ8GXIwid2nYXMLkEY0cFPBH9hJykclIQbWlu5Fz 42qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GzQ3s7s/"; 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 z14-20020ac86b8e000000b00342f1eb0d99si1782435qts.751.2022.08.19.08.43.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:43:59 -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="GzQ3s7s/"; 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]:46756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4AA-0003aH-9x for patch@linaro.org; Fri, 19 Aug 2022 11:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP468-0005eo-Gw for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:46870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP462-00064V-RT for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: by mail-wr1-x42a.google.com with SMTP id e20so5124306wri.13 for ; Fri, 19 Aug 2022 08:39:42 -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; bh=cl6TQtvSxV7arO6sC6GB32F3upDS/NEMszQzruWKRcc=; b=GzQ3s7s/pWvsd6xhdPcB3eBKkYXcfsqDGmDVT8dxc2wkiCmXvGWd7kvqe9NWkJXLPX NKnrPdGuCVzZiA5wN2cblqU4HT9GVNWZkSOuBpCgMJtajE3JXtFpedUiX3g2BEY1OFUM ErwfA29zDJNGM5QNSaHdqZI1nqY0QiL0WkkFAwle52+JMtbAMQ/Sl8TJb9ECvT9z0saB Y8nGNDAJZTBcYs3EN54mB7+P/SZNpIAkMF+awJyvh3+mw4++mtCwfvF4AC5bGhcf1obs O7ILTvvW2eo0e4IMpM2nRn4iFbXpOIvw22+d+vagUC53fQRxrc/1/NXaHMwE6Jb1t5kA e6Eg== 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; bh=cl6TQtvSxV7arO6sC6GB32F3upDS/NEMszQzruWKRcc=; b=MxnufD8LvmBMsSDaPp5Lx9h8HZs4Q2s/Xk+7YYQqml/Cv5rVfDZEoRjjtOFAdHlajv yyqDV+Tzxzp874FgiH0k3jVRIMihvrI5L1fXYgUB5xeNsQ1+XlrYv8GGy1Btdj1F7/Df z6wXbx1roHvEgaB4zBeCdeAcl3GNe1L63pJ5iIDV4y53SZC37xpmsV4yxRD9FOkLQu2m icaIzYN1SbwQfOpEbeYjpecTKFZkfn8Kbs9F4Mioarapb5kk9E5EWh+6Cz9uYwoziTU5 ov+YqkrCgnuanhcEIGbrCaUeiMuJSyc+ABKqfgkXWnG+9IKda5JOxvMUzofmMk5WtH17 2EAg== X-Gm-Message-State: ACgBeo1ir8E8KsMqz89a4YqseuuNHUetn+blW4r4FNcZkaJJqoR3yRxW Mftu08JwZ7OGZOD9LKTg9VNAtyH/W2NWdg== X-Received: by 2002:a5d:6c6b:0:b0:225:dde:ab40 with SMTP id r11-20020a5d6c6b000000b002250ddeab40mr4611589wrz.690.1660923581387; Fri, 19 Aug 2022 08:39:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 05/11] hw/net/e1000e_core: Use definition to avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:25 +0100 Message-Id: <20220819153931.3147384-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" From: Philippe Mathieu-Daudé The compiler isn't clever enough to figure 'min_buf_size' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Jason Wang Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- hw/net/e1000e_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 208e3e0d798..82aa61fedcd 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1622,15 +1622,16 @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetRxPkt *pkt) } } +/* Min. octets in an ethernet frame sans FCS */ +#define MIN_BUF_SIZE 60 + ssize_t e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt) { static const int maximum_ethernet_hdr_len = (14 + 4); - /* Min. octets in an ethernet frame sans FCS */ - static const int min_buf_size = 60; uint32_t n = 0; - uint8_t min_buf[min_buf_size]; + uint8_t min_buf[MIN_BUF_SIZE]; struct iovec min_iov; uint8_t *filter_buf; size_t size, orig_size; From patchwork Fri Aug 19 15:39:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598506 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1502301mae; Fri, 19 Aug 2022 08:47:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7aSzSmpyHE83qA0xtMThg3wDytz10SaptI0GKUAXDj9pMwaIq8XAEN+cdG6eDeb94IxRfZ X-Received: by 2002:a05:620a:25c8:b0:6ae:ba71:ea7d with SMTP id y8-20020a05620a25c800b006aeba71ea7dmr5644344qko.547.1660924061979; Fri, 19 Aug 2022 08:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660924061; cv=none; d=google.com; s=arc-20160816; b=xPUzvhPCTfGhzviSEkwYBmeMiBDd8rIEPzv4SB5ltuorhTXms00FU/nKG7y6qQAH5H EQtkC9HVBhigp5sPJQHs82VwiDn7SJrlmFG2wYq5wWt1RuMCJL8W9mdQlN2wk5XYvOaj o7nC2OGdAFIUt7YRgcKJW3nKFgIpd7XC07mYDxSEFUb9WW8v+DBUuJfU/p2CorVlJM13 zhn+874EnVNpjaEBTY4ZIZGjfg3OxA74F6xjPqNjobyIXtHMdMFRGB3m6z3KvGWNKlg2 r6btxsG67W0gN2ZaNhJlG8mpj2yZ0fkKoGcEDtxhDBPqGYWAn32iTEnl3noJOZvuCEo9 wQrg== 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=O0kTlYBRe8XrfOsBr0O7vJ0KUHjU8+ns6BkcrOf/Srs=; b=EPtlWlr5TaLp1P5BZYrOsFrDT/MeykFRJ0S1tO7d515u9PrOkFozl4YgHpbs2+OK4/ lXPJNhozeDREKxxDIZ9aPnn0JUi7rcVuxZ+7qCRj2sR+KAxJra47YSuCG7Nx6OpeD+Sw fOImumEAB9WD8Qro399n0QMXT4HG+dxDpU/mei3yVvQOQLoRg9+WPcXAhU11l0OD5ibD bdnfZFwGuTXD7EE8I9BJQLSLkneDsbl32RoMNvqjfeiB9w0ExlbOuq6YurRqs73pptIf Fss8OW+2xBgyWjLijMaxm8T7tkwdvGUSSjAhfHHM2wVC9o6OPFR67ZmAAPPe7eoLKLg3 ZRGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UGtuTV1t; 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 u30-20020a37ab1e000000b006b965879f99si2257140qke.249.2022.08.19.08.47.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:47:41 -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=UGtuTV1t; 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]:42276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4Dl-0000e8-I5 for patch@linaro.org; Fri, 19 Aug 2022 11:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46A-0005iX-4b for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:50 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:42590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP464-00064f-9D for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:49 -0400 Received: by mail-wm1-x331.google.com with SMTP id l33-20020a05600c1d2100b003a645240a95so301861wms.1 for ; Fri, 19 Aug 2022 08:39:43 -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; bh=O0kTlYBRe8XrfOsBr0O7vJ0KUHjU8+ns6BkcrOf/Srs=; b=UGtuTV1t+QRxXJ4M+JwMNuCTwf/sLV+Mwn9bMwB4yodePOieFhw2G0WIVe6dEL5coy b13fdyeq65OVvEr9y9g5A/lHqGqkfP82AYbkuEI+xmu5ha/QAcboME6y1Wg3hajwsi4K cS9GRLmdcr5pBFlt+NY4VhKPlv6pbmo3tM435JrgBWtrh0Yd9SwGiwIDS8j1gSxIJjho n+decSApioxnvTFaFuMLxXAShU7Q3vHFFVY7JbW1i9zrAXuHs70iPFvDl3j50DuFOYsJ tinCK9H4YIlQjn0+w1Gl9Z935Fq17UhHFaoxzAcdJHx0tZG8uFt7/AoObgrG1YfZW5Gk qgOg== 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; bh=O0kTlYBRe8XrfOsBr0O7vJ0KUHjU8+ns6BkcrOf/Srs=; b=GbWX3p03WEwhPmhSNPr6H+dLrG6/VhFPwgGgK4KgXPAYiexQjGj2v9LzebptJD3z4Y VO0fQmjv62YZHCSMQg5Exii88SPVgqk7/VyyXxGIhEUJjSsXabmPbxGdLNjIDRnYSmJC wKkkeazLAhBGR3ISbqEUpx5Z3S1VNluXHbJ885TKotTpRe0p5nF4R9T6PmY1SAiKVXq/ 6DdriM2WwobHkm4KML5/6uPIagfbsVQewvBTcDOuE/wIXAFztuj/qE6r8plb6mhe++KQ LswYeKVSbmyYUecviIRh5khx/VlDXzEcHNnCwjsXZ0p3hhRyYfDXrTxYFTmZQlpIokLn LzqQ== X-Gm-Message-State: ACgBeo3qiSdqCOAgj0zN4gBT0PzjPBLZm/mxIcYnNKpIT2+wgFTBTqt9 oiC0vap2Oah5LNxnGrfsTaxXCfck7OKmBQ== X-Received: by 2002:a05:600c:1898:b0:3a5:b467:c3ef with SMTP id x24-20020a05600c189800b003a5b467c3efmr8310912wmp.178.1660923582708; Fri, 19 Aug 2022 08:39:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 06/11] hw/ppc/pnv: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:26 +0100 Message-Id: <20220819153931.3147384-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell Reviewed-by: Daniel Henrique Barboza Reviewed-by: Richard Henderson --- hw/ppc/pnv.c | 4 ++-- hw/ppc/spapr.c | 8 ++++---- hw/ppc/spapr_pci_nvlink2.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d3f77c83672..dd4101e5b65 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -137,7 +137,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt) int smt_threads = CPU_CORE(pc)->nr_threads; CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); - uint32_t servers_prop[smt_threads]; + g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads); int i; uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; @@ -240,7 +240,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt) servers_prop[i] = cpu_to_be32(pc->pir + i); } _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", - servers_prop, sizeof(servers_prop)))); + servers_prop, sizeof(*servers_prop) * smt_threads))); } static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index bc9ba6e6dcf..28626efd479 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -177,8 +177,8 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, int smt_threads) { int i, ret = 0; - uint32_t servers_prop[smt_threads]; - uint32_t gservers_prop[smt_threads * 2]; + g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads); + g_autofree uint32_t *gservers_prop = g_new(uint32_t, smt_threads * 2); int index = spapr_get_vcpu_id(cpu); if (cpu->compat_pvr) { @@ -196,12 +196,12 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, gservers_prop[i*2 + 1] = 0; } ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", - servers_prop, sizeof(servers_prop)); + servers_prop, sizeof(*servers_prop) * smt_threads); if (ret < 0) { return ret; } ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s", - gservers_prop, sizeof(gservers_prop)); + gservers_prop, sizeof(*gservers_prop) * smt_threads * 2); return ret; } diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 63b476c8f72..2a8a11be1d6 100644 --- a/hw/ppc/spapr_pci_nvlink2.c +++ b/hw/ppc/spapr_pci_nvlink2.c @@ -397,7 +397,7 @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset, continue; } if (dev == nvslot->gpdev) { - uint32_t npus[nvslot->linknum]; + g_autofree uint32_t *npus = g_new(uint32_t, nvslot->linknum); for (j = 0; j < nvslot->linknum; ++j) { PCIDevice *npdev = nvslot->links[j].npdev; From patchwork Fri Aug 19 15:39:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598505 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1500302mae; Fri, 19 Aug 2022 08:44:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR5d9ArpaM5bKj5+J4PcXVnGFnDvwg7JcoMk0/hqqsT3gQrMtofP41uV6ahpE7SYOqxDqJZw X-Received: by 2002:ad4:5dcd:0:b0:476:a48d:4c43 with SMTP id m13-20020ad45dcd000000b00476a48d4c43mr7080211qvh.13.1660923892022; Fri, 19 Aug 2022 08:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923892; cv=none; d=google.com; s=arc-20160816; b=qGRvbB5vxNvYaplI1xQEj36IHA37GBZtdQXz/nxbA5ofYxZkbTrJCF3SpSCFWGzNQn hdH6hJN4fbsJb8lKr6Lbg7NZ2n6S9Ll7UgZ7zRQPxLYrHA7AvOWAEAzvz1+uCK2Melzj IFnHA61kQV9Nw473uArP8puzDH8Lr+j4uUol/IXnHxYmxQc/qbUuUmVop8HrMpsl6DM5 6sMxY2NtCoq/vVF5J+6/TOlcyteloB7kRn0qXU0vdz9WboRsqOF7zQMy4HvfeXK5LGEh B9TMcEIU6SaWSkeQnsZbRU0aC8eroDP2lkjI8Gh/pVZbA2UJqYWo4se6ehy2Xx+hgrZp Iujg== 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=MdveKL4MP90EdNQkpPRlvAKQ9ASmc2UjMbS6E+1HF1Q=; b=p6RuaxwIkSzqpMo+e92q/J37vHIIhxd9mavujsg/mWxxs9ALfBQAg6tk3YVMgdI7WZ heUf3j/Qzwc4cAt7jJAXes+S4ZrUwW4Rql4fw1Uxp1RHmIMZWS08bHxCvlgPX1QF3UoB Fp8X47ygfy6WE8XDxX7wyEDDKyq/wy9euR2MUxAYeu38cDXPOeMo04gDrwFE6ZFxxNb/ WHVufgByj/NCmRtagIaw9ifgX8iyMryHk7xtQ5eVE/iMti69ZqyKmzhKlM/U9v/IoNuN r3RKDW+DXfmDOzr+auZmdrrzVya0QiuNKBn02syDsyvkUD6Vm85tXLokXXBYq5cl36u9 YHHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lihKwPGj; 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 14-20020ad45bae000000b004967ffe7aa3si2021616qvq.37.2022.08.19.08.44.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:44:52 -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=lihKwPGj; 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]:40702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4B1-0006Kb-LS for patch@linaro.org; Fri, 19 Aug 2022 11:44:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46D-0005lZ-Ih for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:39655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP465-00064w-Bl for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: by mail-wr1-x435.google.com with SMTP id r16so5619823wrm.6 for ; Fri, 19 Aug 2022 08:39:44 -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; bh=MdveKL4MP90EdNQkpPRlvAKQ9ASmc2UjMbS6E+1HF1Q=; b=lihKwPGjA0DKnwXPdntU6GoO4IsgZ9k/4gQznM+g11xVB/9U9nbvIRDhzSaXbwnLY6 CUc+J+ULKLAmRls3veAO+02/NAVJSc6efljwzsZ5bfTLYzB4BJ9f4GnUkadUf9UTf341 AFiGAoBYxJXhTiXLFWaURNoDxffX9Dmyo23lSSSVN/Wm7uQ5dzMLew2qGJN1Ji5AK0uw EKtCH7aG2QI+CEEi3/AfFfTAgkRuiNHyvCwntiC3ENJfGT0AleM+ifLM7HzYxuQPwdAL D4ARWrj8jYXx+UOG2Bmn90vCyV7bHmCLBhpW0XGyxlAGfteANnv7c+ki/6iUtkKxkYXA rWQg== 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; bh=MdveKL4MP90EdNQkpPRlvAKQ9ASmc2UjMbS6E+1HF1Q=; b=Thbn5YsOkuiDJmr5JlTC1fXFcMcDFOB2dzwqRgdE8AaOhN+Z9W1bHpz5ZDu6yDs4mG 9s7/SfvQHj+EOiFXYtgZ6gr7DJtpKkYouj2hir4iJkPaeWBwlEBIkzDn+3YQuN/oOa4V 6d1Hsj8m9OYoCvfxumlLmdUvHJI3rRUb0pJiHkzgcrUWcFWuDF6wwz2bUGTxHU5v27vU Mccd1L7hOuELLnn79lr8P7L/Syzy7yBO4McUhBnFK/ee3pZE3Fbxlx8pLVp53xBFmwa2 o7U4MKErivL3K3d3MA8Tn8ti5pEshz3fPq2QE6RDoAARdBJZDMFw3HNBmN+bi4d2OQpc KBQA== X-Gm-Message-State: ACgBeo2rIY1L3zGR1UiV7abRTDtNxZ5B8xUukkmIRoyBIPnVokt78U4C nV2wzyBXhtFEz0u11irJfMAZ98A+K7ukMw== X-Received: by 2002:a5d:4301:0:b0:21b:8af6:4a21 with SMTP id h1-20020a5d4301000000b0021b8af64a21mr4766102wrq.296.1660923583981; Fri, 19 Aug 2022 08:39:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 07/11] hw/intc/xics: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:27 +0100 Message-Id: <20220819153931.3147384-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson Reviewed-by: Greg Kurz Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/intc/xics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 5b0b4d96242..dcd021af668 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -567,8 +567,8 @@ static void ics_reset_irq(ICSIRQState *irq) static void ics_reset(DeviceState *dev) { ICSState *ics = ICS(dev); + g_autofree uint8_t *flags = g_malloc(ics->nr_irqs); int i; - uint8_t flags[ics->nr_irqs]; for (i = 0; i < ics->nr_irqs; i++) { flags[i] = ics->irqs[i].flags; From patchwork Fri Aug 19 15:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598504 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1500006mae; Fri, 19 Aug 2022 08:44:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ZpSW2XRijQbw1S9pX+r2f2FvVg1TYiJg72k+wrJPBDiTpvBl993jW32eoMYMpSaFhMCKP X-Received: by 2002:a05:620a:151b:b0:6bb:5508:59bb with SMTP id i27-20020a05620a151b00b006bb550859bbmr5467527qkk.55.1660923862340; Fri, 19 Aug 2022 08:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923862; cv=none; d=google.com; s=arc-20160816; b=cWD2V0Hi/7AviUju6rHebw+LqO6uz8NpkY6szqRTzFza8+au2QOCqulZexUQVuby8l TLTHbURHwhv0+NSlOOYikPsKNWwC73Jd25DVIJ5hDZkwJNmMt71p01NUpuyssjPrPNvn +I5CmKaExH6aL3+wHz8e23l1nNaAL7MUxfrHftrnJDcH9fQZqroYl1TCdbMe0/kaf8gM QIxwcVUW5lVdRsv+cWchbmbBQuaqLgCmc1DDqNYsvjoXdf7qRLYCdTWIezNFJgS2Myoc Afnoir8wAWFpt6jjS7hsZAIdirwsKkopIYkcmdAfwNWv+KhP/om3tq9JFX3DUdrR/HRp zUOQ== 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=o0T9cbillLUVn1AQ53zgvfCfnDyIkISRz/FjBOjJIOk=; b=f77noOGqElXiaD5SH+XychORZLX87Tflv6fO3XDxTwonzetoVP3iyCe2mzVqtaqA9E ElwG+9mvDty9iTsj4ATfR3iuqtdsgFVY8ox6JTx1QxH1fhEUim/0l6x3w7cMl+oomN4q F3BUEHN5GVZIUKBMbOeym2RmwYbdmzlYH2RLE0nxwZ/R3vCThueTX06Vh7cHkiRoGbUG 9JpqCyNWvfA2KKGHxHHCK+SdXM73tItsjL+dGqIWgnOHz725zuQ01Dt8bm5RSoS55cjw VS1ihWHwVvr/9acuYTXL4vibFfWl7LcUfnfnWuxwjUeSBsoXFOeYFu/iT97xeWSapi3I FVMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJGNqIPF; 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 fv12-20020a05622a4a0c00b0031ef4c92e98si2043752qtb.493.2022.08.19.08.44.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:44:22 -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=AJGNqIPF; 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]:39674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4AX-0004qH-UJ for patch@linaro.org; Fri, 19 Aug 2022 11:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46F-0005nG-Na for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:57 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:34636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP466-00065D-Pr for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:54 -0400 Received: by mail-wr1-x42f.google.com with SMTP id a4so5630379wrq.1 for ; Fri, 19 Aug 2022 08:39:46 -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; bh=o0T9cbillLUVn1AQ53zgvfCfnDyIkISRz/FjBOjJIOk=; b=AJGNqIPFvRZh9dyOzh83lCOXDOdwJuJroY0ue4jamLmE4hhHBnIkcH/YjwBoZQN04h 4FNbQqvml6gu45nz6SinqufrUu/lN/lVxmfZ6iYU9Pb0sNIkKAXE1YmjqUXE2mDG4CQA sJ6FVAEE6s1QY9yKdURXKQGJlZKvjwL9+zrIbQpF/43bX7AMcr6BcLl+y4xWTMnv9hgK 327+ygnd9SrPz1Y4xyvZFYV4vCVoGHNUdIL1myzRylCHCZrUEwLyJOaGlGn8mi+6pk3T q4rL0laq5fqN2mS4YT/UT6HzEtRjvk/GzbsQR3/jm4/24Op3TKFvLwl3Hidk24Jwa3qo YLcg== 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; bh=o0T9cbillLUVn1AQ53zgvfCfnDyIkISRz/FjBOjJIOk=; b=TdGYTeX6J3aIKsukaKHlNJhNn6Z0fcL7RsrslEom37qxMdPusoiRN4nG4KYNaOIYuB 9Xf6MbF0EjoRUf1WnpWXWYK9Q95p22Aw/giravgxXJzn4oxVFb6/B3H32pezlDF2Mjvt 8ggCMOHG6DhjsZnYBc7UhgLcUJZ+K8usEPWpkIQjW+n0ddAgaFCtH6FHdd97GnFdcTXi FYLi26Tge2ZTYkivRZD0I6yZ3jvnjEynac2+6ExMZjEkVq2YJ7tECDKpvbR2owi4kqst sc1iUGrtCQXwNOWKY1k/1WF4qZSf2zonzupTl3Ht8Xg58DnUVkibkoHP4IenjwkzNJjY ID7g== X-Gm-Message-State: ACgBeo1VBFmZdAXE9Q7fA+Jzg5bLNpoGzDzPyY8LV/2Y6Ee+QHNqHTF/ 76VtIganl9Bchxh23Q5S/nrg0maRNtpM1Q== X-Received: by 2002:adf:d1ea:0:b0:220:6334:25e with SMTP id g10-20020adfd1ea000000b002206334025emr4903739wrd.32.1660923585325; Fri, 19 Aug 2022 08:39:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 08/11] hw/i386/multiboot: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:28 +0100 Message-Id: <20220819153931.3147384-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Replace the snprintf() call by g_strdup_printf(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- hw/i386/multiboot.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 0a10089f14b..963e29362e4 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -163,6 +163,7 @@ int load_multiboot(X86MachineState *x86ms, uint8_t *mb_bootinfo_data; uint32_t cmdline_len; GList *mods = NULL; + g_autofree char *kcmdline = NULL; /* Ok, let's see if it is a multiboot image. The header is 12x32bit long, so the latest entry may be 8192 - 48. */ @@ -362,9 +363,7 @@ int load_multiboot(X86MachineState *x86ms, } /* Commandline support */ - char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2]; - snprintf(kcmdline, sizeof(kcmdline), "%s %s", - kernel_filename, kernel_cmdline); + kcmdline = g_strdup_printf("%s %s", kernel_filename, kernel_cmdline); stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline)); stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_name)); From patchwork Fri Aug 19 15:39:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598501 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1498969mae; Fri, 19 Aug 2022 08:42:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4TA/IkdMplUt0Ep8VA2vCh5Naez0oJRwATnLmjH3Mou1TWzAU7avSknJXqhyXvlRfCR0M2 X-Received: by 2002:ac8:5c8f:0:b0:344:7194:f49d with SMTP id r15-20020ac85c8f000000b003447194f49dmr6987697qta.355.1660923757409; Fri, 19 Aug 2022 08:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923757; cv=none; d=google.com; s=arc-20160816; b=BWy6se2v2U2MbhfuEmkB9Cvvpky2cqSLsYygqj7xOCS7Z+hg6kgFY/Tp6To4EEHi7B giUwnhsnmbNsudD+3gmb7LD1VDvjX4PR64AfnJ16LdPOisZRxJRyK6JTd5LVEH0E6rq6 K+rbvWBcd44bIGwdFWyVg1daVg0BhSAufpdeiITXxvNkMZE8VDcYVCt4hLnsoE8WHCj1 +CkHdU2XEgCYVn0lmc3HE1B/FEPJh3tb+oPQQTyOga7KgKt8Cli0anr3e1Vv1AtvA30Y pZfVVKuUXNCJ9H9OYm0XaljrL1ke7YtgDjxDxuht+iLxFfxCrXUGaEyY6VNhIb9axFoS an2w== 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=wicKql4I/h9UnyT0qeiWtm97WB3+4GVyQ+X7NhjeYE4=; b=r7zZJPwFTI/4ay7xQQpXE4traowY5H/DhJKZqMtSIr9uYNYfOQcDXJ9ORGzYuR0eja CahvPCGaUPjwh3kzCpIHwpk0vqXidZMNofnvmETfQZoAYNEPmu9gj1LLFbxFbTCJ9xpI 6AVXfvuybE2sZUt8rZmIvaSSrbWxPnahQJGiesAIsUiqfos7uUQ1ABVxAFQvE3o8R0eK SOFk4foxTIdzDIU3p+QWiRTkrZQD1pnZOv1dWd33t2y+pu0XQB1jcE8zVUjOZVYRQjHM bTfhvpyPj8sELkO2/o2IVQdYW0NvwKghfnA0Rb3uo4L2oU0KzMht9WjKryjCpyRBnrAc BXYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A3+tajuM; 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 o15-20020ac87c4f000000b00344959f7832si2040450qtv.579.2022.08.19.08.42.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:42:37 -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=A3+tajuM; 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]:50080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP48r-0000bl-1D for patch@linaro.org; Fri, 19 Aug 2022 11:42:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46C-0005lO-BM for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:39652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP468-00065d-Fz for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:52 -0400 Received: by mail-wr1-x431.google.com with SMTP id r16so5619983wrm.6 for ; Fri, 19 Aug 2022 08:39:48 -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; bh=wicKql4I/h9UnyT0qeiWtm97WB3+4GVyQ+X7NhjeYE4=; b=A3+tajuM/D+cBNz8wVn21umtZzep7yXocwXNlSjy9AmPvLeySUgvajsTefklCwaTPz A6S44opQ3e52W6gZaxmbVXXsVWsqyKcBRJZQqqSCbqw7EM1/1lnP1osx/9WeB9sAjeIG RX3Yluv1rRbWzX9Sn+kXVRiNwgwzaJ9kiiB9DxBgXo10xlV8TgEsYfLaPzPrnv6eccL/ lc7ovIH0eFtKCiIpbdAldAL9x6P6t+FB3O61h2OklmwHOO8kiPbhXtlN90u5TLASMwMh JaZG3cDHiW3MIHz0aAaKkpSHHqOma4HmFtSOxodLWFJHf4qt0l6mVo1Gi183PxgqZDeZ BbFg== 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; bh=wicKql4I/h9UnyT0qeiWtm97WB3+4GVyQ+X7NhjeYE4=; b=fFB2vRz7L+oJ68mW7QbqiWwH6oi5zdySSO5YpP+iyqZlNpSjz6wU6XCxHvqSpTxufc Wkcm8f/GPiO7KJ1OL8JISTW4tZbewksJLHFu8eE3xP4jvCDb7AC+HNpB+DGJ3nXMOb5I At8uM1whNb52hEwutsnUD9VAdrBN0BYanFhk2OFQUYg50Xp4ArPv7UFljoLy2m9txgZY cD6VSMTPON5U2IHOHSRy5PVhAjLu1sWLFTaiZcTeyFXohTsxDMx5QAJTiAs1fL/du8J+ CTNqqcDRROK6rC/9QwT8tZinUvpk8g4bNiePW/S61ir0slnT17Z53PGFbNFffwLM/KTC cQow== X-Gm-Message-State: ACgBeo1GBegnedj0YpyzLdhVVRLb6TC3aseAz+L3XRLmIez5LyLjxqe/ /FieC3g284WIRIxEc+dX4SNOt/m2FUgivQ== X-Received: by 2002:a5d:48c5:0:b0:225:2f99:430d with SMTP id p5-20020a5d48c5000000b002252f99430dmr4769879wrs.358.1660923586670; Fri, 19 Aug 2022 08:39:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 09/11] hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:29 +0100 Message-Id: <20220819153931.3147384-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Philippe Mathieu-Daudé The compiler isn't clever enough to figure 'width' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- hw/usb/hcd-ohci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 895b29fb865..5585fd32ccf 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -805,13 +805,14 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed) return 1; } +#define HEX_CHAR_PER_LINE 16 + static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len) { bool print16; bool printall; - const int width = 16; int i; - char tmp[3 * width + 1]; + char tmp[3 * HEX_CHAR_PER_LINE + 1]; char *p = tmp; print16 = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHORT); @@ -822,7 +823,7 @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len) } for (i = 0; ; i++) { - if (i && (!(i % width) || (i == len))) { + if (i && (!(i % HEX_CHAR_PER_LINE) || (i == len))) { if (!printall) { trace_usb_ohci_td_pkt_short(msg, tmp); break; From patchwork Fri Aug 19 15:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598508 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1504212mae; Fri, 19 Aug 2022 08:50:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6QlwkbZd1emVpoJR3tDnN+HEtZq2jieHl7AgVrve0kIuP+g1cSO2MspH+q87YeKJHbjTkj X-Received: by 2002:a05:622a:15c7:b0:344:5321:5874 with SMTP id d7-20020a05622a15c700b0034453215874mr6970183qty.506.1660924247527; Fri, 19 Aug 2022 08:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660924247; cv=none; d=google.com; s=arc-20160816; b=qdATmzwU0iSfGtYTwcFjVSYfjRcxjn1ZNAPEc/f7FAmde8IjUiUComjoEq3YZd0xnT vXZtHcORoG6Ko5fQRPSATc4wMNOR0A3vgxNOKAe8bbKWr8X5i5DJvjD5lsjt4qWQ6TwW cC2JRFVO6uA790CgcgArJ52MOoehSCKBuB42Huk2MefR83GnbERlqAOSE6bojWnjgL3L P3OgA9QrbM4qiKSuoiUQ/+KTmgTe4Mj2PiHW4aOVYWQ+vWnRYXS8Mni27P4Vye9GVRUc 3o2LF5pUtbncpse/9M2bXlOhSUiNKoedzCFimO1yAoY05eQQ1zxgClEHg+Or/q7/IYh5 BRWQ== 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=DXJfK+guYihDgdmOYphJLRS8QCxqYa74HNzsTOAa8r0=; b=GEFhFQAkus4khDhUGnaAczYq0gTBFvyF7xJoMQ1pQdei0m8ZOjciEYH22lRnZQElwO 0zPo3pgoN2NrSfgHMb9Vs0i1ESV9HYVR2Bi2gDBRleCivOXJyC8oCkTmzt0g9xTAYSIT 22t3VbScBwInGY5Pmk0nLPjCyYsA+xeESdfT+ayX6lpnXlzCz4PQIlcK67ZV6fkw+47R ms1kwnbeXc9ezk7BdjSj5u1TYU0GOIKfLbWN3XW5Q0FMbvK40fagttAx7FsZadWDerlH G+mZ4WnPLLg/H8fg3kOHyw01T5iuIyBCdU9vGPVLYJH1LqLD5MyueK2rozDGQx/oAL67 Vr/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DyUMAANV; 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 t9-20020ac86a09000000b003430589dd44si1772684qtr.484.2022.08.19.08.50.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:50:47 -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=DyUMAANV; 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]:37964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4Gl-0004EO-4o for patch@linaro.org; Fri, 19 Aug 2022 11:50:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46F-0005nH-OX for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:57 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:39655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP46B-000664-FA for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:54 -0400 Received: by mail-wr1-x434.google.com with SMTP id r16so5620057wrm.6 for ; Fri, 19 Aug 2022 08:39:48 -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; bh=DXJfK+guYihDgdmOYphJLRS8QCxqYa74HNzsTOAa8r0=; b=DyUMAANVNV/3+DdidR8URZyYe0tIx8aH5CKHdP8p6kD0wpb7Cuz/rmOyAtO1g5O9YI Vq/I96D+7FSyHJTK1yFKfHu1AmDHQyI2h6J4IGqtuoczYzXIOwaB+h7iPGNY00hum/j4 kGvrW4Jet4v97jVQpQHEKMWq7WgxiAgI083TyN0R8N7NDEWvK7+CMDadnZrm3TTNZbir kNrh1wIfEDT72O3Q5Bjtkkww7RQG+puWm926PM2FDHV04nR45tlBUaK8jGucP/HY2d76 4E2b3rrGtKw/jLdD2It8iVbwXYML4XZRDptsBBMsk4kwiISLpfeRbha8kmbkZdL2k8rJ yJaA== 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; bh=DXJfK+guYihDgdmOYphJLRS8QCxqYa74HNzsTOAa8r0=; b=w2lAE55BMKcmOelL+T1dQuoXuY0GVOhYt9iPSIT80C7H7SxT1RZLHasjLE8z99MFEt k5kuQpq9W3YkaaktYKbMtTiQSjrvQ/QsuwncSH+GUm/XeYPerfIWBH7lnWO050y/811Z vL5fskjaXyHUYqRRZN6QzX5Qg555Bbh/uEGd8xb5YzEh3Msh2LeAym0OpT9hm29cGATX vNnlISK40LMnA8NeZDYUhnGBJJ0qFfF1Pv6I0o3HO8Q4nmRyZ5P+JdXBbOBUebr6oveT LcuEoIJDOWnxN+UUVfwBuk26UqRZZsFeIkqa32L3kNLi1P2e3fIOaBMvI2aLUbce5+EM aPvg== X-Gm-Message-State: ACgBeo25XQCDcCiX1aeCzOnFCuGFjpw7vUZBl2XC81J2MQdLYbv4IoD6 TYtHOhF9Zr8WhXfKptwiurWbsbQ/WvAf+g== X-Received: by 2002:a05:6000:15c3:b0:220:676e:c825 with SMTP id y3-20020a05600015c300b00220676ec825mr4565743wry.512.1660923587985; Fri, 19 Aug 2022 08:39:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 10/11] ui/curses: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:30 +0100 Message-Id: <20220819153931.3147384-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- ui/curses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/curses.c b/ui/curses.c index 861d63244c7..de962faa7cd 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -69,7 +69,7 @@ static void curses_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { console_ch_t *line; - cchar_t curses_line[width]; + g_autofree cchar_t *curses_line = g_new(cchar_t, width); wchar_t wch[CCHARW_MAX]; attr_t attrs; short colors; From patchwork Fri Aug 19 15:39:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598509 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1505090mae; Fri, 19 Aug 2022 08:52:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hAV0lGhjQeWQQQQQ3kgS1SR8Isc3A0w0Hh5VyMJApIGITdy8h3GrKu47g3OLpKgtR90dA X-Received: by 2002:ac8:5c01:0:b0:344:90a5:b662 with SMTP id i1-20020ac85c01000000b0034490a5b662mr7022520qti.83.1660924329367; Fri, 19 Aug 2022 08:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660924329; cv=none; d=google.com; s=arc-20160816; b=bEzBf+JlbNBo/keBiu64UETXA+MjPDyZB1xSduyUVv2UGpLPgQLNlBGC3NKc5mZBOD JsrrDONfhMmAuIOSVJk60acHi6rzxZgPbD4HQBj+eXk5pCG3/9jtQ/2EeO2CqEg8udTY V70PD/oNs4UjS8J5zEdepcaoj/vS8R20w8L7UsRhffttuuRGVfxvUgxKuuY/nTGWbWkX KkGJypb1wcZ60D+o7qagriqJ4tGkYbxDQBfUYgScOYAs8IR+gPj0cgxQX62DpBP9mUTg TwRrmZWZH0ZyryLTeTw16EYhdY4tKU4txlE2/gAwudGslpdjfoU5AvTmCemLhUGBkLMu jR+w== 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=zDPOe1uObuxexnvyi+yesTMCr3hQR4+1gwfCM4+5LO0=; b=MUlujNUWQ5uTxrHJLCV+fS2Hw9Gsbi8eAn3O1GkvwraiAGR/bwedpqP9XAd3FIQBhj dfMw5bP5XsiuRfpSQ0WIg7Hswtzwj1cf4Y38v6TfFHXoqk5rSL6a6Vdo9DgI+iVAGNA/ KQmhWx5HB0tMbf1vwCIto3he20f6W6C2GXqLJUOnjPjLgUES/M2DVrJebrG80zIfv8Gb c30sYzauHfo+5ZFmEq5Hi+oT4ajvuB5EZwp1ETPAtluJNZguSeLpFi2D2AaWSHZExQJJ 3LwlEQqPh+YS9Bivujmrj7jzR9hkSM9R7sI114pRLpbnAlF29KH0ijuTsuUU+SXfCHHi ECAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RXQ76h/C"; 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 j29-20020ac8405d000000b00344580ed1c9si1773412qtl.212.2022.08.19.08.52.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:52:09 -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="RXQ76h/C"; 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]:56810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4I4-0006bs-QO for patch@linaro.org; Fri, 19 Aug 2022 11:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46D-0005le-JE for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:38699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP46A-00066e-Jt for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: by mail-wr1-x436.google.com with SMTP id b5so1346653wrr.5 for ; Fri, 19 Aug 2022 08:39:50 -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; bh=zDPOe1uObuxexnvyi+yesTMCr3hQR4+1gwfCM4+5LO0=; b=RXQ76h/CA4jXaZNLn4RwOVYu677lB4hoozg2SBc4RHoTFmiTJIej9SSYL6KQ3x0gtK iigSVbLLxoI0WM1jY7zka1QCXUXbirtltrZBy7KhZtINLjbIfccQzXx/D8iSJnaXGnjj yjccdRi7agGWSMhjEhvfxkarVciTFnCVxe2Cgvi5Y6fRFEWq/Nd16H5SOnU+KiGDZKDw EpMnKgb6SAnpfhJ7uoY0pFclRFUNh7HxkAvY8EAS7wdbYDbrbCYjaTtUdpZlHLzyFmHP 94o04J0hrNW9IsI8BrVmIg+ZXRm0drvgBrl8VxM+VBYHf3a06nImVJ3gkvdbJayN6IYg f4xg== 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; bh=zDPOe1uObuxexnvyi+yesTMCr3hQR4+1gwfCM4+5LO0=; b=chv0h1A2Hs/ER5BEdYfs175CkmwAjIjwM7zngwD6C2uBiqrEhDTkLxwoNf/83jCpqw NicDTsDLv2hmZxHF1nmLfFxqtk1sMgPjxHpElmB+rq7MS4nuiOgdCNYWhDpOxFGi8Ada 3b3w+ppk2lMgFgEy56g5AQGpoQFEkhfZz7sEQ+tQ3a/mIJdLXGlPKj5AzIDc2WXxRyAH qgI743ObHr4E2fkWp10Mv2ALfHIynaTDEU+RpQesnFJEHgtgfAGJ8UXI+xk8OlPTANqS rq26dj9mKHfUA65jIjNB799xZ9JZByMXR1u7qYD3lLvkEjGmU1pGlfH6mC+XHzPHyT+u onsA== X-Gm-Message-State: ACgBeo3Cl0tqgcqsN2xTjzj2e0ZZkrAIUp2DqflsTfr75Sq/gYDIwyLe A1/6Z5a0YS0AjlRWSM849bGBj8H7OKJdeA== X-Received: by 2002:a5d:5711:0:b0:225:2884:cc88 with SMTP id a17-20020a5d5711000000b002252884cc88mr4537239wrv.141.1660923589234; Fri, 19 Aug 2022 08:39:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 11/11] tests/unit/test-vmstate: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:31 +0100 Message-Id: <20220819153931.3147384-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- tests/unit/test-vmstate.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 72077b57800..541bb4f63e3 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -87,17 +87,16 @@ static void save_buffer(const uint8_t *buf, size_t buf_size) static void compare_vmstate(const uint8_t *wire, size_t size) { QEMUFile *f = open_test_file(false); - uint8_t result[size]; + g_autofree uint8_t *result = g_malloc(size); /* read back as binary */ - g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==, - sizeof(result)); + g_assert_cmpint(qemu_get_buffer(f, result, size), ==, size); g_assert(!qemu_file_get_error(f)); /* Compare that what is on the file is the same that what we expected to be there */ - SUCCESS(memcmp(result, wire, sizeof(result))); + SUCCESS(memcmp(result, wire, size)); /* Must reach EOF */ qemu_get_byte(f);