From patchwork Mon Apr 29 16:59:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 163046 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp2130662ill; Mon, 29 Apr 2019 10:02:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUPp/jruZK8QvJf8G1WAyuE+ImCyTKnD1ntttBzjtxivhmGOzPsImb1DdTK9RhdNVzNAwM X-Received: by 2002:a5d:55c2:: with SMTP id i2mr1300176wrw.2.1556557340309; Mon, 29 Apr 2019 10:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556557340; cv=none; d=google.com; s=arc-20160816; b=hcN6rd6WWZ80N98x8YycO60eCw3BjEHk0rLF1kYkYo7/0oNlB/Oi8Jyiq82ZAhhE8M cQMQ515CqHOmytQB5OYkLSrTkr3qQcBxG6eS6CsT0bE45iqUyI976mTt/HFncxn4cfEF 51T+rBcCVDY81AYCAiFdUDuOr4qToLoULDYiELq6iEtdTSu7NBWGrL9LUC9h/BbjEt34 BuxSlj45j3RYIFtbN0Bf5vrwJTAXA2DpyhM/gbM/104EmwhXCiv/HlwqFwPYOCJ0PVfq Ez4/kuB1ur30BXYDeLIx1HxMR3DwqZ78/eWwybihYtG+us6KTVOjUlQqiWCH0qThjTsR kfCQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=PoBbqKnm48icKHr+pnJggpSaSU4ZKCdGTaxhpvXU0VQ=; b=vKvfre4euKF0aIPUc9VgVNa+qZVj9cNyEyJkp/dJZAtb/2EJoyULSIDYvMPTIP/pT2 rhE3hUruKQgozoyNIHH2drEkbWlUuR/Cbq2uTFL7+72YpU1Zd/lMAQA7JlopG1CZV0ux Yymy0RcmvC0DimFRa7Rs3/Jqh6SWZqjzMzjs9SjfdXRJs2sS0YG3Ug6MOYdFhu9IA2l3 VtjjgJJW2HCGCG73QWRvvZ+JOTTsiRsuJWTI0mWQwVz5VlahzvFOWy1klne3xH1zUQPk TBaEFax+skO3Q26nDkJWHki9T6h32fuuthhD3XsjSnl7PujQcVno9+jG0kFJ1r4AYYm2 U6og== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iJYgOnzH; 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=fail (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 t3si2231436wrv.420.2019.04.29.10.02.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 29 Apr 2019 10:02:20 -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=fail header.i=@linaro.org header.s=google header.b=iJYgOnzH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:60612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL9fX-00053s-6q for patch@linaro.org; Mon, 29 Apr 2019 13:02:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL9eB-0004DP-Ka for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hL9e6-0006PE-Oz for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:00:52 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:34428) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hL9e4-00069E-19 for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:00:48 -0400 Received: by mail-wr1-x430.google.com with SMTP id v16so14710340wrp.1 for ; Mon, 29 Apr 2019 10:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PoBbqKnm48icKHr+pnJggpSaSU4ZKCdGTaxhpvXU0VQ=; b=iJYgOnzHanS8MCyf/Y/TsyhGhNhp8j68clu7GSzxkV8oyNeseLQdQN2j6h2tpNu428 tMJgG9tAwIJyWypDVL0m3M8m5uxisI4BK++pkqnj/BFNkWe9UouweFt7uUdWNqZPaBNU GrTsYbXNg3p9cvoM/1f05Z/1rbvdtYK1WwknUBdbA7cCwjv4dyAsysyBh/Fu35/W+wLa 2FCIcu7uHQ8jNGBlgbjpH5Sx0dZfInLkrp2l4HXipqSwUV8ks6EPRUFLcUcLu3C6lNF2 +lboKxs6Wu8lvz2YWaG2vZVyiaEiLmtfxdqX+pmSk70urzxEPQeqhcEuSWYkigVgn70M m6Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PoBbqKnm48icKHr+pnJggpSaSU4ZKCdGTaxhpvXU0VQ=; b=g5r6EJyAIAC0CaVmsqwQvMlMAXFLrChPAruHlylFJgIkz3AraZBg56p3/vSEe3ssMG t8ljKC49TZXSjOx0mCYsLDHjS5Oylq2SAaB7d+D59K/k40iTSGv4hgGbAWHQ2F69kguo OgjcPJSI3Lbdtvzf3twrSpH5rmMk2gwDKz8sZEp3AoXkonLnwYNrFJ927/898e83/po/ iVt804+IkNQ1RYLXd6QymDgEbdNUFFtxxKbKOhsm69qyXZ/TYg6LTvvLHqAjQxEJBzur K/sW3IN025h86cHOeLRW5OJL6xqW7H0Js2eZoj0F4ube9hIeSdmuHAUcrteNez9vf/mE aVTA== X-Gm-Message-State: APjAAAX59OWf0uMrnie6DZvV6NQ47kRNdELOFNl551teCO6ZigH+JqZS 12oaIfxVrsgY5eOxyhhXJM2bfdA2V5E= X-Received: by 2002:a5d:410f:: with SMTP id l15mr15384783wrp.6.1556557235470; Mon, 29 Apr 2019 10:00:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a13sm36896wmj.39.2019.04.29.10.00.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 10:00:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 29 Apr 2019 17:59:50 +0100 Message-Id: <20190429170030.11323-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429170030.11323-1-peter.maydell@linaro.org> References: <20190429170030.11323-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 Subject: [Qemu-devel] [PULL 02/42] hw/ssi/xilinx_spips: Avoid variable length array X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" In the stripe8() function we use a variable length array; however we know that the maximum length required is MAX_NUM_BUSSES. Use a fixed-length array and an assert instead. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis Reviewed-by: Stefano Garzarella Message-id: 20190328152635.2794-1-peter.maydell@linaro.org --- hw/ssi/xilinx_spips.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index 16f88f74029..c615058cc1b 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -429,12 +429,14 @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) static inline void stripe8(uint8_t *x, int num, bool dir) { - uint8_t r[num]; - memset(r, 0, sizeof(uint8_t) * num); + uint8_t r[MAX_NUM_BUSSES]; int idx[2] = {0, 0}; int bit[2] = {0, 7}; int d = dir; + assert(num <= MAX_NUM_BUSSES); + memset(r, 0, sizeof(uint8_t) * num); + for (idx[0] = 0; idx[0] < num; ++idx[0]) { for (bit[0] = 7; bit[0] >= 0; bit[0]--) { r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0;