From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249059; cv=none; d=zohomail.com; s=zohoarc; b=TSWLWW/LO4LN9kMQR2Rkq801pnnCWE5ZbH0ot7J0LB0onTN4LVhabvE3vlSUoeiN4GzuhowagnrvFHdIxUbJcEQvc6fL4r7DJ4z79eda4SFeRjTWnX3XZyJFpYi6QYvqzT1KSLV04wWb8yxsblPwu9/Q/XjlkLtsdaj4DM4FqoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249059; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nfSqtx2bsWJBI4JnD1Mt3pZTQzkiHMCXAS9LcMiGD6o=; b=GTaQXwYGsbwLN6333ciCZqmwn1ZYkbfBS1sfS2B+SojS/0E0hwBMJK0UW3Ge7zCMGvF3S4ZO7aqGCQtdz5kpvncePJJ4eraMENUqyO1ZgKJDuoNJ/EZtBA6LKSxiafSi0xlmAlj6zsJfvcAXpdkQ4Bw85fYGetXF+ZQppcG05YU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249059132466.73430145369275; Wed, 5 May 2021 14:10:59 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-7Q_Az6ewOhCPFyiN8c-_lA-1; Wed, 05 May 2021 17:10:56 -0400 Received: by mail-wr1-f69.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso1207077wrk.14 for ; Wed, 05 May 2021 14:10:56 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id i20sm6168267wmq.29.2021.05.05.14.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nfSqtx2bsWJBI4JnD1Mt3pZTQzkiHMCXAS9LcMiGD6o=; b=iup9TjAdyCmwZUIom/ewF1sem1FUDPYCdrolUTBgkJbblT6emIJVprqHUzL+qHolnyQTyf 5uwSE1aSTu15/LtGpN8kJCfFoTEgui8fJl5EiSaWaJeoSIkWdewHvpKZ41uq0AIWYIvS/e xxw6KEDgupM5cZRq+vjfN2UPUxYv1T0= X-MC-Unique: 7Q_Az6ewOhCPFyiN8c-_lA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nfSqtx2bsWJBI4JnD1Mt3pZTQzkiHMCXAS9LcMiGD6o=; b=lXJzxAe6FfYi1jJO5Z2cQe8QA9ky1Z/9c3tg4IVsUPnR4VHoQL5+5Zgy9+fsKJ9qn+ NdAxq15cTD7mrLz+6+Xkxl3oGhyn2/8pzQIHMjrUWgV5IGqEXFXprsZ+NOoH0Lep3c0V lRUtzIc+mz08tqqMgdWy4xj5+P6ioV35aemoNrLVsfe5831OHsvrJD+dgkHj/tKfrAlH Cx9IrzsiXzjTJjyV5n0BdXPTI7GQVNWhxMlZAyQ9tIwocvX/q1576PEO6GvHb0f7uZiz 3gT+2fXfscqPI0n8N5ccGKxP+EpsCkBGN+wsh2ZjQybMp8ai4+zPEi64xJwldz6LNX0O r+bw== X-Gm-Message-State: AOAM530O7F2zSiAuRgNKwqga3UZqBD87ttJzb3h68N1eo7RTiz80t0Us O9EjIiBVSGDCj1lKcHfBjkjpy8Lks6PTTl97tKDcVP7CbDjY4tAF8TAbEHFThsM65aQDRy4n3tS CLlZFk7f0UD8QZA== X-Received: by 2002:a5d:4e52:: with SMTP id r18mr1005298wrt.179.1620249055022; Wed, 05 May 2021 14:10:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdcO6k4STJUW002h/z1xwQnLLkjuTPTZ/XOg80aMMNDfDaqPBnBBRL5M9D/HGhVmHgmwSWKQ== X-Received: by 2002:a5d:4e52:: with SMTP id r18mr1005281wrt.179.1620249054847; Wed, 05 May 2021 14:10:54 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kevin Wolf , Max Reitz Subject: [PATCH 01/23] block/vpc: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:25 +0200 Message-Id: <20210505211047.1496765-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/vpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 17a705b482a..9ed144331fd 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -509,7 +509,7 @@ static inline int64_t get_image_offset(BlockDriverState= *bs, uint64_t offset, miss sparse read optimization, but it's not a problem in terms of correctness. */ if (write && (s->last_bitmap_offset !=3D bitmap_offset)) { - uint8_t bitmap[s->bitmap_size]; + g_autofree uint8_t *bitmap =3D g_malloc(s->bitmap_size); int r; =20 s->last_bitmap_offset =3D bitmap_offset; @@ -556,7 +556,7 @@ static int64_t alloc_block(BlockDriverState *bs, int64_= t offset) int64_t bat_offset; uint32_t index, bat_value; int ret; - uint8_t bitmap[s->bitmap_size]; + g_autofree uint8_t *bitmap =3D g_malloc(s->bitmap_size); =20 /* Check if sector_num is valid */ if ((offset < 0) || (offset > bs->total_sectors * BDRV_SECTOR_SIZE)) { --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249064; cv=none; d=zohomail.com; s=zohoarc; b=Hj1fXvYGyCZfSI4biJPQHyQl8CantuIKURbpTGF6K5PgkVYgx4LGG4jwiFCKoG7T6MWaffbJi0AwOz+BfB+8Xt08CAMJSSHC+Kfq+fZ36XNxtHq+BuFDgwny9zUTVq9JwxshYAPjKjtgBLtk8t1+xvdhQWHdDM5f0ABWAQBp+Cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249064; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=yGG470A3Jaz0DhDPrHiZEZ43qAaY5nNHcaGiMNivkn0=; b=T1rkSugWLV5fy/LQVcCWnCaojltMWTIDFNy8gx2nClTaWhfNobmqIFvMJ+V3qNDKIiXlcHcCdpKcmnjVCunzDADsfjBbrT6n+PewZOgdyIrFz1qcplE5HZHQXj/7iT+eOpFF7scSBGPjI6VhMPwEX4qapyCCa3neFSTrAWuZRhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249064019575.598077105788; Wed, 5 May 2021 14:11:04 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-FBNmYAjhOSKaRaO5k53uzQ-1; Wed, 05 May 2021 17:11:01 -0400 Received: by mail-wm1-f72.google.com with SMTP id v2-20020a7bcb420000b0290146b609814dso728869wmj.0 for ; Wed, 05 May 2021 14:11:00 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id w22sm7363254wmc.13.2021.05.05.14.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249062; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yGG470A3Jaz0DhDPrHiZEZ43qAaY5nNHcaGiMNivkn0=; b=IA5kDYyhaXhp5ZROB1kMpviUfV9PjURi4RVCvVwpzAkdgD9eaHdyQiSeDVpE2oF1VJ6PXt KSdfNrdbdDDZI7Er1LDwmjgSoOc22XYVlLiMTCviPVPf/9Gjyquqq3IbCVwjrc3nEQdBdE /sspVmTnqfqBNjVHGiNarERCWVyHBKA= X-MC-Unique: FBNmYAjhOSKaRaO5k53uzQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yGG470A3Jaz0DhDPrHiZEZ43qAaY5nNHcaGiMNivkn0=; b=awp2hHOWAB97W0KMNm/rIlB+g9mmgYLxqcSCLVQ1xcaAoCVRczmyw1d4AE1VFyKzfT Y6YIKLq60q+Ftcw74ftdYLNU6v4PlpvbpjjsgBTG0OYUZj7uKxhRNcQYBa2qGKzTbjv7 R/SchvaKKtd+/vsK1Rwlv/Jz+BvC0nPluQNelhr/FrOH8Jo3G8xKRK+iez064OW2z4hQ WTLwVxhV8TiHy2gV9Ofq+bb+0d5z8zO6s6+W1hw2rdjWCfDHLBbvMc5Tc18kZ6ighvfS /yUZjK1JFx/i0wn72gZfpF736j3fr+XJ2PMy9AuddZ0rkZimlx8KP8UyFHaq48w1izIC HhnQ== X-Gm-Message-State: AOAM532Yg9BckDvUqJkzjiLIb41G8Fy7hnPNBcre94Hye8dMpjhXfHNk /HI+O/7LJvyB625CQ2rsYXEKLM8G04o4uv9u7f6qFLY0lbMWI3vNdtyfWdcida9HUTN4lSe9Hlx d2sRP/NEY699foA== X-Received: by 2002:adf:d1ec:: with SMTP id g12mr1078574wrd.294.1620249059905; Wed, 05 May 2021 14:10:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIGIU2wTR52pvVBtbElhLcb5ebrIvmDSZz3nPUhGj9Y9gRioNSfoYQBa7vB+kIDXVm3OwEMQ== X-Received: by 2002:adf:d1ec:: with SMTP id g12mr1078568wrd.294.1620249059800; Wed, 05 May 2021 14:10:59 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Samuel Thibault Subject: [PATCH 02/23] chardev/baum: Replace magic values by X_MAX / Y_MAX definitions Date: Wed, 5 May 2021 23:10:26 +0200 Message-Id: <20210505211047.1496765-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Samuel Thibault --- chardev/baum.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chardev/baum.c b/chardev/baum.c index 5deca778bc4..adc3d7b3b56 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -87,6 +87,9 @@ =20 #define BUF_SIZE 256 =20 +#define X_MAX 84 +#define Y_MAX 1 + struct BaumChardev { Chardev parent; =20 @@ -244,11 +247,11 @@ static int baum_deferred_init(BaumChardev *baum) brlapi_perror("baum: brlapi__getDisplaySize"); return 0; } - if (baum->y > 1) { - baum->y =3D 1; + if (baum->y > Y_MAX) { + baum->y =3D Y_MAX; } - if (baum->x > 84) { - baum->x =3D 84; + if (baum->x > X_MAX) { + baum->x =3D X_MAX; } =20 con =3D qemu_console_lookup_by_index(0); --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249070; cv=none; d=zohomail.com; s=zohoarc; b=UYGxNOYVfhsO9qzzGgn2+2+UAa0Hggcw1xiPAF9bq96Wmhhas+zaoRzp/ROzUKn/vklKofm67wUrHY4cB3U3zL+sNdNe5f+acHauTmSyDzVafUPEVpQ28Z/feu9t1CHr/I+SlKat95kr5jz5SB5Hbju8Eo20jQuXAFI5+v05OrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249070; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jDbW5AjqVLLqIRW+qjBQwi317+pzRCZswt2T1a+tgz4=; b=R87+epvD6sjbmdUJHeLnxdHXszH2Y1fDCnv5TZc0pSiGDuzjx5UDUXxZd1r8fERkgRSEx8IGKjdqZU3MccN5oAKWO0DOXtrUWAonUY8t45aWSYVKLhVMadRznNwnJRRCSHykDifPrCXj6+R0AwfmJNKvKmrzp5fAfMtNspxzrLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249070560538.3853345795826; Wed, 5 May 2021 14:11:10 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-2fwpHHRUMHm1UfdoDNVrjA-1; Wed, 05 May 2021 17:11:05 -0400 Received: by mail-wm1-f69.google.com with SMTP id x7-20020a7bc2070000b0290149dcabfd85so703372wmi.8 for ; Wed, 05 May 2021 14:11:05 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id o1sm4073966wmc.6.2021.05.05.14.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jDbW5AjqVLLqIRW+qjBQwi317+pzRCZswt2T1a+tgz4=; b=HHmtU2ZMVnl8xumoNKZBbUuggR/iI5V5rlVZkmHrelW6e+VlshMH2o1oYQrBpXvw+MtAEe Dsf+PzmfZeO48B6Aud5mCM0niRhpU3G3QER2ZHSnuH3TCn/OcgIW+P8V2x9pBu47/OVKrB MWHdpt34IjFbjPePB/lHYMTS6bQ9AsU= X-MC-Unique: 2fwpHHRUMHm1UfdoDNVrjA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jDbW5AjqVLLqIRW+qjBQwi317+pzRCZswt2T1a+tgz4=; b=X+aukdv7V1F5pMR6XhnMQLXdtKbXrDA+e7tsvo3bt9rMcUb0zGNNeZL0tSUzqHofBP W/FxG3BukcsYokGGWKfgplfvtFXupIztFPplddJw85yoPpG/E1ffzrwdfkLlfFopVt8g cfe6nM3lRONnbROjHR7iQ1uMd2R4f17lS90uRuZiWTUSQZRQdSCtbAhMUzVOKqSRTsRX 7OrbEcK+dV0IsY6aodXHDpICYxc1HKnKXeOierxo0ttmLN6JErAgIkngPljBibKvx7Zy FG9nQa9CvNXSHigEVDFsy7ca2+30XPwgpQS1TRaXIqo/VkATynRP1qjs17VO3jmG8T9/ YPqg== X-Gm-Message-State: AOAM5320UOvKA8etgkOXAis+jF4P3wA3vZCBD8dYqNcVXqjfq92n0FlP NnjoYG6DhUISQu2uvN2aTsFctxOneR/9YK+vObpeB92k3JLhyzgUlnscQYINFv0yqBTCPxq+vu8 xFuHFb42uFiyk2A== X-Received: by 2002:a1c:750b:: with SMTP id o11mr12022971wmc.188.1620249064704; Wed, 05 May 2021 14:11:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOEPOao+qykKQIphPjsuJSYjxkn/EPllDV0Z2ZMqGBHfz+R9Qb+afafsKtq+M5cPi7UKuSqg== X-Received: by 2002:a1c:750b:: with SMTP id o11mr12022964wmc.188.1620249064582; Wed, 05 May 2021 14:11:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Samuel Thibault Subject: [PATCH 03/23] chardev/baum: Use definitions to avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:27 +0200 Message-Id: <20210505211047.1496765-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Samuel Thibault --- chardev/baum.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chardev/baum.c b/chardev/baum.c index adc3d7b3b56..0822e9ed5f3 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -383,9 +383,9 @@ static int baum_eat_packet(BaumChardev *baum, const uin= t8_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 =3D BRLAPI_CURSOR_OFF; int i; =20 @@ -408,7 +408,7 @@ static int baum_eat_packet(BaumChardev *baum, const uin= t8_t *buf, int len) } timer_del(baum->cellCount_timer); =20 - memset(zero, 0, sizeof(zero)); + memset(zero, 0, baum->x * baum->y); =20 brlapi_writeArguments_t wa =3D { .displayNumber =3D BRLAPI_DISPLAY_DEFAULT, --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249075; cv=none; d=zohomail.com; s=zohoarc; b=It6YeHf1J6QaeGVcfWq0co4yQhXugbxWgo9ierTWlRpf5J0+BbKTQck486kCVLXi3Zf/DG7y7Q8zvR1DtarnV7CLUVUIoIuBEYVmI+8JKRa6hbWm/PfdVSC/HgSA5DCdJAwugHuja4unlQIb/RoT+9mNrh08FuTJW8/ug4F+YjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249075; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Jsw0hjQgHEh8fe+V8icgihsn1Zo56TzjPc95CU2mxS0=; b=e7cUGl0RUTabFBFmKtwGWTkHTsQ3kNtRhQtrqfP8o8w0/pc+E7T3eOwfLI5Xo0AYdpMwdUCyZGoO7AoByXxT7Ad78Nl6Bw3xYdhmAIjG/YD5je+MnhOotAoumdgZgFO7psP/l9ZpXun71WHHBN06ehNp6H0mdhDtrc4FyuD6n84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249075470716.7879379843074; Wed, 5 May 2021 14:11:15 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-wIs0kaLqOdqjZqvOo92ltQ-1; Wed, 05 May 2021 17:11:10 -0400 Received: by mail-wr1-f72.google.com with SMTP id 93-20020adf93e60000b029010d9bb1923eso1219538wrp.4 for ; Wed, 05 May 2021 14:11:10 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id m6sm761402wrp.29.2021.05.05.14.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jsw0hjQgHEh8fe+V8icgihsn1Zo56TzjPc95CU2mxS0=; b=iJYLh8lkFwIDjTIpoOgB2F/8grBvVei5TU0///P3gou2FnwOtsvKfD1HCIB3IKy1TEyMSk dH0i0tbOBHl3StH9NX6FyrpjlTP144AV+HXLJxsvmQ55mLd34KMOJm5HI4H9QKw7ccd6ZD vY7gbMYC8o/36TQAAUseh/clb5E7cto= X-MC-Unique: wIs0kaLqOdqjZqvOo92ltQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jsw0hjQgHEh8fe+V8icgihsn1Zo56TzjPc95CU2mxS0=; b=aB6dt8vPugZ2nInp23wtyhwgZHLxU/oGkkWkNEGaOoKQ5lM2CavPygoKrZFu34OKep m+J6NNc+WD/t5jmE2NCuAHYMQwa+3NUj9BAiGk6z5jrt3Qn8dX6zR5jlH19PKS3cle9M e6ND9VeIuxvsefvmTnY/9KZiz95LOfrEIdgWbd6gJnbGd7H3xGvhE2ehWnhdS+/3Yv4s PT1sUlY9is/jG/fa+Yui00rSlblWQ8ulTc2Ufz6magiiNk5Y5TU+IZ3rlNg3nR/IkIHk 0mWni/pRE3ioVmJ8HPt+OCIIqrrheXdHul/XhNyj3wkQQ3Bitp4U+khUnpCh7gET2cOv AH7A== X-Gm-Message-State: AOAM531yMhhSLRIS2QdPzPha/l5DYpcCyWOOBYW7WzZPNXz3mLsmW8ub C/g+/y4qzxUJ4kn4zJEfGZgGBIk2u0F4hfsBxS+bpLnqRb8Z+aSIgGzWcIC5kvFElaRTHMZpazM 7+mAWe+Rfcitnyg== X-Received: by 2002:a05:600c:2d42:: with SMTP id a2mr11900711wmg.99.1620249069601; Wed, 05 May 2021 14:11:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFx12/Cfj5SAGn1R6ueiw6IPzEuQQsz5cieDZOJJF77UKfykeNTFXuTfy86XJg4oIqT3Aung== X-Received: by 2002:a05:600c:2d42:: with SMTP id a2mr11900694wmg.99.1620249069425; Wed, 05 May 2021 14:11:09 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Samuel Thibault Subject: [PATCH 04/23] chardev/baum: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:28 +0200 Message-Id: <20210505211047.1496765-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Samuel Thibault --- chardev/baum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chardev/baum.c b/chardev/baum.c index 0822e9ed5f3..bc09cda3471 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 l= en) { Chardev *chr =3D CHARDEV(baum); - uint8_t io_buf[1 + 2 * len], *cur =3D io_buf; + g_autofree uint8_t *io_buf =3D g_malloc(1 + 2 * len); + uint8_t *cur =3D io_buf; int room; *cur++ =3D ESC; while (len--) --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249080; cv=none; d=zohomail.com; s=zohoarc; b=bxjnMO41ePYjy+keqYtQE2j7mhleXjpKh06ZY0slIetHzf7AVcJgCj0OnvVwCzbpgRGgKTbLHymtJD9X1Avt1FeEaLo2Fh+Pt+z+uLzysmk+o1uLk9EMJcsGf+35L/Ath6RRHRb5rkO1LiVYvkeOsEQ2X0u/l7e7jZFHgJaU0sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249080; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=8XsKwZNupJ+4f3H9PdgeWNChZDELAQClzri8f7pUD+M=; b=frF/Us+UMBsORe1KKc1LB6HSHvflcNUTF+WGFOWPXibO4hVbnBsbDvqAN3nTAazEybH7fxGjktGGZ6/pCMBR0a4HBIZ90hY/KGm2wNg5AwgYlOakhS6+sVYAWGfU5fG8W0EWrmrSzkEqLLpreaLWgqlAtbn/7MXJv2tLDL0YMj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249080515338.66738930618817; Wed, 5 May 2021 14:11:20 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-YVtMglimOK2Z5ESH8AHgTQ-1; Wed, 05 May 2021 17:11:17 -0400 Received: by mail-wr1-f71.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso1207458wrk.14 for ; Wed, 05 May 2021 14:11:17 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id h14sm814414wrq.45.2021.05.05.14.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8XsKwZNupJ+4f3H9PdgeWNChZDELAQClzri8f7pUD+M=; b=Nj2zWNu42JRoqzySuk9CxLKBUbbFBVbf/StLmNHTHMRAgtQ70xBtQGaNKQ8ziQIEXtvJ5v twesmA+kDs+jgLNk01dPwg1HzpdYSt46TRc9b1l+CKSJgdRFkI3+jhyKNgAOJGZf8I31Tb Y8S8cQchgeSZ+628lGue/p69LkpvsOQ= X-MC-Unique: YVtMglimOK2Z5ESH8AHgTQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8XsKwZNupJ+4f3H9PdgeWNChZDELAQClzri8f7pUD+M=; b=h7c7/arvm6bhzMv/5pcIxRKsrXG1EArjB9iFG+yksJq4hG4OeryCaTqHbx1FNuwEra eZuzWgkS+o65jSIn6hs+PPzCQn5FmIMcq+k66wugwunqtIGsfMdZM0r3nFBFVhNnvvII yxucN1RJB1H0gHptVcDRpyj7Zz9DqcykD0iHf4FDC2jvurn358osYtlLwSljGQhWh5tQ snay+FVt4AsZ8wxgw0j6NM5vYGAh/weL6n3kCZmKVAjJ/qR8k4NfWPjmjQFEXGoLjynM izTYPFMM/izE/hnOAqDhE70ZjirrZRYLI+ZoBTGPkx+Xlwg/k93O51sRMtaEBGu2CAFp b+qg== X-Gm-Message-State: AOAM533xZYC6qaCpe/spLMfvC6icq4Z1KzxNI/Ies+VDFKtW4gXtgg2j fXlTqIvtcWnb5w1P6JIsu1I2IKxza4Q2EUQy9EBg3AtH5g+pvvNLl3Of6+fq/GiWwSYwivpp+rO xXyepw6lv/7zmYg== X-Received: by 2002:adf:e5cd:: with SMTP id a13mr1000815wrn.303.1620249076647; Wed, 05 May 2021 14:11:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHHkV8frGxn8o8BSzf/TM9ljlb72+T/9RYIbN9zU07xxuIRtGSed2exRv5kWaKaBCsAaiysA== X-Received: by 2002:adf:e5cd:: with SMTP id a13mr1000803wrn.303.1620249076541; Wed, 05 May 2021 14:11:16 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 05/23] io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1 Date: Wed, 5 May 2021 23:10:29 +0200 Message-Id: <20210505211047.1496765-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 03c1f7cb62f..cd7bba6bde7 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -32,7 +32,7 @@ =20 #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) =20 #define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol" #define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version" --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249085; cv=none; d=zohomail.com; s=zohoarc; b=S6ji01upUwny6huKxCnzsgQN+nCF1pmr/FtvIg3J+uyQGj9uU5mupKBPGTwUK7nYvbMCQBZGGOk+k3LBQsD0MGoRUXfPqyqR5yxra6ZAubdLKG93JD6zkY/FKUfuIQSyMWo/uThLYUV8QkqqL7yvTAAfSL8xo0HSgsJr6damjps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249085; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=9DeDJRSrcFnDQNmIkG6F/kfPkHZxpE7XVa4zWVp8nf8=; b=du3Kbz5B/y2/YyFgNEhz4oiT9Ym3Rwl6ni1lm/AxQ1DTXiwNI+DInSBW9QQmIBF2arH3gYi5CU3F5Ryapw0jJbvmhuiq08A9L1Wu6tES/ofJ4TN3AA/OZK7un1B/eCxWEizcCW+iCDEvn2xtf4jLJajeL9apYsdwbD+OaiqNBW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249085745125.85346255676131; Wed, 5 May 2021 14:11:25 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-xHiMB1vYMgGIKouTSi9HBw-1; Wed, 05 May 2021 17:11:23 -0400 Received: by mail-wr1-f71.google.com with SMTP id u5-20020adf9e050000b029010df603f280so1202360wre.18 for ; Wed, 05 May 2021 14:11:22 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id o15sm678082wru.42.2021.05.05.14.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9DeDJRSrcFnDQNmIkG6F/kfPkHZxpE7XVa4zWVp8nf8=; b=Ov9ZeTwBlwa5jDQjKtINww8X24yBGz738ggWFh8QHl5QIqyGIWk7yA/0EiCeQyIXh4hHXh wgNSTVY6lYlMqrt92gykXxqS+qbEzQ0ES0ibjuYZRRmtJD81ZT+4Pd+yKlbxYaI0Kcxod7 elzjqtaP70bEgZR9LUV6vLgoSdvkpts= X-MC-Unique: xHiMB1vYMgGIKouTSi9HBw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9DeDJRSrcFnDQNmIkG6F/kfPkHZxpE7XVa4zWVp8nf8=; b=M+ztvCfZ4iycUc0zt/VEOERu391zp02Df+8ZaBB35fMXMEL5ak3588qnKyKHeUWPPT w7pWhoC3aiqVuQBgZJeC/1B2DhTz6J73aAApknZLTZxM/ow/Ik50a0WmvblM6fbHdtk7 wKJQDUl5A4Jo3+mYR3qytYdexOGRZrANzUZDxUBv7mTqMogDbBvngzVofENH5+hcIOii lpxR72o08A7V254GOPOp78VJcEqQ0S85Dsz3/5bDdBRfys5AQu6nzHKbnBFsEt55Hv+2 8nHbS84XxzNnDtqqxcYnSrI6JTOhlkhMrU0/KSGSfEo/MC6Bet+5SB26oVwaQQMNh3je WZsw== X-Gm-Message-State: AOAM531FAJYimDibVmAUvirqAPNiD8iy0rLyrDnTpsXQjFrBFRrHAnbI LTwYDGKf8ieaOq8puKF3GOtkXvaImYGlLQKdx5Ng0oTtkaW7Ii3L72NXJ6/L7PRFCDuUEoAx09N 0ZTWpZ7qWNH0Utw== X-Received: by 2002:a5d:4a46:: with SMTP id v6mr1060559wrs.134.1620249081997; Wed, 05 May 2021 14:11:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS5Qr3wU5Lp4hbHG25TcbnfsLrDkX4onOIoj6qKX3yY4Q8C3km01/ViqExk7L5ILTFTLVVug== X-Received: by 2002:a5d:4a46:: with SMTP id v6mr1060535wrs.134.1620249081829; Wed, 05 May 2021 14:11:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Kevin Wolf , Max Reitz Subject: [PATCH 06/23] hw/block/dataplane/virtio-blk: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:30 +0200 Message-Id: <20210505211047.1496765-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/block/dataplane/virtio-blk.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index e9050c8987e..53f5e4d8aa6 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -60,11 +60,12 @@ static void notify_guest_bh(void *opaque) { VirtIOBlockDataPlane *s =3D opaque; unsigned nvqs =3D s->conf->num_queues; - unsigned long bitmap[BITS_TO_LONGS(nvqs)]; + long bitmap_nr =3D BITS_TO_LONGS(nvqs); + g_autofree unsigned long *bitmap =3D g_new(unsigned long, bitmap_nr); unsigned j; =20 - memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap)); - memset(s->batch_notify_vqs, 0, sizeof(bitmap)); + memcpy(bitmap, s->batch_notify_vqs, bitmap_nr * sizeof(*bitmap)); + memset(s->batch_notify_vqs, 0, bitmap_nr * sizeof(*bitmap)); =20 for (j =3D 0; j < nvqs; j +=3D BITS_PER_LONG) { unsigned long bits =3D bitmap[j / BITS_PER_LONG]; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249092; cv=none; d=zohomail.com; s=zohoarc; b=Q6f7Ppwc0gFBx1bTipO4YdaC+zfARdA83byohd3Ntuf8kXenXnf+tj/WY7LDL3IQbclCLfOhwf9AhfJQZV/wsdPZQ5Prq8BsP1b9P0yezTTJ8zrcTllINFfq34nE1iqyqWp6y2B1Lae2uJYUvMd6WScrg+g+lysgY0K+ZZeCZCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249092; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=edHCyfbjyQMGm06QajXLKrSMOyiP3lsHbgoNXfYmyHo=; b=SLW2p9zHGMIoLlktmNexR80ZJTweg2T0r3wCLWoP3voJJyCtY3k1/LR238/bRRKBpCOLqwc4zYUSbU+i/CTTs+1mujDOtzZdeUGoazR3s6E/uKIP5SDPxbf+8JH+lICylBYMB2HHsqZRqHV0dkfzWoku2/YNdxYjm3xw9Pnwdjg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249092724340.90114233885083; Wed, 5 May 2021 14:11:32 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-333-cQXoXoBjPZmKaiEm0TIvHQ-1; Wed, 05 May 2021 17:11:28 -0400 Received: by mail-wm1-f71.google.com with SMTP id o10-20020a05600c4fcab029014ae7fdec90so706836wmq.5 for ; Wed, 05 May 2021 14:11:28 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id v20sm629564wmj.15.2021.05.05.14.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=edHCyfbjyQMGm06QajXLKrSMOyiP3lsHbgoNXfYmyHo=; b=SatRNyI8zLgle3Do/GcGSRvQDLuuMVNb0lWbyPbEPCfVgaQ79L4fXyF1WM2sqZVrnGohG/ tte/OqftImc2UdvrxfYO45ZVdRtjoWSwWWryC+BN+GhLSVefydC/27f+cgJz6bcOnaQJdh 0mW+aVWWuv2rxdjHICp/xT0sQ2jgBwo= X-MC-Unique: cQXoXoBjPZmKaiEm0TIvHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=edHCyfbjyQMGm06QajXLKrSMOyiP3lsHbgoNXfYmyHo=; b=NFlc+Aw8fKTrBjeFXNHvJ/PX5PMXa2vEpMjbA2p09s4zUy6TJJvs51jG43vouEzATS EbHAJzPoItQQU/T9Cysj0SmRBJx0T8lrO4w1VUMmUT7DQxGrcPY5u+1B6rXdk8g9DdoA EuY/DvL5t+EFqKiDkEIJfCyw4ufxf5PuZB/budl7x+EyBx+XB8TBKP0YzLVY9NJv1P8c jnViBQwsKicohXrBSUvw6a8Ce1dzJtRtSH4Lsdy91SoMUY/IVa5mcCFK6g/m6V2QPdgS A6flNlmDBifwbZYTw9QeWvfD61nrOdfqUkjaEIncLCHDUikSmkpz3yjF5rc4/tLGV7Cq QuXA== X-Gm-Message-State: AOAM533/NUKihxozIfuV5LxQR+jzQIR14T00YfdFgh22CtfGXo6oMpVh Y/m4ZFbbf0nThyS5dKW8W6WgD0mYfaVSGlE+llsy7xmHqT/G0wlQjUC7vOU5L+yC2V3A7HH9OqK hUNH9LUXPD4V8ZA== X-Received: by 2002:a7b:c846:: with SMTP id c6mr11554270wml.75.1620249086931; Wed, 05 May 2021 14:11:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0VftcqDhM4DQJ04/+C4BJuKVLP11nCVQfP7uSkA2CI72+ZsfDVLy1hAWjQNzuDLBkFk6Qgg== X-Received: by 2002:a7b:c846:: with SMTP id c6mr11554246wml.75.1620249086794; Wed, 05 May 2021 14:11:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Keith Busch , Klaus Jensen , Kevin Wolf , Max Reitz Subject: [PATCH 07/23] hw/block/nvme: Use definition to avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:31 +0200 Message-Id: <20210505211047.1496765-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The compiler isn't clever enough to figure 'SEG_CHUNK_SIZE' is a constant! Help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Klaus Jensen --- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 5fe082ec34c..2f6d4925826 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -812,7 +812,7 @@ static uint16_t nvme_map_sgl(NvmeCtrl *n, NvmeSg *sg, N= vmeSglDescriptor sgl, * descriptors and segment chain) than the command transfer size, so i= t is * not bounded by MDTS. */ - const int SEG_CHUNK_SIZE =3D 256; +#define SEG_CHUNK_SIZE 256 =20 NvmeSglDescriptor segment[SEG_CHUNK_SIZE], *sgld, *last_sgld; uint64_t nsgld; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249096; cv=none; d=zohomail.com; s=zohoarc; b=NouGgmZE4Ked+htoQBp7OwdJaw0BbMFHar1Ws3KTeok8D/92KzNZONVXXbEHglVlnln4fZl0qZV9VA+ZrDgD8RDq6wI1ROt4owNak7anE2iHR6vHA786eNnMwadIt2Gw4Uprln2rgJ+/65IQAogKocZoPqjrQlSYi/SPvQfHAgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249096; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=rJ65+lbAUX8QcisU4vuprIDcRwCJu4Ba2BnPDegiv8w=; b=OwiOrEiMhG7z5xgQ+YW6jzh8QXbgI0Ssv90MMFC4LoJis1no17uZR23zS/X0WOTBYAt1x8D5GAS9dwREihRkfDhqkCDicpUPiQjhGDc6zwWpui26Tkz7Qyy6Ua560XyD/N/WfzjCxZrW6ekGrPVrE9j5EBZujnFSdVJ/mV6/FMs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249096287512.9572945441083; Wed, 5 May 2021 14:11:36 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-E6Od4u2GNmOZ1BOv6gpOIg-1; Wed, 05 May 2021 17:11:32 -0400 Received: by mail-wr1-f72.google.com with SMTP id i102-20020adf90ef0000b029010dfcfc46c0so1226478wri.1 for ; Wed, 05 May 2021 14:11:32 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id t2sm7180507wmg.38.2021.05.05.14.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rJ65+lbAUX8QcisU4vuprIDcRwCJu4Ba2BnPDegiv8w=; b=VpWaeBTZ39v+lqIq8SPJ9CllO4pvwY0aXRzCMfdTpp4qNA+RV8k0EFVhT47Al9yyc5dt6K bBsv/tNEyWkb74oY+GXeLiHr3wHUIJ2d8hTb9KWvcg41k5E4uSDWULHN23ImJjr2jSHmrm I//Qqp3xrzWFNcjQ0xYaTEw+HLI8C0I= X-MC-Unique: E6Od4u2GNmOZ1BOv6gpOIg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rJ65+lbAUX8QcisU4vuprIDcRwCJu4Ba2BnPDegiv8w=; b=SkZPc5cE95UBQ3/Wdue53AzDIvGCe1Mae1WYbQe7g5blbMXPzIOWF8l0/MStrG4S+q tJgZrxpe2038G2Cm4AbjVK+o5TO9wJEmw4foAXDAuGn3HLKpdNfnBod8uSMc+aIAXS+g xESsKwrHKW30LKFxF/2XvYxNY5wh4b3h/uHBzHSeq4bflFv8QFmx4cPjCSEq2BNVAgFb iYcVnfvgE4auAubRnLnTbYVHgAc9/xBixcm9HZP50nrlm+jvUpMiyrAlC4Mfw2sBTOP4 ifaaNdilnp1AY3riqoB0JuBvmaSOQAs6eQaYhKVNhh1WDa3K6bUr0wAEfZA+Wns68lS2 F1NQ== X-Gm-Message-State: AOAM5333OIgX423fryQhC2yIxJdZMRKsrHEy4OMlJlkIUcyFteybCPPD vvaKDCwhTWED142zNj3ZOmYREXKWGvXNKInCv3xdlpi+sd3D8AsVqrun/tnE3CKBtfYv7yBd9kh bTgTn5dw/DpEy3g== X-Received: by 2002:a05:600c:214f:: with SMTP id v15mr12041987wml.146.1620249091785; Wed, 05 May 2021 14:11:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzIMjK9/NTEFGGXqDWqO63JpMTqBTawCLT2PdxiP+MClvhrTwARMYmp46MDNqPPs3YusKXzQ== X-Received: by 2002:a05:600c:214f:: with SMTP id v15mr12041972wml.146.1620249091649; Wed, 05 May 2021 14:11:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Keith Busch , Klaus Jensen , Kevin Wolf , Max Reitz Subject: [PATCH 08/23] hw/block/nvme: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:32 +0200 Message-Id: <20210505211047.1496765-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/block/nvme.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 2f6d4925826..905c4bb57af 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -652,7 +652,7 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, u= int64_t prp1, len -=3D trans_len; if (len) { if (len > n->page_size) { - uint64_t prp_list[n->max_prp_ents]; + g_autofree uint64_t *prp_list =3D NULL; uint32_t nents, prp_trans; int i =3D 0; =20 @@ -662,8 +662,10 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, = uint64_t prp1, * that offset. */ nents =3D (n->page_size - (prp2 & (n->page_size - 1))) >> 3; - prp_trans =3D MIN(n->max_prp_ents, nents) * sizeof(uint64_t); - ret =3D nvme_addr_read(n, prp2, (void *)prp_list, prp_trans); + prp_trans =3D MIN(n->max_prp_ents, nents); + prp_list =3D g_new(uint64_t, prp_trans); + ret =3D nvme_addr_read(n, prp2, (void *)prp_list, + prp_trans * sizeof(uint64_t)); if (ret) { trace_pci_nvme_err_addr_read(prp2); status =3D NVME_DATA_TRAS_ERROR; @@ -682,9 +684,8 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, u= int64_t prp1, i =3D 0; nents =3D (len + n->page_size - 1) >> n->page_bits; nents =3D MIN(nents, n->max_prp_ents); - prp_trans =3D nents * sizeof(uint64_t); ret =3D nvme_addr_read(n, prp_ent, (void *)prp_list, - prp_trans); + nents * sizeof(uint64_t)); if (ret) { trace_pci_nvme_err_addr_read(prp_ent); status =3D NVME_DATA_TRAS_ERROR; @@ -2510,10 +2511,10 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *= req) if (attr & NVME_DSMGMT_AD) { int64_t offset; size_t len; - NvmeDsmRange range[nr]; + g_autofree NvmeDsmRange *range =3D g_new(NvmeDsmRange, nr); uintptr_t *discards =3D (uintptr_t *)&req->opaque; =20 - status =3D nvme_h2c(n, (uint8_t *)range, sizeof(range), req); + status =3D nvme_h2c(n, (uint8_t *)range, sizeof(*range) * nr, req); if (status) { return status; } --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249102; cv=none; d=zohomail.com; s=zohoarc; b=Ui3vwkEEe5I0e+NVzYhsbhER6o+t7hqIyNEuB8fAyZZjKn3/2X6Z9u31wxPjVu1k1d1aFbONhwt5ete81/laaJ1WRZAPqNlIn1QRmq2VA1/ztMlv7PFlffC/noVL9wpQk+WyZ6+4rDcWXQDobmczL5rP5wyyCu4bX+XHm5aHXXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249102; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=okjMXaVx8fDoFf7fItgqe0Cv4qcw3tBNnKOpyhy+thg=; b=KSpYdG8lEza09gIemQefeEKzixS4S3kBFw22+efhcSdyQACtXbS5ZJB0mOyH0ojbFjoq3Me9P4ataaEmBuVNr+HyrlfVY2qEWewnZNP7LmY1+XoRcScK76Jh/dNAMzpS1Do46+TeAQ7K0NWIMDCEyRyOi/49asf8HBq7BdB4om0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249102152392.13019343243616; Wed, 5 May 2021 14:11:42 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-VWsuiJahOB-A-YrvLRGuuA-1; Wed, 05 May 2021 17:11:37 -0400 Received: by mail-wr1-f70.google.com with SMTP id q18-20020adfc5120000b029010c2bdd72adso1209035wrf.16 for ; Wed, 05 May 2021 14:11:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id b8sm731588wrx.15.2021.05.05.14.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=okjMXaVx8fDoFf7fItgqe0Cv4qcw3tBNnKOpyhy+thg=; b=gFFejwEdZaXFgMC7PwwxejfSWJid+OyH3lJJRJn4/7WpDm4RAn4WfZZO5FdZq2kipPvwZy ti2b/0pnFzouGmBY2LZNGiQB08+mlJ6mK1xuj7sTXPNVwqL5FfLcISvd2VV3lQ+9W8+8l1 eNBDbALszvQiwDKLDW9sd9szFnSJEUU= X-MC-Unique: VWsuiJahOB-A-YrvLRGuuA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=okjMXaVx8fDoFf7fItgqe0Cv4qcw3tBNnKOpyhy+thg=; b=dUtk4af2cEU9zF3GQTmXRjuLYB0iV75yoqOMVoofvOovUCEk/H29bqBSa/PlpRu0hE vJ512Kd7H28u/WqFLCd04ZVL1v3rPisfvnZQmgDztCR3IIVNvz5enK0bRgbsUNgkZw45 g9Uo5r7g8oj+rw1jDier2nprIJEL0BHjxbHcfcOwe7Mt9hbDNuoWevo0BuIKr5Am1i18 IXPIJD3XPTRgUaS6Mz+6MGzomgkLXVGo8Pym57ijmqB0fE+PI+GecmuGuDPvE0cvi5pJ 6uUk4CaSWAiBlhYPcaCgvUqj27kGln2zMXpNj0pC7IpDu57qNRGLmh4jD52y3D0S6Ixl 37hg== X-Gm-Message-State: AOAM530yPS93iWVdJ3Fol2OslAOw8GoUaBFi7j80dVB0I1VSpylzB/pC 4A1+8+iknjlVzlWomfs+m7vTg+g0MwaxdrSgySwogk9IMpwC+N6npFIxMxFBRlQ5T4iVyvoz52O FekTzTIaUI6UL5g== X-Received: by 2002:a5d:498c:: with SMTP id r12mr1052493wrq.31.1620249096458; Wed, 05 May 2021 14:11:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygKaQEFEtv8AaUMv9HVvDd6sZKBrSj7AlKCgqWQrVlPcb96sC0MDFakbG/VDWfABiIy17/3g== X-Received: by 2002:a5d:498c:: with SMTP id r12mr1052482wrq.31.1620249096339; Wed, 05 May 2021 14:11:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Dmitry Fleytman , Jason Wang Subject: [PATCH 09/23] hw/net/e1000e_core: Use definition to avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:33 +0200 Message-Id: <20210505211047.1496765-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 Acked-by: Jason Wang Reviewed-by: Richard Henderson --- 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 b75f2ab8fc1..4b1d4521a50 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1621,15 +1621,16 @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetR= xPkt *pkt) } } =20 +/* 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 =3D (14 + 4); - /* Min. octets in an ethernet frame sans FCS */ - static const int min_buf_size =3D 60; =20 uint32_t n =3D 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; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249104; cv=none; d=zohomail.com; s=zohoarc; b=LeJZyIM+54y7JgEm2pw45wMMua2nhn6HOiSvqDbPiwxOZBxmWqejaCJ52Qu2oacjiCFMM+k42axocZ6Q384FhKoV+CvEc0uPMmSlK0nwszKNNtG7cJrECKBE2q2GZQbW++VEkIqyu0NrucOeA4tWVhjgILYNDJpBxcJfx1QW+pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249104; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=E0+1SJDTrG58JGhveEQcslSD23e5C3pDapkhqBRrRfM=; b=BHUeFfDJAugklIh8JgcfBR3l+SmulocvZw5Jjju41GnLhd4GJFuQRvkecWXDr5Q0kFTjAxmMX5W8MkG2nfJgsiU5wqYySQhA02DZjvGiQij/syCLml0W0hki1j96o/YNYSd5bSkfiz+/Eog89mnLD4Ls+aXuNrtXZZEBd1lK/4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249104772105.17672745663208; Wed, 5 May 2021 14:11:44 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-REZlCwtzMBuCi-GxkWLn5A-1; Wed, 05 May 2021 17:11:42 -0400 Received: by mail-wr1-f71.google.com with SMTP id 93-20020adf80e60000b0290106fab45006so1200514wrl.20 for ; Wed, 05 May 2021 14:11:42 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id y5sm640359wrm.61.2021.05.05.14.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E0+1SJDTrG58JGhveEQcslSD23e5C3pDapkhqBRrRfM=; b=hmfB7Xswob6HOjEp4F05xH4QOmiB40wCuFxXy+hERmGeGRiXtYC0aZEGQMB+gYZnDDi8eA D9qVjanRm1CZrV712J412/P1RGdXpOIk0KsQr9MJV3COfgsnvKs/3G7Qy16KpNqqkMHeoN L+HgqEFxEPFJ2S6LeE0kItZabi1Oup4= X-MC-Unique: REZlCwtzMBuCi-GxkWLn5A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E0+1SJDTrG58JGhveEQcslSD23e5C3pDapkhqBRrRfM=; b=hjnOC9KW692ZIOWgraCBZHmTnpXbeZkPucqBYjI3OVQmvtFbaP+xoVLmAnPJh/5dlh H1W4L3E7LiHMJHPWuFiBcLpMdj+fDxcYB4eO7W/wAnIhS7szXgjgLx0iq7oq99P9Ir0j jAk8ScVhE8y/ltL41wM8SmuBbdmQSCOBRQb5LzMQeH7Bw2LQgib9QDwOqtrunLvH8WAb Wf3Xq31eoc6nPDntXMHUechvle9POAaeg3JNgb1Q+PmUbReP819Vy9kGzAjOBQ5rsLgo 3xPyynwUfqQcnTafee9PuECYuAUuit9xPBknGS8i0ZU03MLnBvpyGslhLMlWpnognT/g 9T5g== X-Gm-Message-State: AOAM531I+o0M7kKzYNZBn4ymDSp4qwoHax8H27bQNAx7iU9esWbwx/HS di/V9dRqFXy4eq7rLM01iRgo2wPPG1cboAACfqG9q7BTvSH796thvWm/clNkhQT6Oe7oHcICHh3 89JtqvFQrqqjiYQ== X-Received: by 2002:a5d:408f:: with SMTP id o15mr1002756wrp.89.1620249101275; Wed, 05 May 2021 14:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8d6dca/PRy2aY+dy28loaQ7h1Hm/Fc9iyVuyvvS3A0MsftmMKF6RQ+UeQfRBqRpU5XXN8aA== X-Received: by 2002:a5d:408f:: with SMTP id o15mr1002748wrp.89.1620249101150; Wed, 05 May 2021 14:11:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz Subject: [PATCH 10/23] hw/ppc/pnv: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:34 +0200 Message-Id: <20210505211047.1496765-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: David Gibson --- 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 77af846cdfe..f6e3d37b751 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -141,7 +141,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, voi= d *fdt) int smt_threads =3D CPU_CORE(pc)->nr_threads; CPUPPCState *env =3D &cpu->env; PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); - uint32_t servers_prop[smt_threads]; + g_autofree uint32_t *servers_prop =3D g_new(uint32_t, smt_threads); int i; uint32_t segs[] =3D {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; @@ -244,7 +244,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, voi= d *fdt) servers_prop[i] =3D 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))= ); } =20 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 529ff056dd2..31c2c0d97bf 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -176,8 +176,8 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset= , PowerPCCPU *cpu, int smt_threads) { int i, ret =3D 0; - uint32_t servers_prop[smt_threads]; - uint32_t gservers_prop[smt_threads * 2]; + g_autofree uint32_t *servers_prop =3D g_new(uint32_t, smt_threads); + g_autofree uint32_t *gservers_prop =3D g_new(uint32_t, smt_threads * 2= ); int index =3D spapr_get_vcpu_id(cpu); =20 if (cpu->compat_pvr) { @@ -195,12 +195,12 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offs= et, PowerPCCPU *cpu, gservers_prop[i*2 + 1] =3D 0; } ret =3D 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 =3D fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s", - gservers_prop, sizeof(gservers_prop)); + gservers_prop, sizeof(*gservers_prop) * smt_threads = * 2); =20 return ret; } diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 8ef9b40a18d..bb61adb114c 100644 --- a/hw/ppc/spapr_pci_nvlink2.c +++ b/hw/ppc/spapr_pci_nvlink2.c @@ -401,7 +401,7 @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev,= void *fdt, int offset, continue; } if (dev =3D=3D nvslot->gpdev) { - uint32_t npus[nvslot->linknum]; + g_autofree uint32_t *npus =3D g_new(uint32_t, nvslot->linknum); =20 for (j =3D 0; j < nvslot->linknum; ++j) { PCIDevice *npdev =3D nvslot->links[j].npdev; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249110; cv=none; d=zohomail.com; s=zohoarc; b=j+jYf4lrZLT0O5syx9T2uEYErwiQkud3yeFWlX6tv4P1ioG/BlDFcMSfq2pACJgDVKmK1Rh3NfKdq5vHNP7rBSkAWxLsgbEG4Sqx4nvQqGvGGy9+f2HL0a+On/0WugCmNy/c4jsOkvRUEXdzmJG7EgoeeJqNxFecC86vJJ+Bpus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249110; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=hiAEEgiMzbtFY5nN+/nFhOYjAQIYHUilzZNqfLN4ZPg=; b=NJhChixwE8q2hpnjofXG7zVQyT8cp9GguepvqyDlwMAH0b9ujHlpmTFWraezhM2KGUrIlhh6XwaQi+sdAbu6BrhEfDLiRdUPEdoTBUMa6HokmDoOTIRBMxKRGeJyLS//UcOQphBjoU2j3Q2IGi4MAmQ4XkiQYu6rKD51Aoi7xZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249110416379.1973148432745; Wed, 5 May 2021 14:11:50 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-407-DpU5_oaENPWnbZQ1Bvh6hg-1; Wed, 05 May 2021 17:11:47 -0400 Received: by mail-wm1-f72.google.com with SMTP id n9-20020a1c40090000b02901401bf40f9dso1975677wma.0 for ; Wed, 05 May 2021 14:11:47 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id i12sm672542wry.57.2021.05.05.14.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hiAEEgiMzbtFY5nN+/nFhOYjAQIYHUilzZNqfLN4ZPg=; b=cMjt9kX8a54h5MMWe/m6uJtLRf599+dBWCg4ClMG552zjICbcqqzDkQROHarK88uYil75g 0Ep7zIUEJ9gv1TT2VE13a8ounwjtBLzKMMq4+LxioIsWlHWVEkQf88ky8suB317nRjomGF LV2ly7zaFhlMKI24gnKDzGMKdDpWd+4= X-MC-Unique: DpU5_oaENPWnbZQ1Bvh6hg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hiAEEgiMzbtFY5nN+/nFhOYjAQIYHUilzZNqfLN4ZPg=; b=XoUnQ+MzVjB21gJlSGLhDMREVRuQ2Im9KuR1dGnAsXAe58cmWnRG7bM0Mk7B3BsAxZ cL4jAcOCp2ySGyEy8mu2Yv2QeF9pJQBW1uMaoh+7B9elDqB7zmSOiZq4WiXr3J8ixodJ 3i9q7yc+yd7tHVZ/NHHwvp7Ucso5cye1dXgqxEttILD5XoLT5f6I7TWfCl0NF4ZOhy6u dGjIhFihxlrUkuxG764zvJJe3+Rejqs/CBhUf9+qB32BTy0+pSJjauAZt+/yUrErdp+a LYlkhrRtpKTQ7SYmQEzADpjIuWPrBbCPMk/FTUAVEd1QpN+v3m16CrEQVFJEh4NIGW9T zrlg== X-Gm-Message-State: AOAM531sjoqGuhk7qwSI3XQjyPNd0lEowZybryLGVBQy6Re0nf54AmWf AHYNdxhfy/h8Yi1aSO6Wq+sVHicVEE94qEJ/S+mjOgiiF6GdUJ4ZEFl9+Fcb3C7hvzl9MwFO/G5 qRxuKnQ8UNA8k6w== X-Received: by 2002:a5d:4ac6:: with SMTP id y6mr1056209wrs.414.1620249106486; Wed, 05 May 2021 14:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkwwJ4FPVEZbq1eTtKpL88QQ5+CYLkOHs+o3I49IAhK0lukdV3xx4Jvs7je6TKllZc5PE/Ww== X-Received: by 2002:a5d:4ac6:: with SMTP id y6mr1056191wrs.414.1620249106367; Wed, 05 May 2021 14:11:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Greg Kurz Subject: [PATCH 11/23] hw/intc/xics: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:35 +0200 Message-Id: <20210505211047.1496765-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: David Gibson Reviewed-by: Greg Kurz --- 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 68f9d44feb4..c293d00d5c4 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -566,8 +566,8 @@ static void ics_reset_irq(ICSIRQState *irq) static void ics_reset(DeviceState *dev) { ICSState *ics =3D ICS(dev); + g_autofree uint8_t *flags =3D g_malloc(ics->nr_irqs); int i; - uint8_t flags[ics->nr_irqs]; =20 for (i =3D 0; i < ics->nr_irqs; i++) { flags[i] =3D ics->irqs[i].flags; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249116; cv=none; d=zohomail.com; s=zohoarc; b=FnBGgJ0snWcDcOm+d0Z6wn/LLO2WRnc4EBojTQ58vSvF+ciBlUNqHko3ihofjn2EPqYucbV5aQj6fY2Jj443DZHcx0dHyu4FQ/aIxvbMLkMFky4I2QOhf4VZIkcAtwfp8Dnxhr4hZkCt3vRwgAS2bb1XEMmM5rPdQ8J4w4D5gDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249116; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=tKtzUuVUg3zkWjnpM9cF6E//1jWBtx7/fvE0exQ2eS0=; b=R/7HQCem912SjM+ip7ojM9Cu4o4Gpvrl9TBD4/FP2aXGqiuCgjJzpuYNufw+fLIgbTF4Rvrrg5q0lRLC4X/woxua0ZtyLUJZ8w68V0ZsV7XaPb5TQDTMk4o75YE9hjPOQDSRkB7Wp0USJ6pwPE6lNHmriAaGYqB1KsU78jb0PUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16202491168201006.471285266193; Wed, 5 May 2021 14:11:56 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-ek6iS7Y5OueRCtUYdyDlrw-1; Wed, 05 May 2021 17:11:53 -0400 Received: by mail-wm1-f69.google.com with SMTP id b16-20020a7bc2500000b029014587f5376dso1785137wmj.1 for ; Wed, 05 May 2021 14:11:52 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id c5sm612680wrs.73.2021.05.05.14.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKtzUuVUg3zkWjnpM9cF6E//1jWBtx7/fvE0exQ2eS0=; b=UNLmFJbHNlGR42vDw7CZho5RFiwbk9B66lx+BeZdKCNJZnurvWZJZ9G6An1ukp0Qf9KYAE O3JZCKE3htC3X/9xTa0K9p7P4BBkPobBfGMrslRa89+hHYH/8peq1GZ1cEMVC3MWqK4ar7 9oB/reS/zm1m6o8KPfmcOsN1P0KKxk4= X-MC-Unique: ek6iS7Y5OueRCtUYdyDlrw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tKtzUuVUg3zkWjnpM9cF6E//1jWBtx7/fvE0exQ2eS0=; b=X2aFQ3ocJdYxK8L931MOl4y1+zmjsAXwEB5yjhv5XHk0Pw/usVAJceigPZf+FtdYOe jF8mmLIpuckDLfrjccregWhZt2lV6jl/8ks89r5uWVQnfeai85G1UHhR47cS0VivsI3x Q8mAZYcyfyyTZ2CiWi+Eb1RJwCXxTyeTco2gaH1McPpumyvf3gCn4fEBL1FB0FX4VO+u CYhJEY8nOlJTqtTtqyTSHKW2OAPvDLJO0VAQUh7go3Ji6e7sN5+H9M6/Wh+0bLML7sVq QpN+OnsUW5ClreB0BIyqQam9H5e8EKPaihxttNOJ9h8tYxsFxEOAKTkoWDaR6HueqVi/ ty8g== X-Gm-Message-State: AOAM532fuPE2oEnCpdhvhlVCsCqKJ7j4Gom5H1HuPQyj0B9ZReyik476 74kjikH6q3XEl/90ii0b+n0Bm/ulKAKkx6RHT+Jsgam7yV+/q76n+XY87QfAk6lEy/XPe20sJdW PXFkgNNDT61g3aA== X-Received: by 2002:a05:6000:50d:: with SMTP id a13mr1064634wrf.130.1620249111317; Wed, 05 May 2021 14:11:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN4fDkR14J/ZumsUGD5UvKJePZJMZ/4JldUq/xifAFnfQpL4iEP4krswocXMfVRV/FONny1A== X-Received: by 2002:a05:6000:50d:: with SMTP id a13mr1064624wrf.130.1620249111193; Wed, 05 May 2021 14:11:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost Subject: [PATCH 12/23] hw/i386/multiboot: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:36 +0200 Message-Id: <20210505211047.1496765-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 Reviewed-by: Richard Henderson --- 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 9e7d69d4705..ccd197603b1 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -161,6 +161,7 @@ int load_multiboot(FWCfgState *fw_cfg, uint8_t *mb_bootinfo_data; uint32_t cmdline_len; GList *mods =3D NULL; + g_autofree char *kcmdline =3D NULL; =20 /* Ok, let's see if it is a multiboot image. The header is 12x32bit long, so the latest entry may be 8192 - 48. = */ @@ -360,9 +361,7 @@ int load_multiboot(FWCfgState *fw_cfg, } =20 /* Commandline support */ - char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2]; - snprintf(kcmdline, sizeof(kcmdline), "%s %s", - kernel_filename, kernel_cmdline); + kcmdline =3D g_strdup_printf("%s %s", kernel_filename, kernel_cmdline); stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline)); =20 stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_na= me)); --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249119; cv=none; d=zohomail.com; s=zohoarc; b=XRi/MeyC+x8PkZji6xan3yvonR3brEIj6fXF9MJAgGAjCIODj1E4jx+j606FU57e3LoWpBf1Lq2AUubW4S++BMVwCq4s0qZU6lvEljHmlsRBKpVYjP9NA46oscnlP8bGzAjBA4WHMj0WaBcZFtlPumd2UKLjURI6ePEJcjzaSvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249119; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=DfUDaI+/f3cLjeF1lXLCmZjtS2bI+iFNO52XEDHDQcY=; b=S6krua1QvYjvqy33Tux/i0dSoMvJHzQ9kKxn6MOSk2vY9iPLvnxnC8l8D8sn/5Y/QLfaAixQEy6G3fMLd41tzHXdSdPSiUlmtGD1Cl7LK66TkGdQcsUiZxneQKunR+1+/m9Yqri/ywaTgEK6scz15exRn5S3K1f9uGQ8gsctel8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249119668912.4737467998038; Wed, 5 May 2021 14:11:59 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-441-Gm_fm5Y4NpW_m42l-wdIEg-1; Wed, 05 May 2021 17:11:57 -0400 Received: by mail-wr1-f71.google.com with SMTP id 65-20020adf82c70000b0290107593a42c3so1218485wrc.5 for ; Wed, 05 May 2021 14:11:57 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id j18sm528387wmq.27.2021.05.05.14.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DfUDaI+/f3cLjeF1lXLCmZjtS2bI+iFNO52XEDHDQcY=; b=dM+hSgwMRAdbS5tMvK0JMYQNQAOvISVXEtfNQAOE3zrA8IN5rjceSHJ7s0qPEsr+D56BQ5 z8idnQDu+eRzaV5NAl9LG4KHDPz58eG19+c1JiLxx3JsL8frw//BtqrdiVBjJpO1keS9N4 eSmx5S9P1bLliXj/iwmKS9+fUAux0Qw= X-MC-Unique: Gm_fm5Y4NpW_m42l-wdIEg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DfUDaI+/f3cLjeF1lXLCmZjtS2bI+iFNO52XEDHDQcY=; b=VS3fdFGnfViV2fDOaiuFyyChBux9ak51GlGcc03l5RvqoxN1Gz1g4QDYY1QmuduLWj pZgWHEAlcOwDiOxy9i++IKalXZvnOZoPaHNdQmBPSqcOyTS8txrY50IsSjAV7/udjllL S9sie92Me5z+TrIZDHefSbM7fooVTx4xrvc4RAfVLXbd/U6LMdq788kUOaR1C3CISPGx yk5CWT+rIJwz9Osu7QWnVWMVa1X0F2gcGPPAHtokbukRoi812UpU9aEpMOlAwuQFhEi1 lx7wGO8xDOPhm/SCyjtzbTuG4GdxatdaAfUeKwSnfr4jJmbsxgCdFSc5scD57ezRnyYO yFHg== X-Gm-Message-State: AOAM531DOp2C37QEsyUefnsGDYW4LB81mP2m5P+1cPqNB7bJA5NMIjE5 zYr+ajmKAj/B+k5RKKr9pu6U2I7KuyyaG4oWUK/kOoXHRKFkhJCEAKYVaBbZw7ZEUniZx9qKrov ea9oZ9E5Syey2eA== X-Received: by 2002:a05:600c:4105:: with SMTP id j5mr11852474wmi.141.1620249116093; Wed, 05 May 2021 14:11:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG5noAegUY6P5TQU7a34yqqqkqt19xtSf03Oa1j5D6n+YP5pon+6ohzY+LLzQLvfzWE/3n8w== X-Received: by 2002:a05:600c:4105:: with SMTP id j5mr11852465wmi.141.1620249115963; Wed, 05 May 2021 14:11:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 13/23] hw/usb/hcd-xhci: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:37 +0200 Message-Id: <20210505211047.1496765-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 7acfb8137bc..59a267e3c8b 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2387,7 +2387,7 @@ static void xhci_detach_slot(XHCIState *xhci, USBPort= *uport) static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx) { dma_addr_t ctx; - uint8_t bw_ctx[xhci->numports+1]; + g_autofree uint8_t *bw_ctx =3D g_malloc(xhci->numports + 1); =20 DPRINTF("xhci_get_port_bandwidth()\n"); =20 --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249124; cv=none; d=zohomail.com; s=zohoarc; b=MyqEBekkNUfCk1hjk0jzPTgGjK5qOVMY5ZOWXtL10Yh3B/H54WCdevD9NU96ps+M4+13JAFwOJPEXXWq1jLoq8CskEHcLUNDHOqkUK2ivfsUMw2i0BFuq6CWkqNIFWbGLB4guZgRq9WgGK5nMFm7p+/Q1Diyb/qYajB7aHa0mUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249124; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=636tUeaZUJwZXzgkoGYRlYUQS8C8vEDoXPpJByBKufw=; b=T8HZhYXntvxlBI3PKh9nkdUqmePz7gxsc8do0tsO8+k+IPH54+VSeffV+SjGbaEthn2vrqhnH249QFuR344N6uasquywYUkYOwFntLDOwXv4azixIqDd3appaAcm6DhHkCFtv2xzSKZXZPEKfe3N9VmiM4syOsnKXDXjESe1QPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249124605988.8197739150802; Wed, 5 May 2021 14:12:04 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-93QO1oCFM8ijPcgV3u2olg-1; Wed, 05 May 2021 17:12:02 -0400 Received: by mail-wm1-f70.google.com with SMTP id r10-20020a05600c2c4ab029014b601975e1so1789266wmg.0 for ; Wed, 05 May 2021 14:12:01 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id r5sm641066wmh.23.2021.05.05.14.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=636tUeaZUJwZXzgkoGYRlYUQS8C8vEDoXPpJByBKufw=; b=IF1qXYoH3yz2yjsoCjgktKA2JL1W60wC+hBzIbKHy5jg6rpxVTT/kWQ1t3YOzzjfpCV0sQ hF9F0tkspBBrG58xz15jdOALRcq2JOXPD9TeRpY6du7U8VqlM7GpKTCmgnhuWqwuGSRZW2 /vsdEQ+UB5oDjxO/luCDCnLhp9LV69I= X-MC-Unique: 93QO1oCFM8ijPcgV3u2olg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=636tUeaZUJwZXzgkoGYRlYUQS8C8vEDoXPpJByBKufw=; b=BDVD/kQYOH664pQR2u3L6RW+wprzR8+8Xk20LwcQBvgSS9OqfGEaGDm8gnFfz2JaCB k9L3sv2O+5dIZ1WSJGWfYR5pqrmgpBIao8GFgb72z9EORro8wlD5BnxID0mFpMSSvEqI P/5ZStumWj2B9TFdkfUWjQa5nlrqa/i4BeVWwTkVrN5tRm7LM53Qr2LgkE8F4IaSChFC r2EG4a0j5eviE7Izofos9oKoEKuJmK08Gkk1U3XND1dL/UGmejswI+vQ4sKwRNNW7TtQ A6Xsei1lWDq9Z5MBiUH8ngIaRJUQGHRGpnpGbhnQo6XISsBUH7vn2nA2oyd06PwuGz8j WARA== X-Gm-Message-State: AOAM530J/wNhwPP2FDcWRnBaIunaOejIZF4g7TcCEHDyQACC2Pb0sRhZ TSX7fVJHkABsZD3xEh380W+7vKpIxgsQEoCxShwi7c8s+MynC2ausnwjkIsTzQM37k2sCFuzXUP greG+DwddO6ZfbQ== X-Received: by 2002:a05:600c:2242:: with SMTP id a2mr619032wmm.125.1620249120946; Wed, 05 May 2021 14:12:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCJeEMZBQikxcTCj55Wbnl59HNODb424Hnb387n8l9K6RxYflSny7y4Nqiv7PVgw1geYimyw== X-Received: by 2002:a05:600c:2242:: with SMTP id a2mr619021wmm.125.1620249120831; Wed, 05 May 2021 14:12:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 14/23] hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:38 +0200 Message-Id: <20210505211047.1496765-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 Reviewed-by: Richard Henderson --- 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 1cf2816772c..d090eee673d 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -894,13 +894,14 @@ static int ohci_service_iso_td(OHCIState *ohci, struc= t ohci_ed *ed, return 1; } =20 +#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 =3D 16; int i; - char tmp[3 * width + 1]; + char tmp[3 * HEX_CHAR_PER_LINE + 1]; char *p =3D tmp; =20 print16 =3D !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHO= RT); @@ -911,7 +912,7 @@ static void ohci_td_pkt(const char *msg, const uint8_t = *buf, size_t len) } =20 for (i =3D 0; ; i++) { - if (i && (!(i % width) || (i =3D=3D len))) { + if (i && (!(i % HEX_CHAR_PER_LINE) || (i =3D=3D len))) { if (!printall) { trace_usb_ohci_td_pkt_short(msg, tmp); break; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249130; cv=none; d=zohomail.com; s=zohoarc; b=XTIXBzqt8RSdt3iQ7V86t/zQk1jlRimHlk12FK1M6GNY5zxmfFrLxxzpkn+LVJy3d569gdI5WNTbrHQBC1/sH71XuSKzNQqrlqu4z7flzhGsinI+nyUZmWEPN58d78Mc+ypcfrBjqDK+ACyZfSQa7MswDQMr8+/IFL5vSloskvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249130; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=kucBjQtcgLplpmt/EdeRDcsm9+gP7+suZYQbhaTK3U8=; b=jMTp67yLj9wjtpexE1QA/WaHGH9olTro5ax8kPa/ssk7Sg3HyrIylE5KaetiDo9XBMswWSTOLqdP0ctTRJV0aZO43WOx8M4UOccnjhE98dfIytLVMIKOmyYfGBxoGB0fS5iSMjh2mJESGMVRoxd8irNrn39dJw5Fv9L4+bHtlAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249130508809.7114933232485; Wed, 5 May 2021 14:12:10 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-iWheM1kEPUO3u-JhlsEgzw-1; Wed, 05 May 2021 17:12:07 -0400 Received: by mail-wr1-f71.google.com with SMTP id s7-20020adfc5470000b0290106eef17cbdso1206691wrf.11 for ; Wed, 05 May 2021 14:12:06 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id t17sm587584wmq.12.2021.05.05.14.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kucBjQtcgLplpmt/EdeRDcsm9+gP7+suZYQbhaTK3U8=; b=ekQE0RpJlA5PyDOfJV1TUmNycMqCWxlMLAdAb6VjyM2jr7h1Jl98S/S8RzpyfK2jhYP3/U gWH44W2+7kvl3djb1Vtq7Jw7/JPme9KYuz/SUoPCiPpiJsghNrLXhNbEIRTo8ktEjnougO lqEQDaXsocmsReuF1cR76Zq58tWUKG8= X-MC-Unique: iWheM1kEPUO3u-JhlsEgzw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kucBjQtcgLplpmt/EdeRDcsm9+gP7+suZYQbhaTK3U8=; b=s42T2fgNblvWjZ2W/yGCQYd1C5P6aqqD8WR9ZueCUuJirarJ+MCOtujAcCCJvGrvcX Uei2vrE4RsE0ihcTkO5i+Oc92hvTkPmE3SdCYAXzZsLlu9ZCXz3LW0c7QRS/1NFQH0zn 1qFAsrB7YStu2Zlyem/e3sd0paAizSdW07juVLiTO8oYcVggJlxkJjsKn40AkuLLC7tv Ot9V1J7SZ1n4suMF1kjWFPs5VYUUVX2lxB/n50FfyIwDV7eectzCSwteTOS3joJA7it/ Yecaja7+KbdMDEKl4q3WjZYugH2mGYpZZZ8YGsBhYeW8dG9ffvdO0ViS+QgcTHM0m3hv Somg== X-Gm-Message-State: AOAM533LN9ML/e6sI2wBwj73uUUHeZmB93XVQcOR+e+yLyh0iljapFO3 hp8snKIBtgmj7GHEgm8SpXoBe3uBp/cvUhPzQ/iKaMmFy5d7Jx8GktfnWwpX25cAxEnd4u3lsy5 94585mZxFtp7t1Q== X-Received: by 2002:adf:d223:: with SMTP id k3mr1026867wrh.99.1620249125973; Wed, 05 May 2021 14:12:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5tRHEWhSo/5j9x6U8ZvggnSDes7sXlgotB44kpOwkYnlPv+XFtbzO9ez7Pk5cj5Bxs9resA== X-Received: by 2002:adf:d223:: with SMTP id k3mr1026853wrh.99.1620249125784; Wed, 05 May 2021 14:12:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Greg Kurz , Jason Wang , Jiri Pirko Subject: [PATCH 15/23] net: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:39 +0200 Message-Id: <20210505211047.1496765-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Jason Wang --- hw/net/fsl_etsec/rings.c | 9 ++++----- hw/net/rocker/rocker_of_dpa.c | 2 +- net/dump.c | 2 +- net/tap.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c index 8f084464155..1abdcb5a29c 100644 --- a/hw/net/fsl_etsec/rings.c +++ b/hw/net/fsl_etsec/rings.c @@ -381,8 +381,6 @@ static void fill_rx_bd(eTSEC *etsec, uint16_t to_write; hwaddr bufptr =3D bd->bufptr + ((hwaddr)(etsec->regs[TBDBPH].value & 0xF) << 32); - uint8_t padd[etsec->rx_padding]; - uint8_t rem; =20 RING_DEBUG("eTSEC fill Rx buffer @ 0x%016" HWADDR_PRIx " size:%zu(padding + crc:%u) + fcb:%u\n", @@ -423,11 +421,12 @@ static void fill_rx_bd(eTSEC *etsec, /* The remaining bytes are only for padding which is not actually * allocated in the data buffer. */ - - rem =3D MIN(etsec->regs[MRBLR].value - bd->length, etsec->rx_paddi= ng); + uint8_t rem =3D MIN(etsec->regs[MRBLR].value - bd->length, + etsec->rx_padding); =20 if (rem > 0) { - memset(padd, 0x0, sizeof(padd)); + g_autofree uint8_t *padd =3D g_malloc0(etsec->rx_padding); + etsec->rx_padding -=3D rem; *size -=3D rem; bd->length +=3D rem; diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index b3b8c5bb6d4..3e400ceaef7 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -1043,7 +1043,7 @@ static void of_dpa_flow_ig_tbl(OfDpaFlowContext *fc, = uint32_t tbl_id) static ssize_t of_dpa_ig(World *world, uint32_t pport, const struct iovec *iov, int iovcnt) { - struct iovec iov_copy[iovcnt + 2]; + g_autofree struct iovec *iov_copy =3D g_new(struct iovec, iovcnt + 2); OfDpaFlowContext fc =3D { .of_dpa =3D world_private(world), .in_pport =3D pport, diff --git a/net/dump.c b/net/dump.c index 4d538d82a69..b830302e27d 100644 --- a/net/dump.c +++ b/net/dump.c @@ -68,7 +68,7 @@ static ssize_t dump_receive_iov(DumpState *s, const struc= t iovec *iov, int cnt) int64_t ts; int caplen; size_t size =3D iov_size(iov, cnt); - struct iovec dumpiov[cnt + 1]; + g_autofree struct iovec *dumpiov =3D g_new(struct iovec, cnt + 1); =20 /* Early return in case of previous error. */ if (s->fd < 0) { diff --git a/net/tap.c b/net/tap.c index bae895e2874..2b9ed8a2cd8 100644 --- a/net/tap.c +++ b/net/tap.c @@ -120,7 +120,7 @@ static ssize_t tap_receive_iov(NetClientState *nc, cons= t struct iovec *iov, { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); const struct iovec *iovp =3D iov; - struct iovec iov_copy[iovcnt + 1]; + g_autofree struct iovec *iov_copy =3D g_new(struct iovec, iovcnt + 1); struct virtio_net_hdr_mrg_rxbuf hdr =3D { }; =20 if (s->host_vnet_hdr_len && !s->using_vnet_hdr) { --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249134; cv=none; d=zohomail.com; s=zohoarc; b=Ua6BUgdDMWxw8rIhu84KBIicNhBTwx3Cz8TxAIG8u6g1qFLSIGF2qoKQ9N3rRR2w9DJWlbgC4K7X8haIsRBJtU8xb/2kS66DC4Gx3NHhurpZOrEjvmy1JnHh9o/qVyMz05F9tKkiiD5CfbqSUI7Mq4N9fJpMGmjX84MfCh0U7yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249134; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Kwgj8EzIgpZ4gTvY8F1Ym/ZmVleIu75EdNK0fcfU8LU=; b=ZZpPP3y3rfcJ4ajJnw1tm+Qf8yj0i4nqyZMfWUluzRsDZSIJU+FSZz+gE5nPs00zBYITvm5MZGvf9mbwh7l83nHD+Y04oJBLuiUR7S3VZ/kLe8LAltzPS9X59FoAdFFi3QdA7U+YiKCr6uPg7ZV8t9XBqcJbk+H6wmWL5/21MMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249134333790.0177008949784; Wed, 5 May 2021 14:12:14 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-GtRBuH6iP_iNva46SCImzg-1; Wed, 05 May 2021 17:12:11 -0400 Received: by mail-wm1-f72.google.com with SMTP id d199-20020a1c1dd00000b02901492c14476eso714660wmd.2 for ; Wed, 05 May 2021 14:12:11 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id j13sm662525wrw.93.2021.05.05.14.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kwgj8EzIgpZ4gTvY8F1Ym/ZmVleIu75EdNK0fcfU8LU=; b=N7CdxA033Oz234OXiApIdT4yFd63dcAa+qk+KsHKeWVYPLI1p5VB10DfOAtftkEWvqGDRJ sQmvmEZAXBgdywx9qvg6GCSdHJi54GD94wIBu66yqE7WFNcqqaFdEfAWvW5Dstw03TDeH5 tS4dYWBQyGlepCXzQUWQbOUSwhLj9r0= X-MC-Unique: GtRBuH6iP_iNva46SCImzg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kwgj8EzIgpZ4gTvY8F1Ym/ZmVleIu75EdNK0fcfU8LU=; b=J3YQ+tB1JeFG3012XYT6ckNI8FNzUQFlJF0euKEGq285UzMfyZugMdRPwZCBBaK04/ 2pGoAHAkvcCj9rEJrt3j6LpAvC78jdshly7qytBZixJB+514E4q++eucxGaRkCX2bFvH /xmNBPdrHYDGmMUJxlP4KlO5ag1NrK104y//gy/OvH3L8t8vZDTdCnCaU9b4khYvDzFU 2YEDnHC5R5Jrpu+wSpAc0FhCVwpeK3ffEnw8FbPm909LMglWbLntv+GdeP19+P8ruqGc kvSWVkXfKsKh3ZeCqlKkr+TCP1rLm2T3v4MuhbWJ6lX4Z6650uFhk09qhz6qLZgJdN0c 92Gw== X-Gm-Message-State: AOAM531MLAUOoaIYSMKrtwY/olsE0zR9MgSsxLfH5xpzt9kLGnnzotV6 WrlPvpS/Tlp/3UJKzMlrOsr+wa9XjfOYPhJ3oPEN5pedE1WtZEj3YOYjN1D3g0lglnBEqoGAW8r JF3yJLrHkmqc7bA== X-Received: by 2002:a7b:c24a:: with SMTP id b10mr11922887wmj.157.1620249130676; Wed, 05 May 2021 14:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeU/gkKl1/RQrzu7RIpQuniJrPJO+Ml63VXqZKBlg+G/hZ6m1AkHpuxJoOVC5f8lxaHV7+Eg== X-Received: by 2002:a7b:c24a:: with SMTP id b10mr11922883wmj.157.1620249130551; Wed, 05 May 2021 14:12:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 16/23] ui/curses: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:40 +0200 Message-Id: <20210505211047.1496765-17-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- ui/curses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/curses.c b/ui/curses.c index e4f9588c3e8..f490b2d839d 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -65,7 +65,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 =3D g_new(cchar_t, width); wchar_t wch[CCHARW_MAX]; attr_t attrs; short colors; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249139; cv=none; d=zohomail.com; s=zohoarc; b=aUwxYsEsk/fZlOVE9GvfUCv2IVE0HdSzesgRSzuVpiIUoMXd+I4mb8mJgfCnrhtOnnSA8ZAD4zjAmt5vqp7HivaoU2DdV1NZnMEwv9Oa9wHww27QY89K5uOLE+s/q+q3MILQtrUjrBZFwSg2HT8Zq1SCX0nzjILCpOUMTiu7Ou0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249139; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=PcGiW0X9vtq9AeHwSO5/7tvJlwWuqUWixK9RiaVNbNo=; b=FlJ8LSBWACg/g9dgpRnybuZVdaKGUHTP1t0bF5wJQhRtj6Ybx4csZpckMIYBnY8TaVfmSC2C49Cs//4/gE4gaqwJudyaA0PUlOPZb30nOvq6hPTEeqUbrFZZ5Ejbsa9yPMxywGNzWJYcGJd+WtNuVXb/D3u8freTYcXg+qIvL88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249139864395.14376478109943; Wed, 5 May 2021 14:12:19 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-2IOfJCeZOBi4t2TSSqaaNw-1; Wed, 05 May 2021 17:12:17 -0400 Received: by mail-wr1-f70.google.com with SMTP id t18-20020adfdc120000b02900ffe4432d8bso1219340wri.6 for ; Wed, 05 May 2021 14:12:17 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id k11sm6860115wmj.1.2021.05.05.14.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PcGiW0X9vtq9AeHwSO5/7tvJlwWuqUWixK9RiaVNbNo=; b=duu/bfU17AD/JIbBWszszG49BPhYpdym0GfZ1KHUG/NkCI724zPtluD4PChV3XeWUv+T6t nLQtdO3ruIJG6kIiFFc+KcXHyJiQLLJP/cibmDEia4hyjFOqX/lJRmfpmN9GqYuyYgKGdj JylH4FY2FOKvUgiesiEvrBy1AwHxo00= X-MC-Unique: 2IOfJCeZOBi4t2TSSqaaNw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PcGiW0X9vtq9AeHwSO5/7tvJlwWuqUWixK9RiaVNbNo=; b=OdQ4FWCyXJ/RGwpE9yCxLGvv+rXwO4D4+b98UmhGYZXiyQaaqD36aZ3rldkffX5/PL +jt4ZB4DDyswLayy8SwdrlW1iY1bBWuVjmCzvLNR+Zwa/szRLlMth80Sj/ilZ9BR+gwc 0NjUHDNn9A/LrxeoKO8AjAkzX0RRC+abIfpxE8da+YsCM9H/Uqi+JPSTWcJo5376CELx CyVIOJcHdxb8TyBtuZeVFn/6VrTcVCnn7UFhvn7LHP0pcrrRRliOClatuTPjf19YDM1n uly0HcscHGBfd9pdq6QastP0CWRW62crYZmOQQhzhKgt7kRmNrooH7YyFwaf5Wc20NQG Kxhw== X-Gm-Message-State: AOAM531QwSFUZmBwSQy9sTT27CHbi1GH60BtNfrYC6Ui/7tIbxQaNZco JPDJrXB868XgUnGKG2XU1RDtmRSp26m4RZkVDvFOL5IvkJGs94O9YE/N1gnR8f01Kz/AEHVoAIv q2OYQPYDbqPMgqg== X-Received: by 2002:adf:ce12:: with SMTP id p18mr1088942wrn.228.1620249136156; Wed, 05 May 2021 14:12:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywBh5xeB7vHSsLYKX/GGT+xyMQjiQ5BIO2GwRPm7/QvGb4CvRhfISGZeqUJcRkdxtoUmmV7g== X-Received: by 2002:adf:ce12:: with SMTP id p18mr1088923wrn.228.1620249135989; Wed, 05 May 2021 14:12:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 17/23] ui/spice-display: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:41 +0200 Message-Id: <20210505211047.1496765-18-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- ui/spice-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index d22781a23d0..61c4259363b 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -188,7 +188,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay= *ssd) { static const int blksize =3D 32; int blocks =3D DIV_ROUND_UP(surface_width(ssd->ds), blksize); - int dirty_top[blocks]; + g_autofree int *dirty_top =3D g_new(int, blocks); int y, yoff1, yoff2, x, xoff, blk, bw; int bpp =3D surface_bytes_per_pixel(ssd->ds); uint8_t *guest, *mirror; --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249145; cv=none; d=zohomail.com; s=zohoarc; b=UMz1HxeTi+8hT7+30kB02H+L/V3/9wRmYaVXhxtdEkKjJ1adenlE9JC2liWm2NokAqxM4gLPNT7lMl26jZSXfyO2XN5yFQwsPEDS+2Od9895SjkZXV9/xo+r48JYmUNZZ1hfKK2aJh6D7VjZUmbt0XFQN1yG26KIrLbMxVwFKws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249145; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=oW5QmBlxBqqDs5oSoQXSMxZQROwxDbKkCtS/0EJBiMo=; b=O1CrOdlR66xWBlfeblE0dpvhqtdEji+GL/JPegNoUwRi02T5GgSx+dBjbeB+ZnRdAYgmlfunDE/mJMarx1QJeArCMbw/YC36EPPbBtzATsrN9uKJsPhg6Hz6qR/+zYhT0JQXFHwdJ6odNJO65iFwCYD/chcYj8ulb/UL4qkkF/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620249144995618.5556282928968; Wed, 5 May 2021 14:12:24 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-Y0pyD-v7P1-c0SpLWsO0uA-1; Wed, 05 May 2021 17:12:22 -0400 Received: by mail-wr1-f71.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1191634wre.22 for ; Wed, 05 May 2021 14:12:22 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id q12sm6055450wmj.7.2021.05.05.14.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oW5QmBlxBqqDs5oSoQXSMxZQROwxDbKkCtS/0EJBiMo=; b=R2mCIkVuSSZUnGQBRIkjHXzNKZbvZqFQcq6FIVZKgEYsI6OpPhqPmVl3DiRUVnl8DyFWmK 1OQbpGmW/NDy+7OWcYyPByBLxsdU22q2NcXYliegRgZGDLjkd4ww9LO5tw1tmwKCW39Cla MYNYaOPFxU1bcX+//92HHakgg+ZOBCQ= X-MC-Unique: Y0pyD-v7P1-c0SpLWsO0uA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oW5QmBlxBqqDs5oSoQXSMxZQROwxDbKkCtS/0EJBiMo=; b=fvRPp7Aq6g1imJ7g77A2CaoQ3aNgHNk1jhHo0fy6+WpJ8oLnfCKD1JMwakg57RgPep 3O6oehkwhJxfsUXyveQ9p8JExD9F5t9q+Q4EzITnh2q2Oubfu3EZ9KA7gKHuGIzuR4qh ax3TRaJs10SScu2bkL8xkmcxtM5DHW2XHs2AHaDShPerlTbEZi1e4Upr9ClEd7aSnT9J 9440my7k3Vbt+3QpiRfSVcZ//BTvbG3QmvkPFqNmbdNOWLlPfx0ySEnjykt+CEuPfNLg zs6CvDMqVjlOgRS9VcWg3YHNHdMzU71kW1EvfgStDSDzhl6U5Owu7xyn4ePXiMZRnVsi D/aA== X-Gm-Message-State: AOAM5311sBTf1V1psCINKtIWvkzFGODmmUQj9eXs2Qx3YZYJMrP3wRLO gMzVv6fTlw/aJYeMrI/7K6SNIITxNVOxONIOOzaBKm6t9F1xIvumptntx3391xb8ACWlIZd4b0J 11fURyfN4Ap1Cbw== X-Received: by 2002:a05:600c:4ecd:: with SMTP id g13mr592610wmq.173.1620249141109; Wed, 05 May 2021 14:12:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCmwCC0zD2jn7wQAdZyHRrtQRvCZX4zdE25lUjd9tnpTZWp89G9DSliz8fdw77Tu2zsRyi6w== X-Received: by 2002:a05:600c:4ecd:: with SMTP id g13mr592598wmq.173.1620249140919; Wed, 05 May 2021 14:12:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 18/23] ui/vnc-enc-hextile: Use definitions to avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:42 +0200 Message-Id: <20210505211047.1496765-19-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We know 'pf.bytes_per_pixel' will be at most 'VNC_SERVER_FB_BYTES' (which is actually 4 bytes for 32bpp). Instead of having the compiler use variable-length array, use this 'small' maximum length and autofree to allocate the buffer on the heap. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- ui/vnc-enc-hextile-template.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/vnc-enc-hextile-template.h b/ui/vnc-enc-hextile-template.h index 0c56262afff..85e67bd9d88 100644 --- a/ui/vnc-enc-hextile-template.h +++ b/ui/vnc-enc-hextile-template.h @@ -25,10 +25,11 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *= vs, int bg_count =3D 0; int fg_count =3D 0; int flags =3D 0; - uint8_t data[(vs->client_pf.bytes_per_pixel + 2) * 16 * 16]; + g_autofree uint8_t *data =3D g_malloc((VNC_SERVER_FB_BYTES + 2) * 16 *= 16); int n_data =3D 0; int n_subtiles =3D 0; =20 + assert(vs->client_pf.bytes_per_pixel <=3D VNC_SERVER_FB_BYTES); for (j =3D 0; j < h; j++) { for (i =3D 0; i < w; i++) { switch (n_colors) { --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249149; cv=none; d=zohomail.com; s=zohoarc; b=LqC8zUuX8DeIYoXb4hkr3+fhLKOyfmUg7T8BnXo62VoNybAX9LV9oR4pl8OsLt01nM9h5WvWkjXhYfzPc5vrgGjnyNFTazEWjbroOvJZzFL0d7Ve+lBLxcPvYzv2C2/PTEKLOu+J/bb8dNhjOij6tCU92D4/a2v+Uw27clWgDOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249149; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=SmRPmb4hC8Fjru663xDAXcQsgbJqooC87XEyEFNRFMQ=; b=X251O3gkz1FNmRkzuq6qugUS+JSt9vDphVCpKQ+h8voYxXGteoWMB0Avq1WlzVxRg3ebKCAa3X0qMsZSFhVWYi0ACwegXkVaf/brGfHxL/Z+jCdhf1u3SvVnH//oA/B+MAEdUoZM9mOi/1bR8UAc5Bg6pWq9eYKkifPy7KxtnqY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249149902321.174660799977; Wed, 5 May 2021 14:12:29 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-dpyLak5wOtCxe8dxfV9Ueg-1; Wed, 05 May 2021 17:12:27 -0400 Received: by mail-wr1-f69.google.com with SMTP id a7-20020adfc4470000b029010d875c66edso1197840wrg.23 for ; Wed, 05 May 2021 14:12:26 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id i13sm728316wrs.12.2021.05.05.14.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SmRPmb4hC8Fjru663xDAXcQsgbJqooC87XEyEFNRFMQ=; b=DPUFwytlwfCMIc1U/amfSlIuPRZyMUS81zNqjuEmB5nNGhVk5XIaPx3NHlTX+gMamzIQ+Y L0B7B7UMKEe27WPxJLct/ZIgaSBfNiw9A6+xctrnZWQ27E5+AnF78/AFVtGRxalpKV58tE ziWOaXzOXRIjLa3CYkocjH0a+KgLQLg= X-MC-Unique: dpyLak5wOtCxe8dxfV9Ueg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SmRPmb4hC8Fjru663xDAXcQsgbJqooC87XEyEFNRFMQ=; b=TOrPAFKfilq+kkvhR1M8fPJ1AS4FoXWs6lgeBK9qoyOvrd/ui7+Nm4wX4bnScPCyHf pdxopVbP/Qiajsydb9NHB1mlDhELHDfBsQ0P93jRETYL50XIPIfDatkXYTLLTyV8aMBo TX3c+H+KRj9f6KiR8riv0H8YsD8ymgAt8ZBYNHm1dqaPjbsjeEbo82j0Cwph5pRV7X1r 7TIF//1gYyp7Ii6xR8UEhZdNW+qLF17IvNOAbx1EDcNCmFwulukC2Q40UqYgOgmaJPx5 sWLFmcARO9lHuuiNAvvHjeK1lx5hWGA3h6DmnoduXanvewIsyhI28v8O2/SBoxlSw+7P ahCQ== X-Gm-Message-State: AOAM531RvxkogZwKeB4zPobKUml3bcuBv80mvupQJfyDvrGHwUwnaKTF m5FsOAXmK4+e4x3WkoZ5aK9nFW2obD7/uyXpAp+uBsR+nykAQNcfqzpbP7Td2GLGhLX22fHnxOW No6T6jpInR6FYrg== X-Received: by 2002:adf:fe02:: with SMTP id n2mr1006751wrr.355.1620249145955; Wed, 05 May 2021 14:12:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGaMig5BIWWmqxPYj38JqUy41lSxrODNKmbDkEja4RdDilHYo76RG1j5RpQhtiMnidhMw+WQ== X-Received: by 2002:adf:fe02:: with SMTP id n2mr1006739wrr.355.1620249145792; Wed, 05 May 2021 14:12:25 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 19/23] ui/vnc-enc-tight: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:43 +0200 Message-Id: <20210505211047.1496765-20-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- ui/vnc-enc-tight.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index cebd35841a9..ff6027cf8d4 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -1097,13 +1097,13 @@ static int send_palette_rect(VncState *vs, int x, i= nt y, switch (vs->client_pf.bytes_per_pixel) { case 4: { - size_t old_offset, offset; - uint32_t header[palette_size(palette)]; + size_t old_offset, offset, palette_sz =3D palette_size(palette); + g_autofree uint32_t *header =3D g_new(uint32_t, palette_sz); struct palette_cb_priv priv =3D { vs, (uint8_t *)header }; =20 old_offset =3D vs->output.offset; palette_iter(palette, write_palette, &priv); - vnc_write(vs, header, sizeof(header)); + vnc_write(vs, header, palette_sz * sizeof(uint32_t)); =20 if (vs->tight->pixel24) { tight_pack24(vs, vs->output.buffer + old_offset, colors, &offs= et); @@ -1115,11 +1115,12 @@ static int send_palette_rect(VncState *vs, int x, i= nt y, } case 2: { - uint16_t header[palette_size(palette)]; + size_t palette_sz =3D palette_size(palette); + g_autofree uint16_t *header =3D g_new(uint16_t, palette_sz); struct palette_cb_priv priv =3D { vs, (uint8_t *)header }; =20 palette_iter(palette, write_palette, &priv); - vnc_write(vs, header, sizeof(header)); + vnc_write(vs, header, palette_sz * sizeof(uint16_t)); tight_encode_indexed_rect16(vs->tight->tight.buffer, w * h, palett= e); break; } --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249154; cv=none; d=zohomail.com; s=zohoarc; b=ccHpsV8J7KTMnLw7P1qeWHLObJ3t1VdZtLpcPqHvBAvoUVSnR2KY9zj8zwm/BUVtT71jz5HKXaxP+nUUTMkuXC2Sgfi6cxySSZkWuMFNx4SAc/X2fjrEcWa8XNdfY4tuqCuU0b7ocu6xgbtzDa/W2zdPDB4Fj0/BXeutYvaehjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249154; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=X2rQqCwa2CI67ec0xDXbK6Ggh5ghN1UL3hcSFXFlsJk=; b=NdMoX/iH0bizehE0xkUdOQxd2iOdHjAKGsQPiV89FoWbNYfYo2k20DxyEmaY6agk03Jym8DlQH9gjiev3ELDnTTh4+FpqMfBMLdtQjkrdAjaaaUke/jbm4c7n5QRxAFwpkKgv1PIR8K7XEYdN0XjzeceBe8AKrl/2Nmhd7v5k+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249154208348.85269074236237; Wed, 5 May 2021 14:12:34 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-TDD4Vg4SMK-hTTpcoka_Rg-1; Wed, 05 May 2021 17:12:31 -0400 Received: by mail-wr1-f72.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1191810wre.22 for ; Wed, 05 May 2021 14:12:31 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id o17sm678489wrs.48.2021.05.05.14.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2rQqCwa2CI67ec0xDXbK6Ggh5ghN1UL3hcSFXFlsJk=; b=Pr5udrgg9TS1uJAKCi2lq3mFIwJDE2jHHp3IrDGNik3dqpGBZyvt+g292yUiuS3WlgxwLd pAPVZn/HIU+5XdDR4IYMjC+SZqcvg3LuHFlnxWOCmPObT7mANbpZojA3Ofjx9YvSNwHV7e ygRPxMX4d8+wfC63YMCZABOBVX+yHhM= X-MC-Unique: TDD4Vg4SMK-hTTpcoka_Rg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X2rQqCwa2CI67ec0xDXbK6Ggh5ghN1UL3hcSFXFlsJk=; b=itryuwmw/D6QNxkReCDSSB8lX4ikl6qOvpisfMyaFk/GU92pggGmTsMqTJI1ijQfbW px2uKmWNXvcMr58oZkXGgyO6fpuswSo2P1ctl0+OHKogvD3d8qVSnHoHksIlMhNs4XJq FG5DKnexo+az6qf4vLc+sqK/7A/6Oq7pyt8go8CxnA3yGAizSdtHHi+/eVQKXF4BIhUV oPIX+onvLPhhsqrhMDr2RfTmyHHxW6VYLmL7qTRGIEJ2ZpmSf3qasGiAUWNLyp8sCMV4 1kB/7z6Ar2B2DxKF/ezthoyeyLxWuvCv209Fbyb6RGDvW0D02C2MsXNE7BJ5v1GecRMs K4Uw== X-Gm-Message-State: AOAM531g9kfSQ6ANAvl1xe22JqM+Hv58OonLB6fv5zhjjw73VlKWrFph mJq2w5GD/w1QPmaGblmdCOWTpkx82bSev/BxWo/BufQJoYFRKh+ss7f+oUNsYcrLVX37CtU3bAw ML+aoJTCWkD5GUw== X-Received: by 2002:adf:e48f:: with SMTP id i15mr1079368wrm.266.1620249150615; Wed, 05 May 2021 14:12:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs8cqrFZGnHSpVMS8gH9Bhhk3os49FfcAKDoTxp7au5qsa5UU88MA7gB+W9tdKfVtG2iUBug== X-Received: by 2002:adf:e48f:: with SMTP id i15mr1079360wrm.266.1620249150497; Wed, 05 May 2021 14:12:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 20/23] util/iov: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:44 +0200 Message-Id: <20210505211047.1496765-21-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- util/iov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/iov.c b/util/iov.c index 58c7b3eeee5..fc76d717e14 100644 --- a/util/iov.c +++ b/util/iov.c @@ -623,7 +623,7 @@ static int sortelem_cmp_src_index(const void *a, const = void *b) */ void qemu_iovec_clone(QEMUIOVector *dest, const QEMUIOVector *src, void *b= uf) { - IOVectorSortElem sortelems[src->niov]; + g_autofree IOVectorSortElem *sortelems =3D g_new(IOVectorSortElem, src= ->niov); void *last_end; int i; =20 --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249159; cv=none; d=zohomail.com; s=zohoarc; b=bK2T/uDXgZxKAh/tB87HkxC3YQSabZdx1waVp4l6aCkuqHYKWuo+bE8jg25Wq5tkGD1MtW3gg9hlAikayLuZrU1sEpBXz0yz/0R3QuTyMgrkBrrpzOt5Hm0CIlwDkMj2zQFRWZncV7DIVlHqD1PfVKztPrpXZab84NVDqJ4moz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249159; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=gqZEVFVeZ1PP5CqVjY9bmTR5zVRvOWsxXWPKEVWrRSk=; b=DNwEWj/gA5eK0dCVNBCYvSHpA2N4ZxIXLJBk/lOROLUJI+EMzw1FxYBFlug7rSua5vUlY5cQGqcOH4wqK8NOrgDPoJJFryGNERxDqhNX7jJHaFD++3TVmiSJEisqFVpN9R+j4p2aB2/m4UIKGPel455jHBYEmv5ngkAJD50rYrw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249159046213.45687304566457; Wed, 5 May 2021 14:12:39 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-130-TqyBbL9JMpaSO06OCddDKw-1; Wed, 05 May 2021 17:12:36 -0400 Received: by mail-wr1-f72.google.com with SMTP id d20-20020adfc3d40000b029010e1a640bbfso1203632wrg.21 for ; Wed, 05 May 2021 14:12:36 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id g129sm8432025wmg.27.2021.05.05.14.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249158; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gqZEVFVeZ1PP5CqVjY9bmTR5zVRvOWsxXWPKEVWrRSk=; b=gY5Rx3Q7V55uJUS5JC2o2BYyF3eSr66pjB8CeBgzbPylsW4hGn1jpW3qbEzf7Mos+md85M U/rouloOmcIK1oJ8UMvPdSzKc5dNk27afIczwlA6p5oExFVclpFw0W+qgIMacFfvRPrc60 mThiY77P2+9KyS+l762/oT5yQR7iem4= X-MC-Unique: TqyBbL9JMpaSO06OCddDKw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gqZEVFVeZ1PP5CqVjY9bmTR5zVRvOWsxXWPKEVWrRSk=; b=oMPuqkFfezRYJQCwpuTRA7yDN+eOUgus5gpVd5iSbY5O37MGx5V9fVKGaf68v7G6EC HHIy+LjIxPjNG1voh6HNQmcJ+bNc6osx15a0/bw6bxKbQqjj7y7BMh/OktnaZt+Ggog8 Cz8Uh2knfWctszhrEdBYLwSGCv5IoygaAnESoByd8YtGpWT2sVLCu+tSJaqW/i9fcxAS 8Wo11vXGOi5YrEZr1yq19hQ4K+Tnabokvt6JENnwzOS8iNdCJQlr8HS3ruNZmu7g7qhC TIjwxyB4mBnqSIyutDCxiitWo8UxeLCiJiC9jca49W0daxCaUKXXMkAvNTOV2ZEzsUbo oHxw== X-Gm-Message-State: AOAM532xlEa8F5tZ+aFyj5ndoWs3SBOqEWJzZ9nsSxstp2z+qJN0/Jht YDGdvUiWp1p5H4/AAVQKX5gX4x5/le+4IrTqVU1rvRP6r5A0K1AvTHmSOgqiOJ9R1oTFIvCo9xN kJ2McxmPlRZidtg== X-Received: by 2002:a5d:4351:: with SMTP id u17mr1030228wrr.47.1620249155512; Wed, 05 May 2021 14:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdfQQZsRtZ7nyL+DSHqlEkFdqu+Hv47j75LD54ri+lhlT8Xt5UqHtwkM5tFFazugNDQCPNDw== X-Received: by 2002:a5d:4351:: with SMTP id u17mr1030222wrr.47.1620249155407; Wed, 05 May 2021 14:12:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson , Greg Kurz , kvm@vger.kernel.org (open list:Overall KVM CPUs) Subject: [PATCH 21/23] target/ppc/kvm: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:45 +0200 Message-Id: <20210505211047.1496765-22-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: David Gibson --- target/ppc/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index ae62daddf7d..90d0230eb86 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2660,7 +2660,7 @@ int kvmppc_get_htab_fd(bool write, uint64_t index, Er= ror **errp) int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns) { int64_t starttime =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - uint8_t buf[bufsize]; + g_autofree uint8_t *buf =3D g_malloc(bufsize); ssize_t rc; =20 do { --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249163; cv=none; d=zohomail.com; s=zohoarc; b=XsA5rm8ZjaM2Si0MY3y++RKrIK90BR1WKG0E4by8rvIiXYtbbEv1boOWAoKLALoFx4/U0jWNt3y/wnyjyG/enZhM+8NEc4ioJNVv02SYLQuqQphpIP0bD/bN3lIVZKA0DWM8u6jnWVLLuSQQukosnkygyX5/tlVjmKqS9Zb5OPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=FUeFPg/DBT6PTTnQUMbBIc/iv0DSckK3YeVFNuGPU00=; b=HAPSK2uL4zv6RP9hzWeWXWqGOZAbvbzyNlgF3ew/zBWkJj+1U+nyLMx6ftJoLTGA4GrhwrHEKq0HqDZGz6y9X8g0ifls99/VI8w/1fBJ/P2COLBwSwbOeNlOE1XUShiTNnS1zJyJpth38OzDyAzOxz2soFy3tvJh8LDJwNi7CWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249163756508.32215578394414; Wed, 5 May 2021 14:12:43 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-XMbvzIM-MpC-QpH6kGIbfg-1; Wed, 05 May 2021 17:12:41 -0400 Received: by mail-wm1-f72.google.com with SMTP id v2-20020a7bcb420000b0290146b609814dso730246wmj.0 for ; Wed, 05 May 2021 14:12:41 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id e18sm725918wrc.85.2021.05.05.14.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FUeFPg/DBT6PTTnQUMbBIc/iv0DSckK3YeVFNuGPU00=; b=G7c+mrOgcT+LU+q+LPMHWaJFYJME2DzO66SaAYdDLXklBbttj+yzlwGiMdzYtxwO9DQDvM ShAkp4L194JJUvFkwLZiUsJzpDF+6QVF3fJYbKtBDKkG1E36OmU+YM0GB0GroKA6UJVyag +j5jm/0XE36EuLi6Zz71YIjkbM+P3dU= X-MC-Unique: XMbvzIM-MpC-QpH6kGIbfg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FUeFPg/DBT6PTTnQUMbBIc/iv0DSckK3YeVFNuGPU00=; b=M0a/naYFNovY2uErQoxGpz/IU80Ovn4heauczlSgkviMZjYjDEYqAH79PAyJV0VxZE MvOi/CbsLfvAuGrWW216+9vEaNd8hHUwvPLiBeOV9y5qfJZVKFGQHot+89+Sptlbhj6C IcmlTjTRBFTnbD5BV4BjhtYpnUWvTu4LbPeZTncFOg+Bz26/fyNJ2LXO9BmSlX+BdDGB rdS62H1d4qUe+g0bSUrmW0g7dJPO/8+72vmVOETBx2a4MRbJHXCmFbaFMWdzNXwQwPQP 3bqEiY8naR9IY3g68uTA33N9PbfCr3+rAAa16D+458/uPGlcQUSL9b2niWUyZWBZEyOp 1Zfg== X-Gm-Message-State: AOAM533wfsV3MZvYISYytUzzAFC/tD8EZdbPkXcdNB/tLwnfRw+m7lyB ePeaPWf0Js3mQDxbkqqC5Tg8px1fwEH7chBSMaYrgkepr25PNfiHoRSyRR3FV9NFy7JrtmIE6Co na6u54gt3Q/pp8g== X-Received: by 2002:a05:600c:4b88:: with SMTP id e8mr669494wmp.74.1620249160168; Wed, 05 May 2021 14:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM4vkT9fyrsRuOzWqlqhNnPCxLKxFJ+/jKPVgfZG1Gaf+tSButEFgSsc6olHkT1yfZy+fPmA== X-Received: by 2002:a05:600c:4b88:: with SMTP id e8mr669481wmp.74.1620249160047; Wed, 05 May 2021 14:12:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 22/23] tests/unit/test-vmstate: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:46 +0200 Message-Id: <20210505211047.1496765-23-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 a001879585e..2d7ef42d73f 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -86,17 +86,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 =3D open_test_file(false); - uint8_t result[size]; + g_autofree uint8_t *result =3D g_malloc(size); =20 /* read back as binary */ =20 - g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), =3D=3D, - sizeof(result)); + g_assert_cmpint(qemu_get_buffer(f, result, size), =3D=3D, size); g_assert(!qemu_file_get_error(f)); =20 /* 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)); =20 /* Must reach EOF */ qemu_get_byte(f); --=20 2.26.3 From nobody Sat Apr 27 15:32:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249168; cv=none; d=zohomail.com; s=zohoarc; b=eketjXj7hH0szC5/V0GsTQWQapDjNATrE+IkTPFHY4K0SnBY/JslXGK4+kFoyGRgVfcub4SZeVnYN6d3ZVQvPNgqj5j1vxWrfDThRfi+v0qqIsxgZMlqjLcBqj7MXkjNqlg6h9lTe6624mqmAOHgr8+6qRM9H+zIDnvvPmCbkHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249168; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BNIGbNGB2kAXmzDhqFSxh3VfwsIC++UOzvIwklsGj4s=; b=ZVmOKjOwbxnlpWzfmXcLtOGye0CCvZ+Xt3e9Ec33eRjmuxqmkuHICpJOX9GbFacSAgnTvGPu8q+zBrOsCh4Q5wSkTb7QegL4QYvlt6Fk9PjoLFr7RSaz5vdJci0fsfaNt3yqhiq9rh8HqjqDlIjrvraOum+kvlRl+KjAhLDdA1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16202491686563.9407425092369976; Wed, 5 May 2021 14:12:48 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-539-3tq-xXRPNMqcyPmOd8M7rg-1; Wed, 05 May 2021 17:12:46 -0400 Received: by mail-wm1-f70.google.com with SMTP id u126-20020a1c60840000b029013f6df1cd5bso748974wmb.0 for ; Wed, 05 May 2021 14:12:45 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id n10sm665996wrw.37.2021.05.05.14.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BNIGbNGB2kAXmzDhqFSxh3VfwsIC++UOzvIwklsGj4s=; b=Fk5Bwwx9aQ1pXtVS1K/0zc1ZW5lKNzYh8j+TZNxzPyFUSDN99YFL3l+OadNJza+LZ74UNO IpDa43WuDlZPIncs0aN6dtrYdKy59w7OmdCD9bwfq+ozxHOq7ZEOMijWJ1ZJtVkLMh3xPk zbJNYrXmvOte83j/37Gwa9IPrzi5gG8= X-MC-Unique: 3tq-xXRPNMqcyPmOd8M7rg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BNIGbNGB2kAXmzDhqFSxh3VfwsIC++UOzvIwklsGj4s=; b=MMKVcLkA2JTnk12i0WQBuej6YOMUHxYsJDYTvlHNKHeJREVH2E8eKbOsqotIzFjmIb C4B2sKMNWZqXTTZecs4sDTcF6poqqxpWAX1sSY4hMFERn7lh/yyRuHnaVQOP0zeB869X Q9GETGNm3+Mkan3ERVC45o6cDOjmfmna7tUbW6C+6X65CZJl9toqOWYp8y/mT7ih8OKG df6p/+gCr0FVHURacz3YW0AaSy7dmtiZBnMLCKjI2mkICFRRNKpioYyzqzrNiIdT4vhH 8poK2VN6SV+EilKPb+jyZiDSkHOpAWBCL8LZs2aNP4LK8lcMJWW9KioKB48T2aGNY/+j yuEw== X-Gm-Message-State: AOAM533fygWZBgmytpvkvsRvAie5uyM5YAFzpTSY35FwNL26zxMxl3Zd y7l42fo5VQHkpvFzDuZw0eMNcfPktV/BWrZe318pF+g0xhsTv0JejFL0HYUmfYLh5eQ4q5F4xfJ 3DneakoS9JjyxVg== X-Received: by 2002:adf:cc85:: with SMTP id p5mr1048079wrj.75.1620249164921; Wed, 05 May 2021 14:12:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSKnbW9quRN+wUvUODkYnuSjkpq3sgG+NpbBMsKxtmu82GgOeCRXqipeTdWbz31k5j5lvi5Q== X-Received: by 2002:adf:cc85:: with SMTP id p5mr1048067wrj.75.1620249164748; Wed, 05 May 2021 14:12:44 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 23/23] configure: Prohibit variable-length allocations by using -Wvla CPPFLAG Date: Wed, 5 May 2021 23:10:47 +0200 Message-Id: <20210505211047.1496765-24-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Now that we converted all variable-length allocations in the repository, add the -Wvla CPPFLAG to trigger a build failure if such allocation is used. This should help avoiding vulnerabilities such CVE-2021-3527 (see commit range 3f67e2e7f13..05a40b172e4). Inspired-by: Gerd Hoffmann Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 4f374b48890..a78ff15b52f 100755 --- a/configure +++ b/configure @@ -552,7 +552,7 @@ ARFLAGS=3D"${ARFLAGS-rv}" # provides these semantics.) QEMU_CFLAGS=3D"-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS" QEMU_CFLAGS=3D"-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" -QEMU_CFLAGS=3D"-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" +QEMU_CFLAGS=3D"-Wstrict-prototypes -Wredundant-decls -Wvla $QEMU_CFLAGS" QEMU_CFLAGS=3D"-D_GNU_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_LARGEFILE_SOURCE = $QEMU_CFLAGS" =20 # Flags that are needed during configure but later taken care of by Meson --=20 2.26.3