From patchwork Wed May 5 21:10:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43839C433B4 for ; Wed, 5 May 2021 21:13:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0393613EA for ; Wed, 5 May 2021 21:13:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0393613EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOpy-0002Ma-RL for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:13:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnN-00089p-IJ for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnK-00042S-RZ for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249058; 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=e4Vgyd2IdMFDq0UWMXWpmX05ob2NmHHPuWcHz+V5R1JKlZME/MHL5Pq1r7jguLZXk48E4F 6h9TZJARagoT9P0NxggbJ+AiIeS3lrcr6v+ByeHV+peXorXf3ijOV1gjJS0EXBKCSGcM4b 7zqOAeHcIORxLg7lHXovluZPxV8Jbk4= 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-462-HPWenaD1PPeKcoOr84CpNg-1; Wed, 05 May 2021 17:10:56 -0400 X-MC-Unique: HPWenaD1PPeKcoOr84CpNg-1 Received: by mail-wr1-f70.google.com with SMTP id l2-20020adf9f020000b029010d6bb7f1cbso1210985wrf.7 for ; Wed, 05 May 2021 14:10:56 -0700 (PDT) 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=Wtn+SjXLp2YbDc/oIWS+MEZEwj7jrrdG6dhkeeIAiAX08j+iZ4Apk3VR50ok7Kza+s 7UMO0ng13MdFrnKvTeCByjJJvPHOB3nWTvTmwHsCWBicfnQuB1E0FI6rJpCtoMPnQNDY YwpGzu6hi1kIXN566ZyhPGNS6Fjb8fgueyJKOKoRNv5iHE4Di17EJWgJKeofdnsRHzW+ PlqgAn6j5a1BAmbZhT6LWDzqD4gL5Hc5Fuk+dNHR+wgJ+PzFUQqU4iVYXblQqTbeD+W8 4LVHYZyCKvAgIJ8GUQZhqBRyZ+VA8yY7LPN0Yg6+3I1ktaQtQG+P1jAv80KZSlWuer0v kVQA== X-Gm-Message-State: AOAM533OLClsUc2+3NuKQ+7qosUn1R17CXWHGSw4csaYXXk3J46I8C21 ClLxPEee7M5eToWNLpRSflFc7qdzGDxdT7qnruqMq1Pj68Q2QHbVhB8WSWsIUL+JE+THAZ87kjy BdlikMfT0DfM7k6w7a4Ly+00sUXjmIwpgTjpF5x0xTqN29HsEELZ5a4kqDLCi+ead X-Received: by 2002:a5d:4e52:: with SMTP id r18mr1005313wrt.179.1620249055108; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , Max Reitz , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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 != bitmap_offset)) { - uint8_t bitmap[s->bitmap_size]; + g_autofree uint8_t *bitmap = g_malloc(s->bitmap_size); int r; s->last_bitmap_offset = 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 = g_malloc(s->bitmap_size); /* Check if sector_num is valid */ if ((offset < 0) || (offset > bs->total_sectors * BDRV_SECTOR_SIZE)) { From patchwork Wed May 5 21:10:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7DD5C433B4 for ; Wed, 5 May 2021 21:13:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D2B3613EA for ; Wed, 5 May 2021 21:13:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D2B3613EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOpt-00028m-54 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnT-0008E1-QA for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnS-00049c-AC for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249064; 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=X8HP1SO/x3wW+y8yFQy1VqYn4VsbNfiM4sGzhhfUe0MA3lKzLMvIMjeGddffSFuVGHHomJ qXTwvHaJV/UhYz2mHKElos5WCHctllqUtb9kvUuPd4Vhg+DVURIRxrn6exydJy/PzmHBvA /yJxe87P6xHZMcnSL+I0PB2utrVv4ec= 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-516-i3gvtOTLPZSGB2hEGmtLpQ-1; Wed, 05 May 2021 17:11:01 -0400 X-MC-Unique: i3gvtOTLPZSGB2hEGmtLpQ-1 Received: by mail-wr1-f70.google.com with SMTP id n10-20020adfb74a0000b029010e1a98fb84so1237452wre.0 for ; Wed, 05 May 2021 14:11:01 -0700 (PDT) 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=h9ZXhZrNRxrfEVxR1Qjd7viN9hOgVUl/bjXVqTYsQSjOqFvZqoBx3xCu19jvjdtPfA Fg5BIdqEX14xRzG0rg7nisAmUPmErc+bjBureFIrlSCpJPEyuNkEefmj1ZjU2t53QUOk xHfcn2sMjWuUJOZkcC7CJ+Sayqr4d3o7ND9Ce0jUnVKE96TQlznBnzaukG4yCl0GbcwB v9gtz+gYSL/tsPSifK/TP63M8aH9UjaQaXcSIZPW3zBKLfPlGjMprtoNqF+cil0Om2sb FX8NC/AuryV1BG7LuSj0yB7kIuNAa4Wwh5lPFiQDnnKZ7Mvook1ASSK73bMq1IrVf188 MbQA== X-Gm-Message-State: AOAM532WxGKAtAaBItfZaG9x/tqT/NzZSOO4n53ejEfRNOWGuEu1bprH WSW39wJ/amG0ma4VzjpQ4STa1aAZcMDaw+i9IE0ATai/9JyXggoXZhCRBrBZZIVCTthiGzrnZRO purrjcd5nPTmhND+HFsJmsCdr24lCU+bTrNI5R5QF+MX2kOKNXRN0bTebLMaAHW7E X-Received: by 2002:adf:d1ec:: with SMTP id g12mr1078585wrd.294.1620249059936; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Samuel Thibault , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Samuel Thibault Reviewed-by: Marc-André Lureau --- 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 @@ #define BUF_SIZE 256 +#define X_MAX 84 +#define Y_MAX 1 + struct BaumChardev { Chardev parent; @@ -244,11 +247,11 @@ static int baum_deferred_init(BaumChardev *baum) brlapi_perror("baum: brlapi__getDisplaySize"); return 0; } - if (baum->y > 1) { - baum->y = 1; + if (baum->y > Y_MAX) { + baum->y = Y_MAX; } - if (baum->x > 84) { - baum->x = 84; + if (baum->x > X_MAX) { + baum->x = X_MAX; } con = qemu_console_lookup_by_index(0); From patchwork Wed May 5 21:10:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 550B2C433B4 for ; Wed, 5 May 2021 21:15:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8EF1613EB for ; Wed, 5 May 2021 21:15:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8EF1613EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOs3-0005e2-V3 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:15:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnY-0008Fp-Rj for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnU-0004BN-Dj for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249067; 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=KHDdeDe1m6Zrj54XHU2pDNFXJkOU/N721eZc7/SBQXw+Cc6aTgAWJrMRAka9JTocGVxnyQ D11Xn2qPizNBpCplJvC8/J9yCF/pi+KeukQX/ImAA68DxNau7mY6ZhtpCjZmJZUE1dRAoG P3lMiInHM/lBUeC7ytUhTw/Dt2CgRAE= 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-266-2fGPp7LqPBidA81VxMuPcQ-1; Wed, 05 May 2021 17:11:06 -0400 X-MC-Unique: 2fGPp7LqPBidA81VxMuPcQ-1 Received: by mail-wm1-f69.google.com with SMTP id o10-20020a05600c4fcab029014ae7fdec90so706489wmq.5 for ; Wed, 05 May 2021 14:11:06 -0700 (PDT) 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=ubnkVniNa2DvXGeE86Vx5kTE6qWIVTYsEW5sNX9buss7hayx1qhUy2Tl5pHSddS20k GfdOpav2NJ4tKabieJDb91xgOhf2n3c/5aVoMzHTZXB7lL6VZF/iUjEXAtDMQ7Bjd8hi cBYRjSOIIuLJfMxwMyKT9Fm+fxRjMl0oaD7oiDiVzXOtT8nPI4DvMOq5zLKE7isUapUj 2dAk1jXoFxKHetuMBhTsm5jcBW+xmxrv04yEu1AkLtQtbmRJnEB+gstlMQQx7Ew/d+Qm 1PCzO8N/LTkC9zo8v3ZjMVbcY1aC3WTURECurgj4JuMq3JPer+AUWwkElVZQDjq7Tv9e KWtQ== X-Gm-Message-State: AOAM532oTJG2+Z+6fuaZFya4OXJ7rW0ELYm8xMVLAf4e5vU4zbZpp14N AsacqSswOyH6mz3ytsNnPGAgxbsLLqqo2SmsteqAq4j86+o+fzfnYkn1G9jLbAKn7C2kmzJBWk3 CwogW6g4HiHEUZjG9sbjGzJSiwH2t8cWFNpru/rS0REKt/vl7emv3BJwCaA8dPFpE X-Received: by 2002:a1c:750b:: with SMTP id o11mr12022989wmc.188.1620249064811; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Samuel Thibault , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not a big value, it is actually 84). Instead of having the compiler use variable-length array, declare an array able to hold the maximum 'x * y'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Samuel Thibault Reviewed-by: Marc-André Lureau --- 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 uint8_t *buf, int len) switch (req) { case BAUM_REQ_DisplayData: { - uint8_t cells[baum->x * baum->y], c; - uint8_t text[baum->x * baum->y]; - uint8_t zero[baum->x * baum->y]; + uint8_t cells[X_MAX * Y_MAX], c; + uint8_t text[X_MAX * Y_MAX]; + uint8_t zero[X_MAX * Y_MAX]; int cursor = BRLAPI_CURSOR_OFF; int i; @@ -408,7 +408,7 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len) } timer_del(baum->cellCount_timer); - memset(zero, 0, sizeof(zero)); + memset(zero, 0, baum->x * baum->y); brlapi_writeArguments_t wa = { .displayNumber = BRLAPI_DISPLAY_DEFAULT, From patchwork Wed May 5 21:10:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D92DC433ED for ; Wed, 5 May 2021 21:16:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4539D610C8 for ; Wed, 5 May 2021 21:16:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4539D610C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOt1-0006bO-DW for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:16:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnc-0008JW-E4 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnZ-0004Ee-M4 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249073; 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=XO2dNvh+rbIHzNtMLodTOzUf+D8BYazbfStbsIFp4+8WjSXj8Y7Q6Hd7AmELrKd6EbDAyn SQgh8dYsnx0lAHJD8vowAjjt1CwsFgAqxLOPJ3qfXPsyd1Dgt48HfCNyIisDcneeZtIQH8 +JiNJ6kjFhoYdAlD+Ky6iwSscNxBKlc= 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-472-b2x9IoaEOg-enVhnxLh-qQ-1; Wed, 05 May 2021 17:11:11 -0400 X-MC-Unique: b2x9IoaEOg-enVhnxLh-qQ-1 Received: by mail-wr1-f71.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1190505wre.22 for ; Wed, 05 May 2021 14:11:10 -0700 (PDT) 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=FhhCzZgcnypZu5rIEIC83TUZoyeZO89RgOcUAUNSxgY7L5WuWfAOYIbBrE8sO/i5FL grtrJ+gNp8naOtrjm9LvJd5DdS5+Z9QQ7lM+Z2gRs35qTP1Y8dGv382cObYNQVED7zOl 0vgsw/3v+As9fEVpCmdW8OWOaXvtBtaadMhHrWnPKkLehLjZqIQWVi6SR73mP6U0Lhqd AMMci1I2C+jGTV0LT98Op6cPydx5J6oTegWCVhfsCaq/MKI+Q5voMPxnajX7dG7g9+Lr 6ITdG22ZiC4YLkfZepjJ4RIS05/m1Z49JBItZweh7UZS+0ig61orZs8yhD425emRUOBi DIQw== X-Gm-Message-State: AOAM53206c4kuylkBXOky+8iSRkWEiaVLrDUlBGpwprzyk2/rwZktIX1 S/zSu6GkzGcM0gf5gQeGZ933Z6M6xxNeIxrJ/p+fE2o4LoMrGS3a4EAWbTdcd/a0uQOEadhWew4 4erOh5lW2+JUlJEB1dTCT2imJk+2YY+SKGyz7oNy4FmjMSQeFGVpU+jZhnW9x1Fcw X-Received: by 2002:a05:600c:2d42:: with SMTP id a2mr11900719wmg.99.1620249069641; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Samuel Thibault , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Samuel Thibault Reviewed-by: Marc-André Lureau --- 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 len) { Chardev *chr = CHARDEV(baum); - uint8_t io_buf[1 + 2 * len], *cur = io_buf; + g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len); + uint8_t *cur = io_buf; int room; *cur++ = ESC; while (len--) From patchwork Wed May 5 21:10:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 164C7C433B4 for ; Wed, 5 May 2021 21:17:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95AE0613C0 for ; Wed, 5 May 2021 21:17:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95AE0613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOtV-00073n-GR for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:17:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOni-0008Os-K4 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOng-0004Ir-0n for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:22 -0400 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= 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-502-qLHhiOy1NwO5E7hmKN5ARg-1; Wed, 05 May 2021 17:11:18 -0400 X-MC-Unique: qLHhiOy1NwO5E7hmKN5ARg-1 Received: by mail-wm1-f69.google.com with SMTP id y184-20020a1ce1c10000b0290143299f39d7so1969921wmg.4 for ; Wed, 05 May 2021 14:11:17 -0700 (PDT) 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=Z+lYNefEGFV9W7Ks1hHr/YFMCDGbs8Gdi2i/bR5W/RKGQg13z7RF0uXvFQ3/QdBHea tZS3fFShaPWkyQgDqozzfbZvkgGPKJggQ6CcomvxJPNiP1gNvMGK2XFVfk4597x/9Z3o A050U/zrlHXKHLfKuY1RFXVqs3M3tFNCxr9YH9h31TCOfgWfwoEDD8AVkDZp3+sj2gvJ 6ku0fa1BV9QDhqxrKXwZjro+KL/8haeL7c3fhZMfVDFWKWMv2J3zzk846nyjXYtiHG6s yU0tJe9ZdKuG4nnhb/TuUGCJNrJJdUvtAvg0ESczVIVi7VJOJTOovOpIYAA84kGcTaaP dcQQ== X-Gm-Message-State: AOAM532UFjmDxsW6BdaGNpxUo3oWjNRgyjHuDwDwvnVcOvDdYJZ6QuMv zT/Bx2Fskrx2uq4sHy+iMe57Ldnuje3aovUyH81cv5ND+J60oOECS5E2Wjqiu4Ng/3OT9+mIug/ LqbqnDQxBpvrhfqZe+tjAk8XN6liicNd7covV+L0mJ3OM61Ai5RtdUcH+MKfHrwDd X-Received: by 2002:adf:e5cd:: with SMTP id a13mr1000826wrn.303.1620249076689; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in qio_channel_websock_handshake_send_res_ok() expands to a call to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't realize the string is const, so consider combined_key[] being a variable-length array. To remove the variable-length array, we provide it a hint to the compiler by using sizeof() - 1 instead of strlen(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- 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 @@ #define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24 #define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" -#define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID) +#define QIO_CHANNEL_WEBSOCK_GUID_LEN (sizeof(QIO_CHANNEL_WEBSOCK_GUID) - 1) #define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol" #define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version" From patchwork Wed May 5 21:10:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0734C433B4 for ; Wed, 5 May 2021 21:20:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D1E4611AC for ; Wed, 5 May 2021 21:20:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D1E4611AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOwD-00029N-B9 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:20:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnn-00007u-6e for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnl-0004M8-Cf for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:26 -0400 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= 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-600-Istx_fdjP4GtE0uKe4YfVg-1; Wed, 05 May 2021 17:11:23 -0400 X-MC-Unique: Istx_fdjP4GtE0uKe4YfVg-1 Received: by mail-wr1-f70.google.com with SMTP id 91-20020adf94640000b029010b019075afso1201947wrq.17 for ; Wed, 05 May 2021 14:11:23 -0700 (PDT) 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=tHGtihCsCPjOeyX9GWPLSnRVmGfujaYFwN5u/OZz+DlfKJNTbSlZ/9uFTwDnv9girb aZJfHs04P3cTFy9ITWE4I7RaWCHrTcsJpcY2+KbwRe+iW5bDsKunWHaT19gup9zDW7mm jHiIVFzM5z4GgNw0KoViUIQOLokS5+Hb8xttncdneg2G6FvkwR/7JtnQ1QSVo5T7v6W9 0ZrPWoTEnZYuqdbJoA0HNbo1csW5pQscTRbKJaTIhozKvIg6h5aXkLNv6QC5VTbNmFvV 3ankZlxu9O4/UE+taEkuexi0LmJRje1BKxKKalJhB8zAFmGLR0B3VvSxeE7WbzVGtHej lh1w== X-Gm-Message-State: AOAM532gM7uIiIJCemSNAUmTtHE+FymbFXzM+LYf1eQ16M4bBfPcmimC YU349c4kmllPtanvKbyK72e6od5/w4DYcrWB4hT36m6Av5UAZz0hpXPErqCboaJ9Q/G90gfNUNV N+4sOfY/UQVmVdY3TlnI9lopvjEZ+s6L6tVit8ZuwMdGfvEXg7YHdwqkVvZvCUtID X-Received: by 2002:a5d:4a46:: with SMTP id v6mr1060563wrs.134.1620249082051; Wed, 05 May 2021 14:11:22 -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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , Max Reitz , qemu-ppc@nongnu.org, Gerd Hoffmann , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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-blk.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 = opaque; unsigned nvqs = s->conf->num_queues; - unsigned long bitmap[BITS_TO_LONGS(nvqs)]; + long bitmap_nr = BITS_TO_LONGS(nvqs); + g_autofree unsigned long *bitmap = g_new(unsigned long, bitmap_nr); unsigned j; - 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)); for (j = 0; j < nvqs; j += BITS_PER_LONG) { unsigned long bits = bitmap[j / BITS_PER_LONG]; From patchwork Wed May 5 21:10:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65721C433B4 for ; Wed, 5 May 2021 21:24:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1AEDF613EB for ; Wed, 5 May 2021 21:24:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AEDF613EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP0F-000672-0g for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnv-0000IH-Ud for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOns-0004QG-Sd for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249092; 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=Ripftz+ZW5j52Wp5eAXxhiDIc5EwWmUHgBUzexIeA0hY0mguN6Raoc0XBhPAsVmx3k53ba tQ4b4bGQyZIh0WkXylsAmoVhid7elSMkXQuEmAW6trCQp88ViXF05qoqO2LlJvCMbtL2xj qObRaAlMoqh+FXr5C9nKu96GP6Acp+Y= 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-550-wyeZAzbLOEiICDUiVUWaQQ-1; Wed, 05 May 2021 17:11:28 -0400 X-MC-Unique: wyeZAzbLOEiICDUiVUWaQQ-1 Received: by mail-wr1-f71.google.com with SMTP id 93-20020adf80e60000b0290106fab45006so1200286wrl.20 for ; Wed, 05 May 2021 14:11:28 -0700 (PDT) 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=A+E3JN5JDnmAMNqRH8MXQM1TlZnW1Pqb3uV+2lxYc1n7vYtFTcI2JUIO5BE4nFgbvH kN2dHAm6+hK5PWptiPunoC9rdf301h5xrxwZ2wvPSdHk4nKkvBOtC8cDlDZNDuXDsNOo DshSJAQq7eozjATrtUsvBsz1SpfcnpjN2/di1fBCUo18m6orRJsuTXg5iUgIyH0JOieh w1p+7qaPEl0n1OI3JJgwS4iGqcAlxSdVJFoB6zUcM56UgfTrCDz8KhiAOsMWig7aW+W5 M4xluNCvL2MtLP+daPiwR5UZ+L8YvdQoJq2IyLPi7bnv4cfCMvpwvvE+grIS3qLAZO/c lWrQ== X-Gm-Message-State: AOAM53171Dwxbf6ZtmE/4ZK8r9GqGrWOBIAXZ/zr3aejw46ok/yUrD1s RDeD5QjN3aQbmQVAH6NV6+bGyr8cZ2j6zvSkCIxvu/rmCarrL2DYfGDYmVIR9xxonV9lQXYg8cJ bTZl6mWqiGFCP5v4hkkPIrFB1uuYVlfGFwXBLGdkFj0fKb6UCDuzXHDe3cYQtcjWU X-Received: by 2002:a7b:c846:: with SMTP id c6mr11554276wml.75.1620249086970; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , Max Reitz , Klaus Jensen , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Keith Busch , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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, NvmeSglDescriptor sgl, * descriptors and segment chain) than the command transfer size, so it is * not bounded by MDTS. */ - const int SEG_CHUNK_SIZE = 256; +#define SEG_CHUNK_SIZE 256 NvmeSglDescriptor segment[SEG_CHUNK_SIZE], *sgld, *last_sgld; uint64_t nsgld; From patchwork Wed May 5 21:10:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7836BC433ED for ; Wed, 5 May 2021 21:26:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0347C613ED for ; Wed, 5 May 2021 21:26:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0347C613ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP1w-000198-07 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:26:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnx-0000IX-1r for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOnv-0004Re-7R for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249094; 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=BMmaabNmRIsjbi16SxVtD0nI+ZmOm3cSwhLPJUl7sR6A5MBz3MUBaRa6vehS0FbRyUU+mI M0SJhmprQMPtZdC4lgiRfAa34HG3IHn94ISwT5qz4rsaQN+nBD3lkcQwczbTbaYGNwshfJ I6rmkEmQHAS600mbgMrjBe9nlPOCm4Y= 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-156-u6ZH4po-OvCljXQV0qisLA-1; Wed, 05 May 2021 17:11:33 -0400 X-MC-Unique: u6ZH4po-OvCljXQV0qisLA-1 Received: by mail-wr1-f72.google.com with SMTP id t18-20020adfdc120000b02900ffe4432d8bso1218637wri.6 for ; Wed, 05 May 2021 14:11:33 -0700 (PDT) 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=awLjgMQY1OZLyixixI5C+qFPyuSxwINRiVHCa8HCl/vvreSCwzHSCb8MmnD/Y37xKS zOuQAnsVzG/0rwgqgLMCMXwJf2QEoUR5VQTV45zdNC1ny5OHIWeghH6hvbLTwWE12ZSh k6/i3SdX5li8qHINtEoDF0c/zqlIFATkb29/RoWEyxZLthmRT5Uh+D908I65PgHA8WPS 5LB1oXn2E/B/HVPiFtVWTe10bYTbyYrFnrVX2ftjSrdZ807msy4Seje3UbkFDZ8IckV0 e4XK4T3dO+VF0VI/Ln3iAodAgbzBMM8TLeu6efYHPnI4+bZB3aD9kIV6sqBJCaORXayp oX6Q== X-Gm-Message-State: AOAM53092qIqk0cy4S4cNYpDWWyVzD/RRNIR7RHnsEuSG7IZIytFx5Z1 TLh92UFv20nJm73DTAcWyNoixkktaxeOIDnUpS0e4Nn3c57PQNhLKr25RMuBfD9CAENrmb+TuRu ftZ9dmHiWwikTIQ+Qh6F9TYCDXyJzCfshohLxg0eOkRsmuF8uBvzVUhLlQzuWVNa4 X-Received: by 2002:a05:600c:214f:: with SMTP id v15mr12041994wml.146.1620249091869; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , Max Reitz , Klaus Jensen , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Keith Busch , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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, uint64_t prp1, len -= trans_len; if (len) { if (len > n->page_size) { - uint64_t prp_list[n->max_prp_ents]; + g_autofree uint64_t *prp_list = NULL; uint32_t nents, prp_trans; int i = 0; @@ -662,8 +662,10 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, uint64_t prp1, * that offset. */ nents = (n->page_size - (prp2 & (n->page_size - 1))) >> 3; - prp_trans = MIN(n->max_prp_ents, nents) * sizeof(uint64_t); - ret = nvme_addr_read(n, prp2, (void *)prp_list, prp_trans); + prp_trans = MIN(n->max_prp_ents, nents); + prp_list = g_new(uint64_t, prp_trans); + ret = nvme_addr_read(n, prp2, (void *)prp_list, + prp_trans * sizeof(uint64_t)); if (ret) { trace_pci_nvme_err_addr_read(prp2); status = NVME_DATA_TRAS_ERROR; @@ -682,9 +684,8 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, uint64_t prp1, i = 0; nents = (len + n->page_size - 1) >> n->page_bits; nents = MIN(nents, n->max_prp_ents); - prp_trans = nents * sizeof(uint64_t); ret = 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 = 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 = g_new(NvmeDsmRange, nr); uintptr_t *discards = (uintptr_t *)&req->opaque; - status = nvme_h2c(n, (uint8_t *)range, sizeof(range), req); + status = nvme_h2c(n, (uint8_t *)range, sizeof(*range) * nr, req); if (status) { return status; } From patchwork Wed May 5 21:10:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CD03C433ED for ; Wed, 5 May 2021 21:19:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3716613C0 for ; Wed, 5 May 2021 21:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3716613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOvv-0001SD-0b for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:19:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOo5-0000XV-AI for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOo0-0004Vs-2O for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249099; 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=CnndKlNCbD2ShCh6YR/mIZRBTVwvmwRlkPp6LwV4OOoJimauVa5BhMOzMKVMrt7WuTrFii GaEGB/Q2Cli/Tzj9LQGTJKPNgBx2utY0sbCvUi8L77qkopnHfoJB/7zTmd/QJH7IwYO6Ci gF9l3qfdeqcsx6uaufEbVRj0Gv7MA4o= 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-26-8JmwtaPeN3mMXl0g7cRMXQ-1; Wed, 05 May 2021 17:11:38 -0400 X-MC-Unique: 8JmwtaPeN3mMXl0g7cRMXQ-1 Received: by mail-wr1-f70.google.com with SMTP id 65-20020adf82c70000b0290107593a42c3so1218210wrc.5 for ; Wed, 05 May 2021 14:11:37 -0700 (PDT) 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=aRZH2R9VHMH3De0w+4OROyFRiVYt4Io3ycqWoXWNxKr/Plri61972qD12guYc6BDpj ckyheIDVDKewI56MZQ5fgJxbpBllT9almzUX1dp9j72qXngCFznKY5cu4q4L0UTZn3GE y+bRiqzKMZRmT7N6GdBUxsu1fjPOTDscELpgh7yJLIqqu3HUCClEqo87uOuAEWvLhIcG nz0GGdEAq8KHOKCeZ6VMmuYwPs0PRABLF617LMNPwM4SVn10G4+KK9P8knytYUuHvHjd /2QmnntFYL5jSsUvvheEwUD/dJIQlhWw7K8UUKpSe2HekhPtd10U45coxIntHgqNchP+ OtIA== X-Gm-Message-State: AOAM531KBW/HnFf1vBOG6TnRrNkf8gGR1R7Q4gCP2DH4aUKUM1BcI4+Z AJCb7bz9A93IRJAm5DZ4NXf8xmOHB+0Gl1j1WJAlwEk5Uy7Rj20Cj5WvW1k6X6hUU1Kq+9Rs4FZ xe020y8g1H+dBUrXJJLkoIbArnYMfTh14qULxjvd5PCcsPkgsy+6C+zmVJmu1d+XV X-Received: by 2002:a5d:498c:: with SMTP id r12mr1052504wrq.31.1620249096547; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berra?= =?utf-8?q?ng=C3=A9?= , qemu-block@nongnu.org, Jason Wang , Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The compiler isn't clever enough to figure 'min_buf_size' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Jason Wang Reviewed-by: Richard Henderson --- 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 NetRxPkt *pkt) } } +/* Min. octets in an ethernet frame sans FCS */ +#define MIN_BUF_SIZE 60 + ssize_t e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt) { static const int maximum_ethernet_hdr_len = (14 + 4); - /* Min. octets in an ethernet frame sans FCS */ - static const int min_buf_size = 60; uint32_t n = 0; - uint8_t min_buf[min_buf_size]; + uint8_t min_buf[MIN_BUF_SIZE]; struct iovec min_iov; uint8_t *filter_buf; size_t size, orig_size; From patchwork Wed May 5 21:10:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35399C433B4 for ; Wed, 5 May 2021 21:23:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79349611AC for ; Wed, 5 May 2021 21:23:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79349611AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOz9-00054t-Dc for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOo6-0000aQ-Ef for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOo4-0004Xb-Ic for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:46 -0400 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= 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-248-TvUbM_wvMMCOv_KdhuEMvg-1; Wed, 05 May 2021 17:11:42 -0400 X-MC-Unique: TvUbM_wvMMCOv_KdhuEMvg-1 Received: by mail-wr1-f69.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1191014wre.22 for ; Wed, 05 May 2021 14:11:42 -0700 (PDT) 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=cci+Ja3/SDNl1xOAJND81NzDRZK7kB7EIdWzt/gFZDSKTGf57xeMWhTadNr5vWuyYe dGEagdOnGYnyOCvhX1aflybFuIxzQZmkJJWDgQN3u6otK0dfs1WyYPHy4+U+ZSn8fZKz rjeJc3chL5FZp54BVPleXHH2gVDFiFtSsHdTxm0cZNdM4AHsaYDGuPec57nycELn4P8i X5Lu3HZ6c0HC7zErc66gRKHWV8KgN6blCYIuFH/xAVsyDnRX4LRCG64wefVMP+jqawXG bQXjYFdm4yzlCwDi1IVXuPM3EvnYIBAxCz7VF5jgmVXeSr68x/Ft/NkSWiLOO8YIfkoq 01Qw== X-Gm-Message-State: AOAM5309SXJoq6t+9wJSaGI0vJhpJZu3VloTbpmJfY97Ce5EHBvlhhxy zppcVKWYOqBR3nO7I85+zPrqHna5oUON0/DwUr8c1+JAtISd5HzL8iU7+VTp5+xhUq2NgcYhHcY mXH60Rgc6pvro7pOc67bFjHZZdJHpxRssGMpgbwFVIHnSKewfWOkOGRij4Eeo223b X-Received: by 2002:a5d:408f:: with SMTP id o15mr1002772wrp.89.1620249101364; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goater?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé 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, void *fdt) int smt_threads = CPU_CORE(pc)->nr_threads; CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); - uint32_t servers_prop[smt_threads]; + g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads); int i; uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; @@ -244,7 +244,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt) servers_prop[i] = cpu_to_be32(pc->pir + i); } _FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", - servers_prop, sizeof(servers_prop)))); + servers_prop, sizeof(*servers_prop) * smt_threads))); } static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 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 = 0; - uint32_t servers_prop[smt_threads]; - uint32_t gservers_prop[smt_threads * 2]; + g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads); + g_autofree uint32_t *gservers_prop = g_new(uint32_t, smt_threads * 2); int index = spapr_get_vcpu_id(cpu); if (cpu->compat_pvr) { @@ -195,12 +195,12 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, gservers_prop[i*2 + 1] = 0; } ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s", - servers_prop, sizeof(servers_prop)); + servers_prop, sizeof(*servers_prop) * smt_threads); if (ret < 0) { return ret; } ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s", - gservers_prop, sizeof(gservers_prop)); + gservers_prop, sizeof(*gservers_prop) * smt_threads * 2); return ret; } diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 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 == nvslot->gpdev) { - uint32_t npus[nvslot->linknum]; + g_autofree uint32_t *npus = g_new(uint32_t, nvslot->linknum); for (j = 0; j < nvslot->linknum; ++j) { PCIDevice *npdev = nvslot->links[j].npdev; From patchwork Wed May 5 21:10:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AAF2C433B4 for ; Wed, 5 May 2021 21:17:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44EB9613C0 for ; Wed, 5 May 2021 21:17:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44EB9613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOu5-0007mu-C7 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:17:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoD-0000sR-Dg for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoB-0004dD-TK for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249111; 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=CLxuo9Zh+RoOHybuHRzHJGUUv/gxUuBDACjgE1eRuih92acILi4IMXMr8AZKrw02FhT51v cNo/KhU7ML45pTxinhXgKQx6bRX6U8BhBew/lSIhfyMZhQRekNfEUqnHO+W5evxeCCavbc 8X15owGsUhY9Kgja+y/SFVvZdh2/gxo= 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-407-gI8vHX5FMOqB9nv24uKt9Q-1; Wed, 05 May 2021 17:11:47 -0400 X-MC-Unique: gI8vHX5FMOqB9nv24uKt9Q-1 Received: by mail-wr1-f70.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1191089wre.22 for ; Wed, 05 May 2021 14:11:47 -0700 (PDT) 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=spJNe/NMpgeVpID3E1hRH1cQMR+v/gSm2yK1HQ6uvlEhm4PsUkSvKS8feoiEIORiMB snv42i/VlbGmS7YHqsHq4fyo6WUCQismjsGm2A/lLOBZ6wBTYkazYTHVa3ViABiel2P/ lTbLk/AuvgOj4X4B/goD2dJ1NxSfFK4XJgom+LgbwxAYXEFUQFzm/PQRecoVuZj04vcG rV84yqo9cYHj7fJ5XurhoEIIDyrlnKxkAqEzex7P+5XoYq6GBBXHxmZD8URIIWq4Uyqk AZElxRi82y1h7RbO6WSQjbjE3cw9AeZ0qILoV6mTSmV25tNnwkL2GGM+kpBHmClhDYJG jU9w== X-Gm-Message-State: AOAM530KOOgwFfp1zjFVb26mYDytq3F2HcUq5j+cAUT1JA8wh9toZ+bt MKnW66gryqCl8l3ZQk3WIwRr0nC3JqZ4a9xdIznZ5l9fKHgYVFwME3h7/HDfk/qrsY61BVvWC3W b1pfk2utXjC1WFYpupHa23yLPDQ9BhHeMrDPqGQfG0K08QwJmyh6j1QNfdHeWqbOf X-Received: by 2002:a5d:4ac6:: with SMTP id y6mr1056216wrs.414.1620249106572; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson Reviewed-by: Greg Kurz --- 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 = ICS(dev); + g_autofree uint8_t *flags = g_malloc(ics->nr_irqs); int i; - uint8_t flags[ics->nr_irqs]; for (i = 0; i < ics->nr_irqs; i++) { flags[i] = ics->irqs[i].flags; From patchwork Wed May 5 21:10:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF04DC433B4 for ; Wed, 5 May 2021 21:29:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51F9F61106 for ; Wed, 5 May 2021 21:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51F9F61106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP4w-0005Cw-DL for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:29:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoG-00010G-D3 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoE-0004eS-SH for qemu-devel@nongnu.org; Wed, 05 May 2021 17:11:56 -0400 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= 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-136-P1ADspMgO_Otb07ygnCp8Q-1; Wed, 05 May 2021 17:11:52 -0400 X-MC-Unique: P1ADspMgO_Otb07ygnCp8Q-1 Received: by mail-wm1-f71.google.com with SMTP id r10-20020a05600c2c4ab029014b601975e1so1789141wmg.0 for ; Wed, 05 May 2021 14:11:52 -0700 (PDT) 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=OrslVnJ4NRpsBSWlS1o8jogJxluLf0F5zXjNkskww3YcYqhDnhNiua50CUYqVes81T 3/z4zF8ulzQ5IL4uX7EP1IYhg0zG4MFtDfzzfhzStfne7apqWq2KC0vQSqj7aZFBpJMt 1RDqWVy1AxZhjar9FC+kKMiycQMqoyLQS7UY9AOpF3YGyMMviz8un+Ypv0dayf8lBjnq G6U/aSfK4BdsQZOVs+sYE9y4O8iK+dq2JeQxO2ojk+ABr2BNfHiM3uZYhbjsskvlNH0E DuS/0Gr498/mdMvsxU+6MEsRXKJE/2dmUudDFLeUnwnBFBo3T3vDdajQWpYV6Zt797cl PH5Q== X-Gm-Message-State: AOAM532Rtg+jyIOKb5/61zTqne/g0NjjfHRBvT8Xem97Rc4YwAbMKyEy JFSlD9z+mBe4KnTJHFGvByfB26k9j0Rt4swV9cy5hmefZ4QZ9QS56BwPmuXKp70VjDkAUfYDusg JO7R2m/kgIEXS0Eb2c+58n0kUlxyzO95mUtvrqX52imSHbGBTot2c0RkjsRNx+iEk X-Received: by 2002:a05:6000:50d:: with SMTP id a13mr1064644wrf.130.1620249111356; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Replace the snprintf() call by g_strdup_printf(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- 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 = NULL; + g_autofree char *kcmdline = NULL; /* Ok, let's see if it is a multiboot image. The header is 12x32bit long, so the latest entry may be 8192 - 48. */ @@ -360,9 +361,7 @@ int load_multiboot(FWCfgState *fw_cfg, } /* Commandline support */ - char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2]; - snprintf(kcmdline, sizeof(kcmdline), "%s %s", - kernel_filename, kernel_cmdline); + kcmdline = g_strdup_printf("%s %s", kernel_filename, kernel_cmdline); stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline)); stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_name)); From patchwork Wed May 5 21:10:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94F3AC433B4 for ; Wed, 5 May 2021 21:32:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D012611AC for ; Wed, 5 May 2021 21:32:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D012611AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP8S-00017A-9z for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:32:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoL-0001Dl-U4 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoJ-0004hD-L7 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249119; 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=N/ICO9F64DtQdtnbBGzATH0sIUitsj+SLmx7BQEqnAAhiOSD6rN+3UCeQQXAqLokJRHKqL ghjFQOrA8VpVtNPSTJjKpTe0lb8nLiIfDfZoQOShIwKpzVH4aoO4M16qybzZLezOPQ6XWA QwovLQz7RkKOneSFgPY9H/g/c9UR0vQ= 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-327-MYHAxYNoN22RQi-duA7GqA-1; Wed, 05 May 2021 17:11:57 -0400 X-MC-Unique: MYHAxYNoN22RQi-duA7GqA-1 Received: by mail-wr1-f72.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1191235wre.22 for ; Wed, 05 May 2021 14:11:57 -0700 (PDT) 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=kTJzfVkaaujNMnBdlRbChb6y+5/Pchj/M3TGzK7l/EKF3ZWBI/Cf7RX7Cv4qzCYPtU QBzpN4Yi87u4rAJSUiWMUzzpjZmZbqx0KUiQZXCElx0J8xgy2n6QtvFluFLmSBQZA/tV G4UggsCDfIWR36P1pg1dST2VKD8G0gCsNYWCMYqXvkRs19gE7wrLQYTHgQC1sgfBQhmO 331r1nWssQM52icU1lS44LL4B+QLCsU/lQ7Obr1ki5NUQec2lJuGC0bZWtbarx229pLs Nk3AqPYs3spv8weIVHZFdecnmlm3zZsq1voGipfO2HltaU1fqXFnhmIidV3hv1O4Xsvs pKtQ== X-Gm-Message-State: AOAM532a8v2T5+P4ALhJPoBTI8jzcHFilIum0rxUI6Ai6O91plX89zi6 bZ17ifnShWBO0RpwpPf+gFbaZep20wPbo6iFG5fRAH6g01UbFR+98DgRhqHgSCXsqKNxZAP0UaI Ky0LcZtffXttgby4yw8uQDezWqazFtZS1rwHIvXWSALvew++ulz/eFPd86hJz9IaP X-Received: by 2002:a05:600c:4105:: with SMTP id j5mr11852484wmi.141.1620249116186; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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 = g_malloc(xhci->numports + 1); DPRINTF("xhci_get_port_bandwidth()\n"); From patchwork Wed May 5 21:10:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CC80C433ED for ; Wed, 5 May 2021 21:35:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47A9C613BC for ; Wed, 5 May 2021 21:35:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47A9C613BC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lePAp-0004ux-8C for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:35:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoR-0001RH-AD for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoO-0004kE-Dk for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:07 -0400 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= 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-497-y4ask1dpPNuscPnmAWTD0w-1; Wed, 05 May 2021 17:12:02 -0400 X-MC-Unique: y4ask1dpPNuscPnmAWTD0w-1 Received: by mail-wr1-f72.google.com with SMTP id r12-20020adfc10c0000b029010d83323601so1191301wre.22 for ; Wed, 05 May 2021 14:12:02 -0700 (PDT) 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=WZKEEEk8yF6lrrJN7Vgf1gC8IYyMAULy1VqzPFOzX4M6S6yiheKk7HbyOO44QoH74a EXMhR2e7SZ7HUyMCCWd1SO7V07vDcOXC1IXHWIT1HHOr3WgYMUdIyuIiapHfKanM7sfh 34kVlvl9k6NwGGEeNC7qGWqktuwn3CMq6OFm5+KAiRxUWqKGfqfJVkMAJbAKlfE4vxue MsoAhkrhsSzWDfcvxc/wJP33lIaiqrpJtrDVt8nmN5EfR/iG5ll4iAccH1KRiHgxw/PS NGx1XeZUxb8PGKJwjtE1+/i0XfIwdjfQcjq0oez0KkIpInEGuMwRTIZPLERKR2xA9LWa QmVQ== X-Gm-Message-State: AOAM530AbVx487n/SreafVN7XquGhLd0xiORMYC6N5y/EEweuXr05HWt qoeSAsRFHY2yMhYEjDuosQTmzsj4pgdbZHRhHTjQSW8iyVvdKYv8hOc/oEGsfwT7T85lBpvwiR+ zDRAIOcwQ3ft3gnp3DdWrcoIrWWW47ZotNskMi2JI2Ipgw1gHeLSQJY1lSq1as5Jy X-Received: by 2002:a05:600c:2242:: with SMTP id a2mr619034wmm.125.1620249120976; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The compiler isn't clever enough to figure 'width' is a constant, so help it by using a definitions instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- 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, struct ohci_ed *ed, return 1; } +#define HEX_CHAR_PER_LINE 16 + static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len) { bool print16; bool printall; - const int width = 16; int i; - char tmp[3 * width + 1]; + char tmp[3 * HEX_CHAR_PER_LINE + 1]; char *p = tmp; print16 = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHORT); @@ -911,7 +912,7 @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len) } for (i = 0; ; i++) { - if (i && (!(i % width) || (i == len))) { + if (i && (!(i % HEX_CHAR_PER_LINE) || (i == len))) { if (!printall) { trace_usb_ohci_td_pkt_short(msg, tmp); break; From patchwork Wed May 5 21:10:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 194ACC433B4 for ; Wed, 5 May 2021 21:42:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76002613D6 for ; Wed, 5 May 2021 21:42:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76002613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lePHL-0003r7-EI for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:41:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoe-0001fB-2S for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoY-0004qh-GK for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:19 -0400 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=kucBjQtcgLplpmt/EdeRDcsm9+gP7+suZYQbhaTK3U8=; b=Ja/RQWtIhnMwc84E46MEWsh5nWe5gWmHnib4hQa2LbweH/5PANGitlWQXH/7+B7cQvRxC5 GsZoVGklPRGhYWW1TqaYCjeQ+DFc+wnSOKEOVIQvdClvKNVAsqsetpa8mIkxmw6kCMOYfc 7r3tJ4xVC0GyqhtTdelA6Ie7tgevaoE= 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-61--gPc5F9KO02VlxpAVQlfSQ-1; Wed, 05 May 2021 17:12:07 -0400 X-MC-Unique: -gPc5F9KO02VlxpAVQlfSQ-1 Received: by mail-wm1-f69.google.com with SMTP id n24-20020a7bcbd80000b029014287841063so713630wmi.3 for ; Wed, 05 May 2021 14:12:07 -0700 (PDT) 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=CjAASM8JivvFI9lPT/ALuxw8PN4pO7QQAsNbGui5MlY4esI9VCz46gHiGRbOmtavAt 2OKIGcmHbNpFUejRtydvMK/YPuL/CurIb8cTPbqYxrf0Vg3Dr8kqVOkkUNUvy1Dgykx1 xKKZnyLkzmbmUczlPm1yQQ/CGy/raInxGazlzi2h4Ny4idl3eHuV430gRmnGMA/c09bv Lq4NWp9rvbwWELR4wE7b9VzX0nWJl81JX1AnBUe2uZzqKSmW6TDcAQlzktsS2cIgAFt2 W6sTVih8LT9CSSE/FMT8Qlx5YUswXyJxsOzQTGJymL4dlGMoTD+x7xkmmdxcxJD+9Ke6 77oA== X-Gm-Message-State: AOAM533FIILOVJFYtl7fmfBcbCd5AuTFkpRzE+b4KH2x+Ng184GG4BB/ 3dM6StOPuJ1FZckPmMyLLd5Ql7+wU+jZJGG2FyrXPm7YO6xnY4RwjoU+FOXcz+buKwruJo2wBaE jJMnfzsn4kP4IciyhLnAxhmslkk5iLcyzLmaBpKb78QOWQ4E91M5KsuYIIIg/ylNN X-Received: by 2002:adf:d223:: with SMTP id k3mr1026877wrh.99.1620249126016; Wed, 05 May 2021 14:12:06 -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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiri Pirko , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Jason Wang , Richard Henderson , Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson 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 = bd->bufptr + ((hwaddr)(etsec->regs[TBDBPH].value & 0xF) << 32); - uint8_t padd[etsec->rx_padding]; - uint8_t rem; 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 = MIN(etsec->regs[MRBLR].value - bd->length, etsec->rx_padding); + uint8_t rem = MIN(etsec->regs[MRBLR].value - bd->length, + etsec->rx_padding); if (rem > 0) { - memset(padd, 0x0, sizeof(padd)); + g_autofree uint8_t *padd = g_malloc0(etsec->rx_padding); + etsec->rx_padding -= rem; *size -= rem; bd->length += 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 = g_new(struct iovec, iovcnt + 2); OfDpaFlowContext fc = { .of_dpa = world_private(world), .in_pport = 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 struct iovec *iov, int cnt) int64_t ts; int caplen; size_t size = iov_size(iov, cnt); - struct iovec dumpiov[cnt + 1]; + g_autofree struct iovec *dumpiov = g_new(struct iovec, cnt + 1); /* 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, const struct iovec *iov, { TAPState *s = DO_UPCAST(TAPState, nc, nc); const struct iovec *iovp = iov; - struct iovec iov_copy[iovcnt + 1]; + g_autofree struct iovec *iov_copy = g_new(struct iovec, iovcnt + 1); struct virtio_net_hdr_mrg_rxbuf hdr = { }; if (s->host_vnet_hdr_len && !s->using_vnet_hdr) { From patchwork Wed May 5 21:10:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE6DFC433ED for ; Wed, 5 May 2021 21:38:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E77C613EB for ; Wed, 5 May 2021 21:38:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E77C613EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lePEQ-00017T-6k for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:38:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoZ-0001bP-Ps for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOoY-0004qH-3x for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:15 -0400 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= 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-210-17yLK-k6Nw-jeVwrNmZ-gQ-1; Wed, 05 May 2021 17:12:12 -0400 X-MC-Unique: 17yLK-k6Nw-jeVwrNmZ-gQ-1 Received: by mail-wm1-f71.google.com with SMTP id n24-20020a7bcbd80000b029014287841063so713691wmi.3 for ; Wed, 05 May 2021 14:12:11 -0700 (PDT) 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=b4sGfJWxj6SzekyCrVO6J1I3pMQaFUhTLWZpAjguJlwh2ms/OI5EPKjeayf38hIWu1 76Ii8qIFO18eqzETtjbMKZ49ap6IYENhm6eGzMnF0lQAbeZy/GN50Nxg+ubPldIAbDtO RAYgMZTe3qzJBaJl104fVPqua/MuM7n4x5J9BidTNvJuZRkMjLexo2FEHI7viaZTuDu0 3GgCerbeAcdQmOxklrHmlQSSCev4v22FHw7GbBjaXF6wld+4b12J5Id36p9cTU8+3rms ZcbqUrhedNps84vKQ7v4Zj1MiWDvNJmionIH0kjvYem5nKVYb12kug7X15ODFZ7nAQui SXJA== X-Gm-Message-State: AOAM5303gjK74OaAyuhhy2dyHon6yQBLPy1JOQSjAkEBq8Cs5LzeojFU Wb43ayrAnaYRSl3oPEclNdxc54uKK6xLtNMqsI/3H1P6/tYV+U5ik0oDNyjJ6/Ebkt+UoT6nu2r 52MvxaIqsQzmt5osD4/wPY9JmrkR+fH+ut8gpZqjzeWt2xEjp91Itwa4qPEg3jHim X-Received: by 2002:a7b:c24a:: with SMTP id b10mr11922898wmj.157.1620249130764; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé 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 = g_new(cchar_t, width); wchar_t wch[CCHARW_MAX]; attr_t attrs; short colors; From patchwork Wed May 5 21:10:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D2A4C433B4 for ; Wed, 5 May 2021 21:21:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DEDEA613C0 for ; Wed, 5 May 2021 21:21:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEDEA613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOxI-00034n-TY for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:21:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOof-0001gS-De for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOod-0004tX-MW for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249139; 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=NYwdd3zc0GaXlXSFXAUO5NI1GZxWe29SkA4X4nDehVZsLGDTQ8oHhhrncB+8Jr18V1p7mx xGEgcJUuwgjXMFUmvewogEBo8csyekm/k1C9SPt4X8SVBKcZcghnV4Vqd6+get+zcs5NMb Gn2ypCzONARq1q7JakeO3BAweb84IFg= 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-110-L69LrrspPHSLUgzypnL9Xw-1; Wed, 05 May 2021 17:12:17 -0400 X-MC-Unique: L69LrrspPHSLUgzypnL9Xw-1 Received: by mail-wr1-f70.google.com with SMTP id n10-20020adfb74a0000b029010e1a98fb84so1238700wre.0 for ; Wed, 05 May 2021 14:12:17 -0700 (PDT) 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=n+lLJnNtEqTWWsDERGbybKNtkUuFZXZ1PWD4wm/nL15jRBko0uwd8VuyTQvVABRMhj Zh8uuoJeFIp/8MX8trbxo/o4FLlxETjbaYiZpzOnqBKgoVT3QOXGPGpX6Na0tmWAIJdu SMr7/prQwNSfT3iMwz2+NqyFwRdtnE3UTbL72LRuaqfvadQ/tZXJUjsQaiXv9qZEdi5E DtohgpEwLTeUF/aQKd62pTld2Q951DgQI6DV5zEIiqU4z+EGeEThaIbxJnr37pLoZ/Ln g1IXJHpGOT7ZPyTeRdfJgA0yJlAvopxQSc+Is1iRQYaZtPsotVdUwLYuoPqu6EDmFuaI EyiA== X-Gm-Message-State: AOAM53073BdyWE4LnS4E8Xk1k4UhXvNl7qvQIBMV5tDXjT/vnpG5Scvn LSMDPlCR79ln9zEs154yc7UEIt3uZnH+/V0vR1foOiUaU87lFZ/9ODbxgkmAymwX0dSbWNuD+dq /YM9HzKyXWBpHv4ck83Z7QhFkthgYKO4JV3EHFL5ae+CvZAjN1EfyNb7BJxhc4t+M X-Received: by 2002:adf:ce12:: with SMTP id p18mr1088944wrn.228.1620249136185; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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 = 32; int blocks = DIV_ROUND_UP(surface_width(ssd->ds), blksize); - int dirty_top[blocks]; + g_autofree int *dirty_top = g_new(int, blocks); int y, yoff1, yoff2, x, xoff, blk, bw; int bpp = surface_bytes_per_pixel(ssd->ds); uint8_t *guest, *mirror; From patchwork Wed May 5 21:10:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B0CEC433B4 for ; Wed, 5 May 2021 21:24:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CBC4613EC for ; Wed, 5 May 2021 21:24:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CBC4613EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP0Q-0006Zi-5l for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOor-0001ou-QH for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOok-0004xr-Li for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249146; 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=C8k7+DIToTGurgy+SkLCs95S6H/W0dooZPew5fxJwSfbwHW74DGcbIkHY9xpU4Nzc7yAr6 ui1he0n9i9SzGOQ3trxmAEoZEObxKxhr7cHctvYKl3XdTIzd2SU1+Qovb5ffyU7OoV//SG wZoNZgAUjJUfHpDfJw1MguneswzX5oU= 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-66--fkQ6WMyOQ6dtOqAIcQqcA-1; Wed, 05 May 2021 17:12:22 -0400 X-MC-Unique: -fkQ6WMyOQ6dtOqAIcQqcA-1 Received: by mail-wr1-f71.google.com with SMTP id h104-20020adf90710000b029010de8455a3aso1210311wrh.12 for ; Wed, 05 May 2021 14:12:22 -0700 (PDT) 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=idFHnfxzuZfti8/6W4yiGYeHI54CpUVLyHQS0UDswcxCHgPtxM8lj2TDosVAr8JmKP e/BhTk8CsVomzOIM2fJNVYdoxoXyRct5KrQtQcj5506v0L95hqCZihLcEw6YCf5NgdKu 04EN0yKfCjfPZLTLw/62Pnxq1oBPW2z/ZoQaYeJOQXQCG0BMIwdD085fg44ovrZ3NXio 7m2bn9sUco3teGezb4l4+ArbCpG/w5pAHDrfgDSj9AbB/vlZmxzD4gSZrSp7GAnx5MRS rmJ1SoCUwKCXxEX3JIoJm25mrT0b1+RubJTQgJjFpt/LMCYUoLv6RwG37ojpqHc5CSbu xOMw== X-Gm-Message-State: AOAM532m0Dh3uE10jk0tYqM12sAfZg4A+J+mllX6g4XWeqPpa0GO5RCj xKhXqKCgFzhjSP6d7V/qBUP9iRaV9DzbH8Y8aipEpVVXZKZytibBllbHkHZuPSol+uvn8qSk4+C RH8N0P7iBRRf+6C2RxVvFLMOMl6HLWbCiSMguAVpGsc48saHRWVNiUibjNMMaWk1X X-Received: by 2002:a05:600c:4ecd:: with SMTP id g13mr592615wmq.173.1620249141152; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 = 0; int fg_count = 0; int flags = 0; - uint8_t data[(vs->client_pf.bytes_per_pixel + 2) * 16 * 16]; + g_autofree uint8_t *data = g_malloc((VNC_SERVER_FB_BYTES + 2) * 16 * 16); int n_data = 0; int n_subtiles = 0; + assert(vs->client_pf.bytes_per_pixel <= VNC_SERVER_FB_BYTES); for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { switch (n_colors) { From patchwork Wed May 5 21:10:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 067D8C433B4 for ; Wed, 5 May 2021 21:43:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2475613D6 for ; Wed, 5 May 2021 21:43:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2475613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lePJ8-0006Dh-U5 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:43:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOp1-0001si-1W for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOop-0004zb-1S for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:39 -0400 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= 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-49-bJZB6QdxNjGj-_2FkA6fxA-1; Wed, 05 May 2021 17:12:27 -0400 X-MC-Unique: bJZB6QdxNjGj-_2FkA6fxA-1 Received: by mail-wm1-f69.google.com with SMTP id 7-20020a05600c2307b02901432673350dso704352wmo.9 for ; Wed, 05 May 2021 14:12:27 -0700 (PDT) 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=ILEHwa1NtqoEKME9orYQKbiBuJ+3JelxSNHC0gxgr3doFzmmfp6be+KOB6r6bxeoL9 WRS4Xt/l9NqBQ6QYFo8gxal6Qx6Pp+YrmuzFO2W+V5MEgYb8EcEvhKhWtgiprbgCV16b wbWfrJ4RysYYAdmCQO18uHlnA6Nf5wDC0V9xf7MBLwDqRNYQPVLRSSk3GgsME+0+TwXz 6nMVAVHpaGNFpfYwrYqPB6f3eXHAjHlgmEiJYoJcbjnDpBdCMv4Eo6SKF+LG/ivwil4+ zDpJiPP6aGqXvvrjxntjvOfC1Wt9GS4tCjVP+aZndpwftcmbDNPWwXg6HzhcXg+sXlms f82w== X-Gm-Message-State: AOAM533DQU9zOj4o4JyK4GrSnDUewT/0n6ae65cLu02jLf7ZozPT+vds Y7Vqo2k97Aj8AIUGXTabiyka1Ln6pFGP9q4TWXgBBCrvQGWbgqVhhXDxDvEwV2J0kfCdq8iTpSN mEPK3I3ab7cyic8cmEiW4/NVYqa2EBISiY2U+3g3/v7jWzISdCmm/kPSEtKtcgyjL X-Received: by 2002:adf:fe02:: with SMTP id n2mr1006757wrr.355.1620249145983; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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, int 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 = palette_size(palette); + g_autofree uint32_t *header = g_new(uint32_t, palette_sz); struct palette_cb_priv priv = { vs, (uint8_t *)header }; old_offset = vs->output.offset; palette_iter(palette, write_palette, &priv); - vnc_write(vs, header, sizeof(header)); + vnc_write(vs, header, palette_sz * sizeof(uint32_t)); if (vs->tight->pixel24) { tight_pack24(vs, vs->output.buffer + old_offset, colors, &offset); @@ -1115,11 +1115,12 @@ static int send_palette_rect(VncState *vs, int x, int y, } case 2: { - uint16_t header[palette_size(palette)]; + size_t palette_sz = palette_size(palette); + g_autofree uint16_t *header = g_new(uint16_t, palette_sz); struct palette_cb_priv priv = { vs, (uint8_t *)header }; 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, palette); break; } From patchwork Wed May 5 21:10:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAA3CC433ED for ; Wed, 5 May 2021 21:23:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66909613EB for ; Wed, 5 May 2021 21:23:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66909613EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leOzp-0005Z8-HN for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOp1-0001sj-1K for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOos-000518-NW for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:39 -0400 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= 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-521-AIdE_iyoPCS_kQaevwGNVQ-1; Wed, 05 May 2021 17:12:32 -0400 X-MC-Unique: AIdE_iyoPCS_kQaevwGNVQ-1 Received: by mail-wr1-f70.google.com with SMTP id 65-20020adf82c70000b0290107593a42c3so1219075wrc.5 for ; Wed, 05 May 2021 14:12:31 -0700 (PDT) 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=hOiGHs5EHE1GTPBi7tpOhC6W3OWo3yNrjv05gF7d+7v9N8DNuGIa0Qhd/+kfbOTSIq tze6TSIS+FXYfw3ZCBXMGLDhsceNL0jb9W4XDEnruDmjTQHKbA8Rl+b699A+kj/OdFBW KlhjLDnnIG9kpbpIzCAYAOLy/NvscrlPpIBSnDPF1q9raQubFVt1wGHCe3+ClFo43f7Q YuFMmGzluJ64Kwkxn4jXQtsyYLGENwOrCvK+LFJE25/I5o8Y73OQki940dPF944j0LEs 7i5FyIjogGn4XlzD2GVc/1cVR18RcPZUSGYkVr/nxhcgwsoPFf6zT8HhSYYiCjtupMfP c9bA== X-Gm-Message-State: AOAM533vyiSuHoAtld1XRHSGT3QA8n54F1HhJhI+BahRwfQb7qp0oRba cYT63Dc1wMXC/wmEBUt1goW3oG/8vf1GWqfho8wtCl/Njl8zhLjYWC0skK1Qwc+K6hMvXZai+6C BDskDwccUhr1cdqc4I/OLTOABRrLJdQ/qKCV+oAeU9cc+pgVHlSnh2bheFSWWWrsb X-Received: by 2002:adf:e48f:: with SMTP id i15mr1079380wrm.266.1620249150714; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé --- 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 *buf) { - IOVectorSortElem sortelems[src->niov]; + g_autofree IOVectorSortElem *sortelems = g_new(IOVectorSortElem, src->niov); void *last_end; int i; From patchwork Wed May 5 21:10:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BB1FC433B4 for ; Wed, 5 May 2021 21:27:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 35022613ED for ; Wed, 5 May 2021 21:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35022613ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP32-00025a-5W for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOp4-0001sw-N2 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55034) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOox-00054v-0f for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:46 -0400 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= 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-160-5ih2lRrvP0efE3ybDyGX3g-1; Wed, 05 May 2021 17:12:37 -0400 X-MC-Unique: 5ih2lRrvP0efE3ybDyGX3g-1 Received: by mail-wr1-f69.google.com with SMTP id 93-20020adf93e60000b029010d9bb1923eso1220904wrp.4 for ; Wed, 05 May 2021 14:12:36 -0700 (PDT) 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=JzCLtdOfEvSdkEGs082l4EM49h7LY8DLVZkO9rq55jn1dDRb5teyRMri2JF15OXyXR TnNKMgCpdtag+ZCI9x+alZR1uBEDJMw2u3V8nB3SeDCnrM+zY0gYgJbv8klv6IFGPAo1 XGbWhZrGZrFgIyspv9zhmlIZGti4C0PCFYg/rzR4roMzyAhy2aUC/5tCVgWKri7QMcVl jGKS85vXWL46vXwQkegE+YuvEYcAtrfHJobqnt8glBbHwj4D0zYKPU/pB+cqYKBAnHB4 9+aVpqLKcqK5/CBxIy4C2V/Np+Dmsu50JZcgPDFGsGPGlg9RmyXwtAZ04olKXp9ZXbZn D46g== X-Gm-Message-State: AOAM530J35lacJb4TiSORrWC/aj8rcWCggXGKHKCJIBoPl/d1Xmu5EiA EFiTtaOded2/DZtriDnBP9Tg7YUG7QQMXwv35oFr4PDmFCezeRtdZ0xnysXcBURCFQKVB53XN1f Bu5CfazqWpUr+DFDw6ejllHbobdEOFB4ipbdWeYGz9WHwvsZXzwlo9DZELCEOgH35 X-Received: by 2002:a5d:4351:: with SMTP id u17mr1030241wrr.47.1620249155598; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , "open list:Overall KVM CPUs" , qemu-block@nongnu.org, Richard Henderson , Greg Kurz , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé 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, Error **errp) int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns) { int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - uint8_t buf[bufsize]; + g_autofree uint8_t *buf = g_malloc(bufsize); ssize_t rc; do { From patchwork Wed May 5 21:10:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C0F0C433B4 for ; Wed, 5 May 2021 21:27:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFBFC610E9 for ; Wed, 5 May 2021 21:27:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFBFC610E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP3l-0002pf-16 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOpA-0001v4-EM for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOp2-00056C-Dj for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:52 -0400 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= 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-76-8YA1mvV0MdisCBhqYelQ2Q-1; Wed, 05 May 2021 17:12:41 -0400 X-MC-Unique: 8YA1mvV0MdisCBhqYelQ2Q-1 Received: by mail-wr1-f71.google.com with SMTP id l2-20020adf9f020000b029010d6bb7f1cbso1212683wrf.7 for ; Wed, 05 May 2021 14:12:41 -0700 (PDT) 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=eY1RrWZCVZe5f+RKnibq7O6ws0gfXiOKkzYnl8kUJNc5TBB7oK/UQxM/+lHU7NR71+ uSu1cYrg1ExZ66cGfuyAg9Z4t1JkRQqWRGTOYhwrerr+BaBoctnLZ/7iLN9gvNPf061/ nay9b2RDmXjlp9/uxNU0K1jk94opE3djnZ7pbqY2w+QdqZZh4xvYGACh1Q0ZtoLXMtj9 bvC8hnWkTJ/JCpr+zs0Jh54yVrBJP0PnEM/I5wZSZlWOZMprdXETQ/SEyihfAPH4gWxR yIeU7dnnAEMg7XEh6NuCRWdICIZLqEpFZyLqKyVEI0nzeYUweggbbdfikLjflSCY3ucs J11Q== X-Gm-Message-State: AOAM531rf0h28rpJ0iE7bX6Uoyy9Xz8fbQkNmJ2feO6qtCYwKxxDBuRe tGc/s4hlQ7rIDv4O6D7m1SkjHt7E6pj5Oo+46MgsYl443+wMATxj5Zm86/miSYCieFoZyj0T9FK exMhgt/yBKyub22g2iVD4Ke263Ke3Eetv/IPt7TNEnXsRXH+57zGmDBTV1BPkwEQg X-Received: by 2002:a05:600c:4b88:: with SMTP id e8mr669502wmp.74.1620249160255; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé 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 = open_test_file(false); - uint8_t result[size]; + g_autofree uint8_t *result = g_malloc(size); /* read back as binary */ - g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==, - sizeof(result)); + g_assert_cmpint(qemu_get_buffer(f, result, size), ==, size); g_assert(!qemu_file_get_error(f)); /* Compare that what is on the file is the same that what we expected to be there */ - SUCCESS(memcmp(result, wire, sizeof(result))); + SUCCESS(memcmp(result, wire, size)); /* Must reach EOF */ qemu_get_byte(f); From patchwork Wed May 5 21:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12241071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12A28C433ED for ; Wed, 5 May 2021 21:25:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1399613EB for ; Wed, 5 May 2021 21:25:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1399613EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leP1p-0000uv-PD for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 17:25:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOpE-0001wZ-Di for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leOp6-00058T-97 for qemu-devel@nongnu.org; Wed, 05 May 2021 17:12:56 -0400 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= 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-261-mxZlCHDoMZWxZBLe1GkIHQ-1; Wed, 05 May 2021 17:12:46 -0400 X-MC-Unique: mxZlCHDoMZWxZBLe1GkIHQ-1 Received: by mail-wr1-f72.google.com with SMTP id 4-20020adf91840000b029010d9c088599so1216572wri.10 for ; Wed, 05 May 2021 14:12:46 -0700 (PDT) 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=o7K29iZQpq9/yxJBTRv2GLpf2PSuOkjNoJm1FimcixBe8PgL1DFDpSidIkubwEAwy/ 9M3zdiJflJx3gGiU+UoaFggUyJbYP5Yyispo48GsRL3rQgrnG3sJxHfQYEMLrT8Qet3/ 0HnboRD6ePoRLMe7R7IEieCXNqrqG3e07egRJfadSjnbNeJb1N1WwFtQptAANXsdhREq CN4HGV7j9TtdkA3w5iqLvFs/k13sBSjQt2KGsQzHYvE31TItPbcHfQl4S6Li1hKybkVJ o9OzmmxST/uuXN5qzUgRXPevhJV05iMGsYiwxmF4ch6ryhT5lqE3QfkrlcD9tfLt/Tqj 6VuQ== X-Gm-Message-State: AOAM530fxjw6PifGPqdowxMt1yR8tB7Bm0Etd1AXW5eZ6Trj06+xsDzZ UlIFyIiI+goJfdUIW6Lfd7LqUiAblnyyDtAcX1b7ePA5Yz8w+KzD8VicSzsWBBYa3mFPf2/hmT7 CtMnMzrCiYfH3S71zp4HJ5afeWRKdQchHIUSWxGeYETuMiJAlzQ1+7RRr6N64q/RO X-Received: by 2002:adf:cc85:: with SMTP id p5mr1048090wrj.75.1620249164963; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.693, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Gerd Hoffmann , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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="${ARFLAGS-rv}" # provides these semantics.) QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS" QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" -QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" +QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls -Wvla $QEMU_CFLAGS" QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" # Flags that are needed during configure but later taken care of by Meson