From patchwork Thu Sep 22 16:35:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 608247 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp500374pvb; Thu, 22 Sep 2022 11:21:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dXj1Bkl0RwgXscyo+g9Espoq68tBijl2Jqo2XKv2Va2hcFZn6Ji4nOSIqhxoOc5NEhqJA X-Received: by 2002:a05:620a:2182:b0:6cd:ccbd:5c38 with SMTP id g2-20020a05620a218200b006cdccbd5c38mr3005241qka.695.1663870909054; Thu, 22 Sep 2022 11:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663870909; cv=none; d=google.com; s=arc-20160816; b=di3rWr1KiYR/38ygSMVVj3hkw7w6rxSU7gTabmdIkH8DR5Lxmz+v200G1N/+asAALM +D4Drtvm3MdMoNt7HU6cc+zU6f0CHKb3QhLngfjxAkha1lWB5MzFShyzXSdN9NqIZPdN wu1oAcwYHanUTO4BdoBpmNHhTJG4otMMzbxCU0T5+WXQjqqefk39JiEDTM1By7zH4G7E XLbtr4/CgmBZRBQn2MQstiacQYuxnxRC1KZ1kr0s5cBFA8eWeApgWIe4TvVJxGdvwLUX CX+qLvadap/VxLzPmpS2/AXLieuyU3oQ4vGrZtV/N73NtWxYaaDHVjOkRVfrWykE3Eyn 8ZdA== 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:to:from :dkim-signature; bh=pWGWLI7V6s9hSnLclf2++UgbHO3xok2cYFgCGF9FY5E=; b=iZ5K5+U74MosjQ1UG7MzgkzIBhmnwJYSU2i67f4uj8LC6AuyvFKDMzBJHpN5agLMpk 6lgfQ3GntN4+XMMcNfEQd27PZzPhzlow2VW2QXNQX/l2SG+lF6C0tDZnP3rw9YFOpsz/ 8DAouvTGiKGPN5BLdg9B+Ym1xPPg0d9n0FtPdyhnlWHvgydv8k1sAUOVQps//BDjhAdB aKLWXeKSiOUFLc+sjdPy2gqjRtmK4iWBQ1ogpDVtVtu3IfiBjEkV8BihM2a2F1AMraps DAMImi2iSnSWvND5aA+JrheR96gPr3qWa7Wx3uzugcRenhastIIWlTGiXku3lzzsr3BG LaDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FcAK5RqG; 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 bp13-20020a05620a458d00b006cf5ed02336si1332159qkb.637.2022.09.22.11.21.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Sep 2022 11:21:49 -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=FcAK5RqG; 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]:37428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obQpY-0005QI-HT for patch@linaro.org; Thu, 22 Sep 2022 14:21:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obPBC-0002CM-7B for qemu-devel@nongnu.org; Thu, 22 Sep 2022 12:36:10 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:40844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obPB8-0005O2-P2 for qemu-devel@nongnu.org; Thu, 22 Sep 2022 12:36:01 -0400 Received: by mail-wm1-x32f.google.com with SMTP id v3-20020a1cac03000000b003b4fd0fe6c0so1682646wme.5 for ; Thu, 22 Sep 2022 09:35:53 -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:to:from:from:to:cc:subject:date; bh=pWGWLI7V6s9hSnLclf2++UgbHO3xok2cYFgCGF9FY5E=; b=FcAK5RqGmh7IlaIZKmIQcWNWoElHC5uHTZ5wZI2zGScmuhTu1Ct4pb9VQfodKnf7CX DizxyzEN+6Yz7VljlYXN2FFAIds6rU324drKPVkRjmYjUwGcqI/cMxmvDjQBKwpi0JE8 mZo85V1Sp/dyg/xCGzlQxtfzir4xgddxY4umSteIWBcXpgq0Zae6CNFT31nyIurYZFxf T/HKjCLzqznQxDL1wnMriuu6hihNwC9NYW+zetcyDUH7i83aZl0E8poGi7J1NEiIYK1h 1QI1vwWRAfRVss7ptOLMao5OcSQ02/wzrI8QhfvY6WPM3UXEpxc2BUK9KRKSGSG7t+Pn VbFQ== 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:to:from:x-gm-message-state:from:to:cc :subject:date; bh=pWGWLI7V6s9hSnLclf2++UgbHO3xok2cYFgCGF9FY5E=; b=ezke81ZowlMH0qBjOhCHEGg139NnWE/GyNhEaI9B5RV4GZ539pmv7dmWRCxZTb65Rh /CTYquZvwZiwpP106OdsCKeZOVBIGClKyLjxSSJbPKrX0Fic2m8wBQhcZ+V8YP4h8fw+ 1xz0Eolh4wZBOOddlPCZTCrSn2yAA1mGME0ikQ7DKxEHu4F/cW9+XaU3mFRFgwB7fCAA 00LQGFLioTFt9ktteEIM7UNRsIjstRdWdTdsk76sdox6w0ksmrLOJCe5DPpy6oit7KQ0 dtkRLT6YQfUdOWGZ71xJ4APtT0A8DZdmoAG7L9BiR3j87oETngBnYA9daSixX7YxO8dC x/iQ== X-Gm-Message-State: ACrzQf3sR98tgMn8FpAZZ41V3S3pO1fELsfL6bj3XX4YlQEEtTeOUefw 8B88Aw4/Wr6Fl/8lptHuFH8oSZFygeq1Dw== X-Received: by 2002:a7b:c051:0:b0:3a6:36fc:8429 with SMTP id u17-20020a7bc051000000b003a636fc8429mr2936125wmc.78.1663864553607; Thu, 22 Sep 2022 09:35:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id iw1-20020a05600c54c100b003b3401f1e24sm6452599wmb.28.2022.09.22.09.35.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 09:35:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/39] chardev/baum: Use definitions to avoid dynamic stack allocation Date: Thu, 22 Sep 2022 17:35:20 +0100 Message-Id: <20220922163536.1096175-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220922163536.1096175-1-peter.maydell@linaro.org> References: <20220922163536.1096175-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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é 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 Message-id: 20220819153931.3147384-3-peter.maydell@linaro.org --- 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,