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: 1668203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lTiOZM14; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8QtJ1R2Mz1ygv for ; Sat, 20 Aug 2022 01:39:50 +1000 (AEST) Received: from localhost ([::1]:49764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP466-0005af-WC for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:39:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP465-0005Zr-Bd for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:45 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP45y-00063g-8H for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:44 -0400 Received: by mail-wr1-x42e.google.com with SMTP id h24so5611925wrb.8 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=BuG1gts2F8OsO9rmllUdcQW42zy7zAD77S2LTS+70P9J+rUPaomBzx2n9T597Gamm0 AjBXkYpvP4X5FCCEVfrZ6e6+1RM8qf8a8DM9E8qX8PiQ8/O/oVskRf7JXpv9Cz/cBZQ+ J4KJGsojznuQjAJ/qOA7HFFGWHxcF9VMMib7dp7NAKMzegbTeyCell83+8GJ+nGUlc2E kCzULQnKyVHHdcStsil667kEQVXB/1KyID8j3cTC4ePFZfG1oCaNGqzDdu6rtjGhGUku 6DOlRXrXZyE1VhNSPDmmC0Tvi77rBO43qTLz12wWaNhpum0h/OG6EWX6/qLO9NaiaOTu NYhQ== X-Gm-Message-State: ACgBeo21ZGTpW2ega+lECiN5fxtp23501zus0CtoiSc5a89zhB0NRiYl nHmnCmf4eguDdmBA6bj844bWuw== X-Google-Smtp-Source: AA6agR5lmc0U/0M92Vfeii6kNDiMUCRzy09lOo9WtpDoF9W4wBSwR2fq+7z2qzvwFcQ+LQrxAnsHUg== 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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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 --- 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: 1668204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=YL0d7agI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8QtK66qLz1yg7 for ; Sat, 20 Aug 2022 01:39:53 +1000 (AEST) Received: from localhost ([::1]:49766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP46B-0005ej-HW for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:39:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP467-0005ci-1g for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:47 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:52969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP460-00063q-4E for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:46 -0400 Received: by mail-wm1-x330.google.com with SMTP id k17so2447770wmr.2 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=cJo1bSp2+lm1fFwweAwYptRU7TasDzqMKvtfIngJPBuHpTTNNBrOdkNPUS/2nHAspw MmuruxSh9GOjhxq5+358ZGrWCIoRjjbSli+uJr7cWol5LGrqoZAKllczDTGaQn98hB7y uyAmXQeR8ilNQ9jYMaVSNXiRusvHDvDVzW675d4eFGnogB3Uk7p+c0u9yloMx0V8VpJX jzT12oXgHACYsKk6HruAlhgaM5oNVY9gCGPRePyWkS+r10q7kAwbhCRXZsSzere8zljY XCwNoF4wPdcD0JjSHkqHh7zi9VgbFYQORKV4kVBR4lPEWloyeZfCMkV6VfluJ0MtbD62 L3lQ== X-Gm-Message-State: ACgBeo3+iW/gX24wftYK1f0f4o4u97nJOzPl8qbWg0dzRlK/OTT+rgJB gE8kkwjFX8Do+3btX/WypSk7nA== X-Google-Smtp-Source: AA6agR5uxSaKepDECZTaU7s2kahoWiSqgMZBG4+sR97RAyCvmo3lbjupqjNWTScpJkxscUVLSUQSvw== 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::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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 --- 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: 1668205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=q6HzCqbT; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8QtT1G7vz1yg7 for ; Sat, 20 Aug 2022 01:40:01 +1000 (AEST) Received: from localhost ([::1]:49768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP46H-0005hR-6q for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP468-0005d3-51 for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:33355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP461-000649-6p for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:46 -0400 Received: by mail-wr1-x429.google.com with SMTP id k9so5645109wri.0 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=1vSYWjGTHKOPzQ1UYu+idgxHsezRDXRVvb+WCY0I6i2HsFOQd6FmxAnf9ajnf9fw3n UUruAzaGdzEheA1bJ7egSs2Wpa4qMtB/c75WJog5SQ8rPa4CytZko36oq/paqXVChtDi bRzoqUmNFeS28me2NIyXtb5Tr1c0lQVWmRxx+QDOORShcymtBlL52sYAN4/nWZRmNKZE tzP7uEBC887Rgwv6tbHYFcv9KCZwqpWXZyLBNwwnZQBMsAbANqfZhU6MA4bAjUhBnigG PoKpa6VAisLCZxJhYgYnBHHPEavOiaj4zLjJPanPrflMl4JbdUcZjgFDTRvrW3T8yTlS leNg== X-Gm-Message-State: ACgBeo30P+yutOzzDHFI2TwWiqdt6T0kQIr70HalV8Itm0Y2HXgkscIm 3IDsTjp0E5inkRMhNqKdoHfxJg== X-Google-Smtp-Source: AA6agR5QanvdtGf7E/JPhY97wj0zYeFgxNHVyHO9PRhmzvpjvlCc7RrR29G2X/25yFH3EiVy8Vn6rA== 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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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 --- 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: 1668212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=gVjmmY/h; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8Qxl02k0z1ygl for ; Sat, 20 Aug 2022 01:42:51 +1000 (AEST) Received: from localhost ([::1]:46758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP492-0003ag-So for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46A-0005hA-8y for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:50 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:39645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP463-00064G-Im for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: by mail-wr1-x42b.google.com with SMTP id r16so5619636wrm.6 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=QQSpEb8QvKoe/UBbbROrGknCXbFnJE9E6xkjLPo1mJQu4Wn/Z3l0QQ8k1vMNBHFxSZ yCarNXKYbKZtAbfZS9TFxakw6SvJuBLUMnwPMlGuVSiEpeROtqbtMTB/yNs1zYgMb70Z 7DqH0QdXEy06Fp1N9cgc8DRgsqML10kht77JfPTAMYT1Qhhaav9VWQFCk0/JmBrfY5gH oIDHZnrfH07ta0b6qPv2wmDdU6gl8NvsT4VwjEyCOThl1dCQdjQ+LiIMOdvMULx+7nwX Aganq/MzP1dg3EavV4QW/rzNsOjfTxPI6itlUoshBHWHFuK2OHelnXZkuJYYuHlMvBQ8 VXXQ== X-Gm-Message-State: ACgBeo3XzSwhzazEEWyawW1zGyl30EnUKJqpEeORfT3fj+MW80Hckfbz Ws1ILviLXEeL0EakKzyQqm8DEQ== X-Google-Smtp-Source: AA6agR4ArLL1jSZaCjaGq2lLlZO17GBCUbsPBa8DewIS4jWVQAS173iTACiEc1+ZHI07BUadwB9tew== 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::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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 --- 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: 1668213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=GzQ3s7s/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8Qxy5RF4z1ygl for ; Sat, 20 Aug 2022 01:43:02 +1000 (AEST) Received: from localhost ([::1]:60324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP49E-0004EA-LO for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:43:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46A-0005h7-8t for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:50 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:45001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP462-00064U-Qr for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: by mail-wr1-x429.google.com with SMTP id k16so5598905wrx.11 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=XSyoy+LBgZC0ZTjK7tWabmAVucuMuxNv7yRZKB0foIOi9ys8V40+y3X8gpxh4WL5lZ zSBuumsYlGuUxUewYBLS9U/aGL1ahkoWs/J4h3Y/fwp3QKQPVBtZNf5ErKAsPQe30EIB qukymQxyWk9Zz3//NWjEMCbHVUjymN3xocwHmmI53lS7KJWvgMxrDxVqn0rj2+e/cYex IsSdjgTxN/HlGC/FBwxPAOkU0zJA19RyqyYb4vkBl5xEkTu4isqb5Sv4G0DFUWdE1dDf 6PwSJRfbDSQeJLo8PjJB5f1d8j4ozdICKBfbE6pwc39fdfABHj7o0RfSHD+h/MGYzu5h 2QKA== X-Gm-Message-State: ACgBeo1o9mIjVK768fQm7ca2ulKfQaL2ulr5NPiwDoEYqZd4ahgmc7lR yC9EaVpyS8QZaRsxIQnJf5sfyw== X-Google-Smtp-Source: AA6agR7o9oiM5Ax5NWGoLwW4ocg8WHS1lP829SnIBrG4qeMikWn2BpkhDwixaCAOF1QR1luBKp7KVg== 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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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: 1668207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UGtuTV1t; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8QvM688Yz1ygl for ; Sat, 20 Aug 2022 01:40:47 +1000 (AEST) Received: from localhost ([::1]:41946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP473-0006ZA-MU for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:40:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP469-0005hu-Vs for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:50 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:33478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP464-00064g-2M for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:49 -0400 Received: by mail-wm1-x329.google.com with SMTP id m3-20020a05600c3b0300b003a5e0557150so4026571wms.0 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=wXeou4stUuSDKpYVViFJka/DK92XJzUHA2U5v4GKuBH+7IMRa969OLH/YNLOJ22jGT zMF+7EyLTASabklaTcahFxWCLuL0T2OPoT6JvyMqcbqfCs8DDvYXg3cqJYhLDXG2gr6O 19ouvcdRFl42PPZdYKz7mlhS3ULjdA+rqKxYrEhN988tE4iMjKwelRxfEMMZEwDXYs/Q Q9Dx4lI3UHq/F8z1Adh0mYzTN2W9FObMZg3qlhCGX2t+Swj7JK3jVwrfkVjw0+yRMhc8 sb35ajbRfVmYOq0cQxi9oRDV4WPSeT2Z17OaixU+sNXuoRlpqPKuVKUV/dlH2EAoaPpn tRSA== X-Gm-Message-State: ACgBeo11YWbJc8xT7lPn5ZTgMF37mGXKtOxyKLW5i9evu7Un7KASoGew ZdjZxeKVbdMRIwDY2UjSOeH16A== X-Google-Smtp-Source: AA6agR5gH8I34ZvPokMrTUVYPCruEb6H/S8MMh2sfi3OTP9DkY+TAv9WwUeBM+BvZWyA2CjOEpuP0Q== 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::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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 --- 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: 1668224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lihKwPGj; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8R6f2Ly7z1yg7 for ; Sat, 20 Aug 2022 01:50:34 +1000 (AEST) Received: from localhost ([::1]:60992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4GU-00067h-Jp for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:50:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46B-0005k5-1u for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:51 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:45765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP465-00064u-8s for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:50 -0400 Received: by mail-wr1-x429.google.com with SMTP id z16so5602286wrh.12 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=pIrO7ffYUk8VChJifZ33TETHshywQ2akLlsO6S3v5SYRcueXezMiH3K7JeIKmefnE4 zJTYs8qirqsmQko17uH0ySvwS5iHDHzPUfWAlLlsjAcPjtPMlpxBb03u9wbnuhvnDLE5 OIZ57ih4aJjns56QqxAM3auORcdKPWMhtBiJm3KiJL2POL5noe2D1ubEs/DLNNDIBcj6 T9GvMyffSIGGXC2EOPpIC1hI9mIe4NlQInficcjSFOCkIGIzysXQQK4EfqEnQlSHDEli 380SptaiP088wnRRfFRGiqI//OQda4QZ2QmnW9EHBPr8A1cwRHkbPHE1Q+SikTWB5i6B +17A== X-Gm-Message-State: ACgBeo0E2gMVBXZf67H9MhsHrILPV/fTJ+emsWA05C32W9HpUtmuXBy7 fPFe0f/EaZFhVKRzHdY0YWWfhQ== X-Google-Smtp-Source: AA6agR4ev68+RW+xxmy99eXOV+AlqS6M1f/wmO9AecmbCxg3txCKqDiVxs4WXWzuDt4KpTTgrXXFjg== 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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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 --- 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: 1668219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=AJGNqIPF; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8R2z2qnkz1ygd for ; Sat, 20 Aug 2022 01:47:21 +1000 (AEST) Received: from localhost ([::1]:39950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4DO-0002IR-I6 for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:47:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46F-0005nE-Nj for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:57 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:36429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP466-00065E-UM for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:54 -0400 Received: by mail-wr1-x436.google.com with SMTP id d16so307941wrr.3 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=GtLJmlDxhXoDimfVda/zskI0cyBVo97UFQGl7LOdvCFPLZ9NzHOdIk4OR+LFEN4owa tMYMIhYjqT2/zYdLOeqdNMowvh97fFWh1edQ9j2gB5IDwp51XDo5HwyQis0kpaC6uhvg o5c2mAPJJ3FNEnxoRSTgpamuWUf2DTwZ3xkYdDyPotAfwOw/bDeYlIZhgWXNN//7bgMl A/wFGsxE3sfVkf+LcMpUiSIYxmpW9gFjRNKggST761bWFIrh1IThnEF8/CSkebiUBqDc wQugyM/fRWS9DBDxsO5V7P02ZlxAhfriZaT5Fv4exKuBvJqvq/d75HgLsveTJwLrA8n4 8dzA== X-Gm-Message-State: ACgBeo2188q9bPcpzFSnCCcZhZUWkvzYogKkYvi6yNq0gSFJyuSh+bIK IoXaaQMcSESLLzhMR4/SoJqQXg== X-Google-Smtp-Source: AA6agR6YJ4YKDT8h30zeUVPqRq86qt5YgiWufaFpDg1jORj8PKBChU+Kk9VbHqYsLSaPzKSGaCMYQw== 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::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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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: 1668225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=A3+tajuM; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8R710QFMz1yg7 for ; Sat, 20 Aug 2022 01:50:52 +1000 (AEST) Received: from localhost ([::1]:47436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4Go-0006Pg-Lw for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:50:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46C-0005lM-B6 for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:33360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP468-00065e-Dz for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:52 -0400 Received: by mail-wr1-x42d.google.com with SMTP id k9so5645547wri.0 for ; Fri, 19 Aug 2022 08:39:47 -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=fw1SWvlAdPR//NY162Olq/8d3PU/BvycV0Y0lqpKLFy6aIJqOHw8rxopTbNJSo9/Gi 2ek0X4/erM+rwd/0QdBwqt0xtZWos3WNiu+1MOxixGeCOP9KVqcmGUEZa8Y2d925L4k/ GsE92qDiBtEnmAPOZpVp/zKzrd8y/37X/sk1r4T01uN2KfQmZ7eZRNJytyZ3t8k0LS2h 1EuzcUP2nmjJAMpGQ58mvbBP6u1Ufw26CZ7Bh5puoB2bX5phSCjda67syu7ijBSS/Whg YagsX2/ctYMwkOA2rWIxPCchruddbMXZ4sCZvJrmf/vwpOuZuY6mgMief/GdGJMzbJtj Vxqw== X-Gm-Message-State: ACgBeo1hJTf9uQW+tZl/0Q3wGA3y7ZEMRrREIOOyGxT0tkhw5EVF3HTG lCjGw3v+Kjy679WdZuA35l7Hhg== X-Google-Smtp-Source: AA6agR6dBct5DooPmF2wUlVZLk86l55DJfWxYUIfhvTjY5iU06dk3F2seoBbT8W1dOrB8u2hANiuqg== 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::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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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: 1668226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=DyUMAANV; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8R7C27Ycz1yg7 for ; Sat, 20 Aug 2022 01:51:03 +1000 (AEST) Received: from localhost ([::1]:40214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4Gz-0006sA-5k for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:51:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46F-0005nF-NY for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:57 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:36427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP46B-000665-Fq for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:54 -0400 Received: by mail-wr1-x433.google.com with SMTP id d16so308092wrr.3 for ; Fri, 19 Aug 2022 08:39:49 -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=PsRLFHa0Qoirov5C+fwBooX9tAtfK60LNQoaPEtwZNAsX7UfDMG6gMdg7/qFR3NJXB ZJzJDMQR8vlYm5+vYDR+w/kCGrtz1dcuu53Khx73U34utMkTlSyJSlZCjnO5HL8cyPBU yqxRwG0YUmQb+WCRNlo6LkgOqTcYKdHnZIqS24zXsHemljJJfF+NB8J/Viskx38XwHbT yGf48aR8+Lu/YQb98HKj22N3/It6DoCH5frpeITe75xhKlT4++qUiMvosSOjjcfLbVoO C3mWR8JBC6bfPiAF8jKEex7OZv5iOaHnyLPxpj4aYSSWLSXDN/kyOKnC0jh9v1X9t/TR vNjA== X-Gm-Message-State: ACgBeo3r0+uGMi5ekK0cS+x68auOED3LAxrzSs+pxUVKFiHo5EDr/2dh cB6OfgBQP3TeVChtzO9OAaFW0g== X-Google-Smtp-Source: AA6agR57dyP1dzfOanR3Hupj+a3l3YMUK6P8LV81vQ26+VowFrOhQJ3xKpBuNcL5p3eKBDo4EJg8kA== 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::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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: 1668222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RXQ76h/C; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8R3p0QHGz1ygd for ; Sat, 20 Aug 2022 01:48:06 +1000 (AEST) Received: from localhost ([::1]:48566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4E7-0003iW-CC for incoming@patchwork.ozlabs.org; Fri, 19 Aug 2022 11:48:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP46D-0005lT-Im for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP46A-00063g-2D for qemu-ppc@nongnu.org; Fri, 19 Aug 2022 11:39:53 -0400 Received: by mail-wr1-x42e.google.com with SMTP id h24so5612711wrb.8 for ; Fri, 19 Aug 2022 08:39:49 -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=SEZpNb5MnubvsJ0D6GEctwNq7x3F3qfnXZ6NQsNb8co2nQXMxiCpi6/UJSd73tvT5Z uo0Iv1aEQaNAV45GNMrLMjWI1zi3Jx90tjLqaYvEXdCzKbwPYjaDHeIBI2EZZPKeBzOf XKyYamRUPbFGlH3df7fJFouH0ZwS1vXwxp62ReFrPUld0v8iC+jb98h8yhy9mEqIYOfn JipRT5XNyg0GRPNkfqDVep9HtM4kMW3ldSQ+X+XtDpzKeQy2JWghplTuh/f+1r5FJLft XTE+wSTkbni8Bvi30we/XLC2fD4cbdzv6DYQA7YSrAQdGLk1TlHS2tc+oWMPoCOFAZVS RXKw== X-Gm-Message-State: ACgBeo3JdRU7E5rTXY2t/c3slOP7Qd9YqrFd5zZ7g1eLXQWlwDLi9n91 uwou73h5Br2CJqW/Vhrz7A1NTw== X-Google-Smtp-Source: AA6agR5A6GZoW3JsZOQPJd9YZK+EiySrV8mTBieN7MIq9baZBH1YjZY0w0pnTUVqmnlPXQpFaFAAtg== 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::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-ppc" 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);