From patchwork Wed May 5 17:00:51 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: 12240613 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 D414BC43461 for ; Wed, 5 May 2021 17:09:06 +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 561816102A for ; Wed, 5 May 2021 17:09:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 561816102A 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]:52914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leL1F-0004ik-BW for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 13:09:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKtl-00066S-Fc for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37230) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKte-0002O1-Sj for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620234065; 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=dXiqUMGNseF8aEoCidrrmNydk4TNmOpI8OAZgIN0M9M=; b=Jfx94TRaZx2tQ3JCTyLTQ76Ipo6yOxEu0Sewfzwu+Qw41d0ZEURG6tn2HwpJ3sSc3b8/JZ Nspz9qN9mYfJTsB+pHHC1/l+xPU2cTQsmKju11jVhS7W3xo26F7GMZfN6y/2X4G9giOGoy ndIZfI91axfoHN8jNYhcOFOEyJIFMoc= 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-21-ezFrNEcSPjK7kd1QlTiEaA-1; Wed, 05 May 2021 13:01:03 -0400 X-MC-Unique: ezFrNEcSPjK7kd1QlTiEaA-1 Received: by mail-wm1-f69.google.com with SMTP id y184-20020a1ce1c10000b0290143299f39d7so1805648wmg.4 for ; Wed, 05 May 2021 10:01:03 -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=dXiqUMGNseF8aEoCidrrmNydk4TNmOpI8OAZgIN0M9M=; b=ViH/2f48A5kqWoVxlGSWWqMoWAheDWVT0z03cFzO0iPk6HgLzTUL9NUVUHDg2RxKdC 5ZMvnQnAvhfkCagI6JLdQDdLO7mEJW1RYyuzod2Dl5zz1tzo7+7seOzgGuERb5pIEhY4 SIuwaNvAFKCp5fvh3bZPACu5SSJqSBM2v7GfZBi1nDHITJogdqpDeWHeHDZujVeJEpMl XMhGgMw69R/Nayvehn8vA2J2O8w48ETbys3mjo1vNtAaKeNu7o8SepmSV0nnmqvDv/eP o3b76oylWDckxfDOx+1+Os6FgToHpu7Gnwd4gYN3qQTiBV/K5VLLhHxL7aqxS401/QPK ih+w== X-Gm-Message-State: AOAM53034jFGjfuWCGOs7dc5G5/3JJAQaoPnbDg91Y1OWYG424GMhzSV AqUbtHLtxUcetNBwnmv0Q4eHcfnPQqGnGczDXIQ6RIDRfM0fO5ILLQ0gbuGbY/Imdta9TUyc8pa mzNWdNnX/4pAkUOo3UvEhb/d47DUN3GRUc7eOaaiI+2YLL/6aBUmQYT/RkJIWbwhh X-Received: by 2002:a7b:c248:: with SMTP id b8mr11424875wmj.150.1620234062147; Wed, 05 May 2021 10:01:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE9b3pj/YxZNlRHG2GkXBUvD3WDR/aewpjObwARt5wff69Kml4yF8lCFHOeEDahXzD3Sem3A== X-Received: by 2002:a7b:c248:: with SMTP id b8mr11424837wmj.150.1620234061759; Wed, 05 May 2021 10:01:01 -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 m7sm6814316wrv.35.2021.05.05.10.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 10:01:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/5] bsd-user/syscall: Replace alloca() by g_new() Date: Wed, 5 May 2021 19:00:51 +0200 Message-Id: <20210505170055.1415360-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505170055.1415360-1-philmd@redhat.com> References: <20210505170055.1415360-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: Kyle Evans , Greg Kurz , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ALLOCA(3) man-page mentions its "use is discouraged". Replace it by a g_new() call. Signed-off-by: Philippe Mathieu-Daudé --- bsd-user/syscall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 4abff796c76..dbee0385ceb 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -355,9 +355,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_FREEBSD_NR_writev: { int count = arg3; - struct iovec *vec; + g_autofree struct iovec *vec = g_new(struct iovec, count); - vec = alloca(count * sizeof(struct iovec)); if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret = get_errno(writev(arg1, vec, count)); From patchwork Wed May 5 17:00:52 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: 12240601 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,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 91CEBC43461 for ; Wed, 5 May 2021 17:05:55 +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 37B2C61042 for ; Wed, 5 May 2021 17:05:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37B2C61042 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]:44314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leKyA-00013R-5g for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 13:05:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKtj-00065F-Kh for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKte-0002OK-S6 for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620234070; 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=KVr/YKk8ykCSG/NDL+d/fpooQDX6C5X50bcflqdu8o0=; b=Js74FL7moJ3MgDx64Foxtsir6C15xGCN67AnLtuRhbMUSwVYmRE0PhOnKbjDZ2YInTS8Cr gPgQcp7fRp9ojLV2QYj41LroZ0v6/QDznGoNtsCSwVtUdoV5vZ56uiYeGew8X68sWwJiZj WvPzKaUr1bOZ/CCXWC9T/oQdKc7px/Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-457-Z_j6NUYIO2yehnZim26aYQ-1; Wed, 05 May 2021 13:01:08 -0400 X-MC-Unique: Z_j6NUYIO2yehnZim26aYQ-1 Received: by mail-wm1-f70.google.com with SMTP id n24-20020a7bcbd80000b029014287841063so526933wmi.3 for ; Wed, 05 May 2021 10:01:08 -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=KVr/YKk8ykCSG/NDL+d/fpooQDX6C5X50bcflqdu8o0=; b=Mwlj797q29Cy/rU3OVWFkVAC97feXUMhvnICEHQAWodO1Du3DiDliz6Uwr4DLDEg3r /VqnRIM9thqESycrdGdxTEa0BILzdVlMxvXE/4D/2yn/DEL0C2hqrUBi3YKg/hJwAMV6 cFQ7B3GUeH4Ot4xjiR4K4Z21fnuCe/melzzTtUP35/GrWknslNrGVl6NzALrDVR6Z/R4 rmTV/J+RxOcBkU6TDMdTidioUMJ3BlWAerW5dmt9rYRiRTDusVdcLuUrMvJGobVFsSh9 KB7ktZrPy2E3DfRSqPUc+50hNx2PRV8VDwc01TI+CzrjKbbz4UDVqGEdXwBXqlEeREOZ Nd9Q== X-Gm-Message-State: AOAM53378FZFVJbYW81f2ncE7Q3JhYoSvFYOHUsI8uVpGTIFaVD0b2mC d6ibyTp6299QjgvQaoAj4zNyM6a6nymZXR2vN9lt46PO0mk0tU8PDgOOvuUj1HmLMHkuWRLZ7kO jxXOrHgSjfK3S4x5OcQsZbUDacu9Sn2doGyHjNT3HmpoFTJaQq2OlA0L+cBAroNzn X-Received: by 2002:a7b:c4c9:: with SMTP id g9mr10881028wmk.90.1620234067014; Wed, 05 May 2021 10:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMNW3ne0tCY2PAFqneUiO3IIV1h5h3tf9MgcewGFxLZtCnjm1YBJggkTc+aanCQig7UykaUg== X-Received: by 2002:a7b:c4c9:: with SMTP id g9mr10880998wmk.90.1620234066819; Wed, 05 May 2021 10:01:06 -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 l12sm20040231wrm.76.2021.05.05.10.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 10:01:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/5] gdbstub: Constify GdbCmdParseEntry Date: Wed, 5 May 2021 19:00:52 +0200 Message-Id: <20210505170055.1415360-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505170055.1415360-1-philmd@redhat.com> References: <20210505170055.1415360-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: Kyle Evans , Greg Kurz , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- gdbstub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 054665e93ea..6f663cbd8dd 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1982,7 +1982,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) exit(0); } -static GdbCmdParseEntry gdb_v_commands_table[] = { +static const GdbCmdParseEntry gdb_v_commands_table[] = { /* Order is important if has same prefix */ { .handler = handle_v_cont_query, @@ -2325,7 +2325,7 @@ static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) } #endif -static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { +static const GdbCmdParseEntry gdb_gen_query_set_common_table[] = { /* Order is important if has same prefix */ { .handler = handle_query_qemu_sstepbits, @@ -2343,7 +2343,7 @@ static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { }, }; -static GdbCmdParseEntry gdb_gen_query_table[] = { +static const GdbCmdParseEntry gdb_gen_query_table[] = { { .handler = handle_query_curr_tid, .cmd = "C", @@ -2421,7 +2421,7 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { #endif }; -static GdbCmdParseEntry gdb_gen_set_table[] = { +static const GdbCmdParseEntry gdb_gen_set_table[] = { /* Order is important if has same prefix */ { .handler = handle_set_qemu_sstep, From patchwork Wed May 5 17:00:53 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: 12240621 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,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 AA102C433B4 for ; Wed, 5 May 2021 17:12:46 +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 1CC5C611AC for ; Wed, 5 May 2021 17:12:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CC5C611AC 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]:34328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leL4k-0000tC-V3 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 13:12:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKts-0006Aj-Oh for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKth-0002QN-BL for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620234075; 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=v6dDjUUr1jX0kd69bV9ZwwKe4Jn9sJZazvtpBwyg5KA=; b=HuHPjlRmvOXoIAX9OjGApArBBrEAjpV5zWBeIxMyZMV0MYi8Kktd/+DxkBPU76FJX1Aprf 2NX2QcFfUoi4pjCctKKRH4qNu7FyTkMT/zqhaUhGNIurIGDjRndIh1TzwteHF+gZFcGzyv wbqOb3ILmSxf9bPMa9kRIc27eD1SgPc= 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-5-pIVsGVS3P7Cvu4XR43clhA-1; Wed, 05 May 2021 13:01:13 -0400 X-MC-Unique: pIVsGVS3P7Cvu4XR43clhA-1 Received: by mail-wr1-f70.google.com with SMTP id l2-20020adf9f020000b029010d6bb7f1cbso948418wrf.7 for ; Wed, 05 May 2021 10:01:13 -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=v6dDjUUr1jX0kd69bV9ZwwKe4Jn9sJZazvtpBwyg5KA=; b=n1xBmvuXtYyQDO9Qhvzb3SxVcDhZ5McKOAXSy38MnML7qS+t/k6MhFktK9Tp0HgmgX c1F/gsZ3iKaPim/La2SrnpnuhUdLoJNiCeL334SlkO4A8mzdk9IrodlBh3Zohk8GhTIg Dm2gA6QBIGdovAwO+mFMWnX75SCfBkow7JG/QM6FpsUbOxxZvlSKPnOB7LjusvkVUyRM raPGttmmlBWjWUodOZ/VruZanNKcTnkneGITj11MXj4pJQnw6v6vUHU8sa+IN1eG546h xwb2UInaOBhfgntZZisMFBN51ELcN5GbXxboWzgraQYXRR2wbPHtY7YIFmDJsX/tA8dU OPjA== X-Gm-Message-State: AOAM530btwd49UTcoCpZO6fppwjYsb8Sx5jGdOPyt0/aLuuJ9AtoLnK/ Yhzom0DpgcKnRWqcJD8OfbNeWIWlvAOJyzttQP0iGi+hwJMlTI4nmfevnmR4sCvNETHklpVhMFE kJfY32KvldK2/FScJHy0op5ct9SlPysTKoTxEk/Fb0FPN+4Li+l7tcSvKIQ8Se/KW X-Received: by 2002:a5d:4cce:: with SMTP id c14mr12205wrt.29.1620234071948; Wed, 05 May 2021 10:01:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUVOp3pO1Wn/Eg12ZEK46NsmpT3zPU6R7yIqJ0Q6XmSE4diSFvuXPe8REXrt2tEMJBnmTrMA== X-Received: by 2002:a5d:4cce:: with SMTP id c14mr12167wrt.29.1620234071681; Wed, 05 May 2021 10:01:11 -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 n5sm16047652wrx.31.2021.05.05.10.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 10:01:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/5] gdbstub: Use fixed-size array in GdbCmdParseEntry instead of pointer Date: Wed, 5 May 2021 19:00:53 +0200 Message-Id: <20210505170055.1415360-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505170055.1415360-1-philmd@redhat.com> References: <20210505170055.1415360-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: Kyle Evans , Greg Kurz , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" GdbCmdParseEntry should have enough room with 20 chars for the command string, and 8 for the schema. Add the GDB_CMD_PARSE_ENTRY_CMD_SIZE and GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE definitions. Do not use pointer to string of unknown length, but array of fixed size. Having constant size will help use to remove the alloca() call in process_string_cmd() in the next commit. Signed-off-by: Philippe Mathieu-Daudé --- gdbstub.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 6f663cbd8dd..0d5569ee539 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1457,11 +1457,13 @@ typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); * '.' -> Skip 1 char unless reached "\0" * Any other value is treated as the delimiter value itself */ +#define GDB_CMD_PARSE_ENTRY_CMD_SIZE 20 +#define GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE 8 typedef struct GdbCmdParseEntry { GdbCmdHandler handler; - const char *cmd; + const char cmd[GDB_CMD_PARSE_ENTRY_CMD_SIZE]; bool cmd_startswith; - const char *schema; + const char schema[GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE]; } GdbCmdParseEntry; static inline int startswith(const char *string, const char *pattern) @@ -1481,14 +1483,14 @@ static int process_string_cmd(void *user_ctx, const char *data, for (i = 0; i < num_cmds; i++) { const GdbCmdParseEntry *cmd = &cmds[i]; - g_assert(cmd->handler && cmd->cmd); + g_assert(cmd->handler && *cmd->cmd); if ((cmd->cmd_startswith && !startswith(data, cmd->cmd)) || (!cmd->cmd_startswith && strcmp(cmd->cmd, data))) { continue; } - if (cmd->schema) { + if (*cmd->schema) { schema_len = strlen(cmd->schema); if (schema_len % 2) { return -2; From patchwork Wed May 5 17:00:54 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: 12240699 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 29272C433B4 for ; Wed, 5 May 2021 17:27: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 7926761004 for ; Wed, 5 May 2021 17:27:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7926761004 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]:34540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leLJJ-0005Kq-90 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 13:27:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKtw-0006F6-Kb for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKtk-0002S6-Oy for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620234080; 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=HTcbf9xflzHTyoKg03h2p2pH+wnGCXbbU65n0yQBFMc=; b=hQfNJcpvtkrwFNuJF0k/xR7N3eRJRDGGSVjHz94rtahbKrPr9JaGj/8f6rTBftz4mzLgUk NBylQw7fCwgpxDAdrhhnAPpIvDzvFzwMEmSzDv2L7pxGudkZ7XXaa1HoqR7FszLnKWaSvr o6LT6unDyFtWWU7I3HZT8QqpCQ024nM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-tpI-Gy0rO7uG3eZBlPZKIA-1; Wed, 05 May 2021 13:01:18 -0400 X-MC-Unique: tpI-Gy0rO7uG3eZBlPZKIA-1 Received: by mail-wm1-f72.google.com with SMTP id l185-20020a1c25c20000b029014b0624775eso1800803wml.6 for ; Wed, 05 May 2021 10:01:18 -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=HTcbf9xflzHTyoKg03h2p2pH+wnGCXbbU65n0yQBFMc=; b=CRJ1rnK1oxxCuC1iIYjON6koShRlhAwYIWRM39SKDpKbIjQUqLG9FJWQQQYFIsG7/H UsW59wBQ3D3aojZpvpo9TyLUg4GReW1YdVNQEMvr8VFEgmBJQFL8Ji+fs5ufRk3oV0PQ vZ5pBncgITas2g1NI+7iFVFaQZBsORi1Rt7B5EQYKgsdkNsgdOfQC5+mOiMtK4iXztiw Guh4T9+5xcD1zRqfyMk1x5O9xGCAJPknieii4oYJ3t1o0Py4JdfbJ7KCGsLgUExTozCc O8w5ZgPQBdnaYXSr2fjaJcBfl/Oeqg1jJyciYgSEyeEVizyYmuV+B2FrnCAwcOyyUj9K 7I2g== X-Gm-Message-State: AOAM5339KuQAco3kVKT/1UVWuqOqtEpzSwtQQqIkAj4IHlhgFb9nX2X/ 6pCV3kXeKoX8S+7Slzb1wJZEf4cTqPPKzxhvewkhXZWQUmsIGiPrxS1mNagELC0E5qF4noLmVS3 5COUeNstYlfblOw1NOGEpGW17atNqNDFdSreZcgB5Xwxd97/7VI7PAZOIZcqIY+8G X-Received: by 2002:a05:6000:1789:: with SMTP id e9mr46358wrg.110.1620234076890; Wed, 05 May 2021 10:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVNOl9XyhslOnr9Z5qwwLZOpH94LvB1BxuuJ5+7dkBrOMXzT4/nk0o52wVuxUxBRv/bIV84Q== X-Received: by 2002:a05:6000:1789:: with SMTP id e9mr46326wrg.110.1620234076675; Wed, 05 May 2021 10:01: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 v18sm24213571wro.18.2021.05.05.10.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 10:01:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/5] gdbstub: Replace alloca() by g_new() Date: Wed, 5 May 2021 19:00:54 +0200 Message-Id: <20210505170055.1415360-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505170055.1415360-1-philmd@redhat.com> References: <20210505170055.1415360-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: Kyle Evans , Greg Kurz , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ALLOCA(3) man-page mentions its "use is discouraged". Replace it by a g_new() call. Signed-off-by: Philippe Mathieu-Daudé --- gdbstub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 0d5569ee539..72b4be89c7b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1475,7 +1475,9 @@ static int process_string_cmd(void *user_ctx, const char *data, const GdbCmdParseEntry *cmds, int num_cmds) { int i, schema_len, max_num_params = 0; - GdbCmdContext gdb_ctx; + g_autofree GdbCmdVariant *params = g_new(GdbCmdVariant, + GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE / 2); + GdbCmdContext gdb_ctx = { .params = params }; if (!cmds) { return -1; @@ -1499,8 +1501,6 @@ static int process_string_cmd(void *user_ctx, const char *data, max_num_params = schema_len / 2; } - gdb_ctx.params = - (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_params); memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_params); if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, From patchwork Wed May 5 17:00:55 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: 12240703 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,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 706E4C433B4 for ; Wed, 5 May 2021 17:32:07 +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 144E8608FE for ; Wed, 5 May 2021 17:32:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 144E8608FE 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]:39764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leLNV-0007fP-W6 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 13:32:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKu7-0006LD-1P for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKtq-0002UG-Sc for qemu-devel@nongnu.org; Wed, 05 May 2021 13:01:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620234085; 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=7g2k8F+O24ILX6i9wlywTWqxuX2ak4LnZOnLn8IJqNY=; b=W6meSEnd6zZOMhXlRgwoAWcmg9di8Nxgmap7/hpEtOXatr6oS5bD2BAfEFsaOkYPrCtzNY e7Gk9zWkNLWuzOx3bNse1p4MuS4Y6uAWT1mfcXEIyS3X7HK3E2VP7e5Lai7bm//EynyoOM 4s2H/XDdb5swaV5FIsUPF9HfZMvHR0o= 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-109-S9xUMpVuNdaXo4GDrgGE9w-1; Wed, 05 May 2021 13:01:23 -0400 X-MC-Unique: S9xUMpVuNdaXo4GDrgGE9w-1 Received: by mail-wr1-f72.google.com with SMTP id 93-20020adf80e60000b0290106fab45006so934453wrl.20 for ; Wed, 05 May 2021 10:01: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=7g2k8F+O24ILX6i9wlywTWqxuX2ak4LnZOnLn8IJqNY=; b=WlWaumhJH+IfP5dQjZ+MjygNksVDJ0S33zCjsdZELTjCAxpeInZwPCl3ABlPOkVaa1 hKSURMi2H77EzUiuHm6z4r7uylw5aNe8bXcKvFgVjz2+KlHpSImkTImUI7EP7TCtLc4Z 2GMkopYGvOywkKy6in3C69krQadjQIFoLowkgylyGkQSYT4aRDXZvw6XVPd3qvtkPNPF dFaIFUJID3DKdlRnoXKD826otDBKrdCUGRpNppRAOmWj9F3r+aIOzsL0T0uC5k5Ryv9b tUuuShMS6qHNj/XcF980Gsb2uPRM/csbfZON/AuLVp7lb+aXZI2vgkGAlzkSuZvo3JCf ERcA== X-Gm-Message-State: AOAM530CMWcfTu3eGMt7Z4eVQyv3/E9gUnbS4TyYkq5NPRQ6Mj7kvwVO EV9wfFhLuCBFBmfKI1zP8gAncKzbx0DPt4byp1TybhO3AcoUxNcwvVYrAFUL8u4yarBve1EekwP NjgDXaQyZdpS9DC63kZHlS/xwhIysrqkh5F/B0KtGp4UpeBUI4JHCQ40CLFtFMxnn X-Received: by 2002:a1c:1d50:: with SMTP id d77mr11295094wmd.114.1620234081848; Wed, 05 May 2021 10:01:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmgH4JwP3i9dHZjwwiWSGdQcazy8feE/fCrd6Xa/tz3JD28tBwB4MYsNyH0CmUS+lyRxh2hg== X-Received: by 2002:a1c:1d50:: with SMTP id d77mr11295057wmd.114.1620234081584; Wed, 05 May 2021 10:01: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 q10sm15824317wre.92.2021.05.05.10.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 10:01:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/5] target/ppc/kvm: Replace alloca() by g_malloc() Date: Wed, 5 May 2021 19:00:55 +0200 Message-Id: <20210505170055.1415360-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505170055.1415360-1-philmd@redhat.com> References: <20210505170055.1415360-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: "open list:Overall KVM CPUs" , Kyle Evans , Greg Kurz , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , "open list:PowerPC TCG CPUs" , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ALLOCA(3) man-page mentions its "use is discouraged". Replace it by a g_malloc() call. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson --- target/ppc/kvm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 104a308abb5..ae62daddf7d 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2698,11 +2698,11 @@ int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns) int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, uint16_t n_valid, uint16_t n_invalid, Error **errp) { - struct kvm_get_htab_header *buf; - size_t chunksize = sizeof(*buf) + n_valid * HASH_PTE_SIZE_64; + size_t chunksize = sizeof(struct kvm_get_htab_header) + + n_valid * HASH_PTE_SIZE_64; ssize_t rc; + g_autofree struct kvm_get_htab_header *buf = g_malloc(chunksize); - buf = alloca(chunksize); buf->index = index; buf->n_valid = n_valid; buf->n_invalid = n_invalid; @@ -2741,10 +2741,10 @@ void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n) i = 0; while (i < n) { struct kvm_get_htab_header *hdr; + char buf[sizeof(*hdr) + HPTES_PER_GROUP * HASH_PTE_SIZE_64]; int m = n < HPTES_PER_GROUP ? n : HPTES_PER_GROUP; - char buf[sizeof(*hdr) + m * HASH_PTE_SIZE_64]; - rc = read(fd, buf, sizeof(buf)); + rc = read(fd, buf, sizeof(*hdr) + m * HASH_PTE_SIZE_64); if (rc < 0) { hw_error("kvmppc_read_hptes: Unable to read HPTEs"); }