From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398606; cv=none; d=zohomail.com; s=zohoarc; b=aZn3LDDOsEdHqREjtzgxxxrwujHGkwMLWm5OniCPn/Dw1hpNulfnVWFQz4OVDZ0dPXVpHeqYG5Ld9g0q7XDYh6zhTDXHgoifiK46lNhqU+Dqq1kDs5IIrmBlXvXlK6fnPpe+cW60XaKnA3Bo8lk0F7+b3sJKWItEwth4yMWwbIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398606; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TX2Xz11Yxqn3cVVJ/gzPo0vFUN0FblHfQJn4P/Y+Hk0=; b=OA3zixivYBm8xzHK9ubCyy1QOR6Lb8MD6KaT+GOFoYEo7+pyhTE1wUBCP7iX1kzo8tUiewAZbovrMmt6ZWtj8bmDT60sOoQmmjC1a+vANHBYxaGZZUVAY4UjZMjf3B2SZN9a1ve+KsVLTdybxPXZk6V4k+eEVHVarnCB46rY0pk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398606743189.64562255450426; Fri, 7 May 2021 07:43:26 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-z4RXykocP76VUH_MTI7wvQ-1; Fri, 07 May 2021 10:43:23 -0400 Received: by mail-wr1-f70.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso3679504wrk.14 for ; Fri, 07 May 2021 07:43:23 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id i14sm23099111wmq.1.2021.05.07.07.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398605; 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=TX2Xz11Yxqn3cVVJ/gzPo0vFUN0FblHfQJn4P/Y+Hk0=; b=VRIbKc9xeT5EBBykfg3piVaJ+oJ5DyKaIqsujgchXmbpiDkBeSdW/iBc8b+uFx1sgZbuD8 2x31q6pT3dnlYns6oqWMr/jdVyfZY4QRZ6zofFv+Zl/obaOF2HJJMDVWJlww+l7+TKo2Wx Ia/XmI7fINKbMWld8Up4Df8HOuikmno= X-MC-Unique: z4RXykocP76VUH_MTI7wvQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TX2Xz11Yxqn3cVVJ/gzPo0vFUN0FblHfQJn4P/Y+Hk0=; b=nBD58f7eWSBfLiOQiFw8CNlPSGVRi6+x2nJYqFCsr85p8Ywd06Z+qcM39vyZkr8y6r qqph1v8Az/IHQ1lMppUswry0mx4/h4t1FhEghAKmzdL3x7G0pU/7oGjwP0DeVttFu0gx uFWssMTeO6ClO6ZbSoL5Rh5wjAVe1yXZQ0N4z6ry93/MvjGkpi5db37EH8haIbTANMbP 0FGBuxgPSO+LHGYVjCmtHUTPTy4AHUh8YE0AeDUtdBGUypYxbdQvCkIIKa/U8FRRaf6t JMc3TBRFtXs7v/hEHaijLV3/yam19lJ6lSfYroyeTqolx0KnQxKu27iypAprXPUZlpwg /aVA== X-Gm-Message-State: AOAM531imhdwAuOmOxYDVKMVdPeCVFUyP2UihTOCK0HvQzAcmcpAyVZR Qlu7Tm2v9vAVovGcWzrqqlvyZPCBj4HFgdX1B5yduCO1WBr0SAWLZnRtNGK+OuF3G32jtbPDd5Q 3mL4/M1F+NYFj2A== X-Received: by 2002:a5d:4810:: with SMTP id l16mr12459995wrq.44.1620398602685; Fri, 07 May 2021 07:43:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbBHiRPbLZTqg/6vC8WRerq8TTv4Coun5JgZZb3kUj3oCXgJlkY4EzdyWqLFhr8EGOc5a3pw== X-Received: by 2002:a5d:4810:: with SMTP id l16mr12459975wrq.44.1620398602565; Fri, 07 May 2021 07:43:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh , Kyle Evans Subject: [PATCH v3 01/17] bsd-user/syscall: Replace alloca() by g_try_new() Date: Fri, 7 May 2021 16:42:59 +0200 Message-Id: <20210507144315.1994337-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- bsd-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 4abff796c76..6db05988f1b 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -355,9 +355,12 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, ab= i_long arg1, case TARGET_FREEBSD_NR_writev: { int count =3D arg3; - struct iovec *vec; + g_autofree struct iovec *vec =3D g_try_new(struct iovec, count= ); =20 - vec =3D alloca(count * sizeof(struct iovec)); + if (!vec) { + ret =3D -TARGET_ENOMEM; + goto fail; + } if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret =3D get_errno(writev(arg1, vec, count)); --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398612; cv=none; d=zohomail.com; s=zohoarc; b=MogCsqEG6y838tmzg7XvYXIwCA/5rPOIerVpYPmb1gMtjySAJvh5dg9wfxLXPQEsXCK3PlxS0w++eVPS0lXQ7M8QbrNLL4xMzTarMVPkfKZMSekwl6vzW3Ahan9nrTMgOB+B9FrRRUAAeQkqVuXcSRPyQTAWPbm5CmeYcSOBnzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=cWe+dxIQxlwOjXTVq4nmSO21Ag5LIQeGVfXOgPjRmt8=; b=G0bPUYnKUGoA6e9Grh52iHzwR8HE4FmfhXZAAe/iT2KwZib0Si0AK1R8JEdl8LbALs0exfvYmfHlzERG3RRXcypIkIpWPQmKcj2Ml5+tQjg8kmzChkCSM8P8cUdza9aapdkGPd/kGIdX5QamcgCWsl81C2X3qvnKNRQZBoZmkRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398612705319.48404337255795; Fri, 7 May 2021 07:43:32 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-vMgJDzk8OSGjoR-ylxsuJg-1; Fri, 07 May 2021 10:43:29 -0400 Received: by mail-wm1-f69.google.com with SMTP id u126-20020a1c60840000b029013f6df1cd5bso1487971wmb.0 for ; Fri, 07 May 2021 07:43:28 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id o15sm8521863wru.42.2021.05.07.07.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398611; 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=cWe+dxIQxlwOjXTVq4nmSO21Ag5LIQeGVfXOgPjRmt8=; b=ZaB6gKevzPVzKBe3fJgPItBVYmUHv/bwN0gfdmm0dfg3tRtRd/R1l1o9zO3oT88Uy2AMvE ZwUNW4L9mhpu6QkIWk0o7qcUf63+fo3ZjHtuOGU4r3FFOZKzmjrI9XvOA8iN/fYZToI9EO /Pl48VEDcNb0G5bhepCWg7Scn6UTGBc= X-MC-Unique: vMgJDzk8OSGjoR-ylxsuJg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cWe+dxIQxlwOjXTVq4nmSO21Ag5LIQeGVfXOgPjRmt8=; b=g+z9eBhemjFUTULXFXSxS2ibCEyMuyjw9mM0VaD2Fs2bRwd6Zi3TVR2BkN7Qq5XxR/ y4aXahLS5qS4/4aFbmpQkpjQHVJXiywE3XnlLDOyLBdPjG5eL66oCxS12P4o+aBX1mCO 3mspnKsfbf5xFKDQ7IvXOyrD3jgLoRkaN+ZHgF1Fg7NSFSTmjddmVjiAOmLmb5piqud2 F/O9NVL/Wv/fkKfNd4GVZW8VRKG9yR5taJzVLK4V2e0XgX/ehYcEc2z3EQFngVTZiCPM u+112dAzZhOcJkM6LbZ/c5D178m5nQlvIwz27OJSBO/WTDqHx18KxbcwVJtq2UUY3lP5 GFFA== X-Gm-Message-State: AOAM530Vdlwh3VAo0HxGy2DM5ejmTrGs7XznP9qQ8aksugmVa/eSw4d0 3qieM3SDDRZ1QNppBFY00wnulixeuD/YmibfVk5MTy3wwi4zG+itZDYKX8bn5IPvfQUScR/v6bF 9aNbVtgAPDYatBg== X-Received: by 2002:a05:600c:293:: with SMTP id 19mr10481684wmk.144.1620398607269; Fri, 07 May 2021 07:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzJXjh5EIUZ5UvBdcTDtVAODkhggy3oiheKgCV4ZKOSMg1GrJfTFeIVPOdUMHt/oXW6+6GrQ== X-Received: by 2002:a05:600c:293:: with SMTP id 19mr10481664wmk.144.1620398607116; Fri, 07 May 2021 07:43:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 02/17] linux-user/elfload: Replace alloca() by g_try_malloc() Date: Fri, 7 May 2021 16:43:00 +0200 Message-Id: <20210507144315.1994337-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/elfload.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c6731013fde..dad2dac24a4 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2591,6 +2591,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, { struct elfhdr *ehdr =3D (struct elfhdr *)bprm_buf; struct elf_phdr *phdr; + g_autofree void *phdr_alloc =3D NULL; abi_ulong load_addr, load_bias, loaddr, hiaddr, error; int i, retval, prot_exec; Error *err =3D NULL; @@ -2610,7 +2611,12 @@ static void load_elf_image(const char *image_name, i= nt image_fd, if (ehdr->e_phoff + i <=3D BPRM_BUF_SIZE) { phdr =3D (struct elf_phdr *)(bprm_buf + ehdr->e_phoff); } else { - phdr =3D (struct elf_phdr *) alloca(i); + phdr_alloc =3D g_try_malloc(i); + if (!phdr_alloc) { + error_setg(&err, "Not enough memory to load ELF program header= "); + goto exit_errmsg; + } + phdr =3D (struct elf_phdr *) phdr_alloc; retval =3D pread(image_fd, phdr, i, ehdr->e_phoff); if (retval !=3D i) { goto exit_read; @@ -2979,15 +2985,15 @@ static void load_symbols(struct elfhdr *hdr, int fd= , abi_ulong load_bias) { int i, shnum, nsyms, sym_idx =3D 0, str_idx =3D 0; uint64_t segsz; - struct elf_shdr *shdr; + g_autofree struct elf_shdr *shdr; char *strings =3D NULL; struct syminfo *s =3D NULL; struct elf_sym *new_syms, *syms =3D NULL; =20 shnum =3D hdr->e_shnum; i =3D shnum * sizeof(struct elf_shdr); - shdr =3D (struct elf_shdr *)alloca(i); - if (pread(fd, shdr, i, hdr->e_shoff) !=3D i) { + shdr =3D (struct elf_shdr *)g_try_malloc(i); + if (shdr =3D=3D NULL || pread(fd, shdr, i, hdr->e_shoff) !=3D i) { return; } =20 --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398618; cv=none; d=zohomail.com; s=zohoarc; b=XOXV3Sq8bTQv6DyyThy8zmT5DBqTVOh1skoWXKA3ZvEJWp5Op2f3729VpPbd4CxqpwtJzFe4i2geRuG/GRHoG3sAU8U4fCu3f2TurPFKjDSqnv4x3FQALXb3L0AxSKhp2AJsXF6QIJOvlDPbxP7WwA5gOTNPoldipZoWOLb3saE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398618; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=q+bUpux/oO0InwS7O+3v+yDI8KzcveNX4OlpMmGvtIA=; b=NmeKgtZaEm1BGe7QJNagvUR0+evfSqx0LSj39EbDJ3NptqEDzhwPwBLNekhUblpAUD1R8HQUrwrtQFMjtTwmt2Amj5IufZmE9PQ5rT7ZQVnOf6JP01BJIrtXdGSJCAVOZI2XwoEX1Ln/Sjw/XHDCqzeWfqHH5GA40m8hxte/XIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 162039861817153.45336473181908; Fri, 7 May 2021 07:43:38 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-WL28WeeLNB21ry_VBg6jbQ-1; Fri, 07 May 2021 10:43:33 -0400 Received: by mail-wr1-f71.google.com with SMTP id s7-20020adfc5470000b0290106eef17cbdso3676965wrf.11 for ; Fri, 07 May 2021 07:43:33 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id f7sm10176565wrg.34.2021.05.07.07.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398617; 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=q+bUpux/oO0InwS7O+3v+yDI8KzcveNX4OlpMmGvtIA=; b=RqX2sDCfg/Ljhm8GoECKUtCPfVD7QowQQvshscBbcNqkS8tur9nyvA9DQdgrraVGpg/SnK mIsmB2olNwGeypF4Yxb89AW/2hBs+4Wn/eV9ru0PoXs30q6HWVTIx17i/7r15XapUY0Mjo qr7AlCerfwL/lBr75CScD36rU9yVGRc= X-MC-Unique: WL28WeeLNB21ry_VBg6jbQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q+bUpux/oO0InwS7O+3v+yDI8KzcveNX4OlpMmGvtIA=; b=hOG7t2dVXnawJmrxdOw7ReJumxI6zbIuvZZ+fUs0/Ry38Dw46uJu7h67i80glxL720 r18Wo1mWrnZ75Zhjusodyd3C9G43xaHxag3r9knngAjRazf7IX5AmVCGH+N5HxDB4Wda aPtjbfi1L2nlyY3Vb94yfTrj7iUeIrnz/DV1j1KykARgugBy6/zrNDR7HCT+4WURM4eW elwy8f5+aczRzHszItx/D69uJ0IHSmVAL80+7CAU2oZNC6xrPmKIf9L22Zmw52QOCetk 3Il3C5rMb3MsyKv84X0MgzTaPRJ3QrYXmmSH5x5yj/j6wC3ffKyKwPhfT+SVBcwaBTf/ RbVA== X-Gm-Message-State: AOAM531WfaCS+83No9FHau3Gr4rahLzoFQ5000jGwiKOqeKNXJf2IYQ0 3gLts2zPAODXSdsLy4kJCoM3V8MzSpstF1zUHkQhZFl/Y5usXY+jeOhJrJ5LeFJxUppx1ssbSg1 kxQyVBOllwYED4g== X-Received: by 2002:a05:600c:89a:: with SMTP id l26mr21147113wmp.18.1620398612168; Fri, 07 May 2021 07:43:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTDpcS06ZVNaty9w4yRm1eFVAUeaEhTHfn0l9iOi64at9nD5MlVi8qUE4UwL2wbZeJV4QBHA== X-Received: by 2002:a05:600c:89a:: with SMTP id l26mr21147100wmp.18.1620398611969; Fri, 07 May 2021 07:43:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 03/17] linux-user/syscall: Replace alloca() by g_try_new() Date: Fri, 7 May 2021 16:43:01 +0200 Message-Id: <20210507144315.1994337-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 95d79ddc437..08ab4cee805 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11417,10 +11417,12 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, { int gidsetsize =3D arg1; target_id *target_grouplist; - gid_t *grouplist; + g_autofree gid_t *grouplist =3D g_try_new(gid_t, gidsetsize); int i; =20 - grouplist =3D alloca(gidsetsize * sizeof(gid_t)); + if (!grouplist) { + return -TARGET_ENOMEM; + } ret =3D get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize =3D=3D 0) return ret; @@ -11438,10 +11440,13 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, { int gidsetsize =3D arg1; target_id *target_grouplist; - gid_t *grouplist =3D NULL; + g_autofree gid_t *grouplist =3D NULL; int i; if (gidsetsize) { - grouplist =3D alloca(gidsetsize * sizeof(gid_t)); + grouplist =3D g_try_new(gid_t, gidsetsize); + if (!grouplist) { + return -TARGET_ENOMEM; + } target_grouplist =3D lock_user(VERIFY_READ, arg2, gidsetsi= ze * sizeof(target_id), 1); if (!target_grouplist) { return -TARGET_EFAULT; @@ -11736,10 +11741,12 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, { int gidsetsize =3D arg1; uint32_t *target_grouplist; - gid_t *grouplist; + g_autofree gid_t *grouplist =3D g_try_new(gid_t, gidsetsize); int i; =20 - grouplist =3D alloca(gidsetsize * sizeof(gid_t)); + if (!grouplist) { + return -TARGET_ENOMEM; + } ret =3D get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize =3D=3D 0) return ret; @@ -11760,10 +11767,12 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, { int gidsetsize =3D arg1; uint32_t *target_grouplist; - gid_t *grouplist; + g_autofree gid_t *grouplist =3D g_try_new(gid_t, gidsetsize); int i; =20 - grouplist =3D alloca(gidsetsize * sizeof(gid_t)); + if (!grouplist) { + return -TARGET_ENOMEM; + } target_grouplist =3D lock_user(VERIFY_READ, arg2, gidsetsize *= 4, 1); if (!target_grouplist) { return -TARGET_EFAULT; --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398620; cv=none; d=zohomail.com; s=zohoarc; b=Pnb8v4fw56gI2eCGktFTqHZtvJGWhf7n3M+cpKAoF8S30WHxKbPJfE7YTlzgKPqaL+ADPn+BhAeYYrlXxLhh/Uz5u6Gyrg8EmWwWR2nU5TDxBViLp3NyW9y5s6UhGqlIN/mbR4WDKKKRqKecmbBfDkjd8hM5jscoIGFgrAxlX68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398620; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Vgjfb8PbNnIcn3GQZwYI0ZjOYyIxocLAAFSxTQwWgvo=; b=bEOo86n7iYVr4NWtY2R7eVyYUefVCFZavr6OjAvJN0vmizr2BYa4+QBuY4tw268eSkcplesV8R75mHUyviQVEyrndzmfdj6cv+Dz3W5kndHkRPrmO6eW6mMeUSVoWZ9rzPMEH4JQO0QRSQ6gJ5PDtBvf/AyWNN+kVgcqbG0al4s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620398620583956.40743137042; Fri, 7 May 2021 07:43:40 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-332-HBSApOVENJmgHLjgitLkwQ-1; Fri, 07 May 2021 10:43:38 -0400 Received: by mail-wr1-f71.google.com with SMTP id j33-20020adf91240000b029010e4009d2ffso1234841wrj.0 for ; Fri, 07 May 2021 07:43:37 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id z7sm8704053wrl.11.2021.05.07.07.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398619; 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=Vgjfb8PbNnIcn3GQZwYI0ZjOYyIxocLAAFSxTQwWgvo=; b=S3JiuQIspYj4SnOncLaO6snj3w8sWw0rorrWs8bxm+oApEGx5mhkuIKxu3/H6nvbIOl6wL /x2M5SU37TG0hb0R1sB5sEeO9FUWbeyHdL78gnwRawmcaCWzdHgGTq/Dwf2eusfZZpJdtv klLJmlrSfGgh/0d+2xTf8MM9DUn7M2U= X-MC-Unique: HBSApOVENJmgHLjgitLkwQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vgjfb8PbNnIcn3GQZwYI0ZjOYyIxocLAAFSxTQwWgvo=; b=UcrQ2MyNC4EL2b/H8BTvl8of0BxUNuuzZtGa6nzYLIKIuRxNS8EilEl6wwQNVcT7ZJ TD8VPtBlWLuNXfYG1kv3k+KYYbNJmGGW/AjQY5K2bGmugNKV9A0ZS9nqVWWPb0tS/z1/ DDOMMTirtTG+rIS/Y+6PXsURyB7pmCtuG7AZ9wrLAwqypvISZshKUbnWSBeItchsgAmU EuEK1rg82LyWszKQtYGT12NSfZ8+rDQ8h0lMZ1HENuZKSxx8xziKAsiHaYqBTSPt+dxO SakIPSi+nM92vfiyUuDs/X6e0T7b5nRMUumNSx9E1s9Pzm6glPe0Ka0awRmEF0S8IYtq vKIA== X-Gm-Message-State: AOAM532lgQfB5u1hUcLk/+slJXlPqRxeXGBTqbsV34Atc7QkLJUFSG/N 7zIc86JqTLUoOBeUJHBs++KF+KSfOvOzSn5p7Cs7sVSAj6L4fsMhGByJQpBURSXxNKrxckZJagu qnzoq2qCKVWaq1Q== X-Received: by 2002:a05:6000:188b:: with SMTP id a11mr12357178wri.275.1620398616905; Fri, 07 May 2021 07:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8z6+nLnCBt+Vj4iXQ1ZSB8G5e+MxGMDopF4RIQpyJSA59dPldQXb0CcFy166g96XArEjxog== X-Received: by 2002:a05:6000:188b:: with SMTP id a11mr12357169wri.275.1620398616770; Fri, 07 May 2021 07:43:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 04/17] linux-user/syscall: Replace alloca() by g_try_malloc() Date: Fri, 7 May 2021 16:43:02 +0200 Message-Id: <20210507144315.1994337-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 08ab4cee805..2fa6b89b3de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10630,7 +10630,7 @@ static abi_long do_syscall1(void *cpu_env, int num,= abi_long arg1, case TARGET_NR_sched_getaffinity: { unsigned int mask_size; - unsigned long *mask; + g_autofree unsigned long *mask =3D NULL; =20 /* * sched_getaffinity needs multiples of ulong, so need to take @@ -10641,8 +10641,10 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } mask_size =3D (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) -= 1); =20 - mask =3D alloca(mask_size); - memset(mask, 0, mask_size); + mask =3D g_try_malloc0(mask_size); + if (!mask) { + return -TARGET_ENOMEM; + } ret =3D get_errno(sys_sched_getaffinity(arg1, mask_size, mask)= ); =20 if (!is_error(ret)) { @@ -10670,7 +10672,7 @@ static abi_long do_syscall1(void *cpu_env, int num,= abi_long arg1, case TARGET_NR_sched_setaffinity: { unsigned int mask_size; - unsigned long *mask; + g_autofree unsigned long *mask =3D NULL; =20 /* * sched_setaffinity needs multiples of ulong, so need to take @@ -10680,7 +10682,10 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return -TARGET_EINVAL; } mask_size =3D (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) -= 1); - mask =3D alloca(mask_size); + mask =3D g_try_malloc(mask_size); + if (!mask) { + return -TARGET_ENOMEM; + } =20 ret =3D target_to_host_cpu_mask(mask, mask_size, arg3, arg2); if (ret) { --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398625; cv=none; d=zohomail.com; s=zohoarc; b=Ji0pnIy9jOFCaBvUv0orJ2t6bK7Ncf7RNxbarPguy5n6pO7D+xfO5Jf4b1WrOLc6g8BKpduYH17wzuFq48imLnmYeLg5QItQBRsUUkcoxNQfrX0gDBtXjOeRZJUMBg/tEO8U34YlS6sph8LAw1Epq4xx3mQS8FvKfMzsKtflEWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=0Q+1JmkmHePwynNhULjY5tlZHv+f3d17hAW4SIJc660=; b=ipDzN1oPWjkrFitJR70CROAVnK+Eq6YME5g9O/4wbdfFQLuZCnqIbaiIMWbC3/OUh16gbQ8COSrgyo5b+i4ZmPGsQXNkBU6Bc8WVRfwqlAvedirC34I7d+StGLpdr85Re3b1uqX6MonZav4yqhZBkLRzxiOLnEMY+REYLZzomAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398625623598.2279247277936; Fri, 7 May 2021 07:43:45 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-YQ1MgfrAMYqYgXBIYZ8aJw-1; Fri, 07 May 2021 10:43:42 -0400 Received: by mail-wr1-f72.google.com with SMTP id j33-20020adf91240000b029010e4009d2ffso1234940wrj.0 for ; Fri, 07 May 2021 07:43:42 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id i2sm10411140wro.0.2021.05.07.07.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398624; 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=0Q+1JmkmHePwynNhULjY5tlZHv+f3d17hAW4SIJc660=; b=T4RiVvDIsugnH8QYf7EtaNA6TDsGSgyjnEhDhhIe6sXlCOL/k+zkJwt+Rxhq20rM8PR3ko gJyP35CVkwehN5RfafacaQhNg6tR8RPMlXMN+Q4rQIS6C+FAI084drmPNP64PgSnqMJOF4 EGUA2uQh+U7oPfTuKYux0OTT+uWZGUM= X-MC-Unique: YQ1MgfrAMYqYgXBIYZ8aJw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Q+1JmkmHePwynNhULjY5tlZHv+f3d17hAW4SIJc660=; b=m8vM8U35yooaY0W62g/PwsO+HsCst6CfUKut9LUM8rEsyIyTWepM7aH/5891N9mU4s Ork/4ZC6lxcdhKKVZl3PKemplNjrSeBs9TSXuJ2xWWASECP58K+9xhiipigOJKqwEUYs dbtyqlb32HTixES9rSxoooKkHIdxRkWHuDpki0EfDG18IcjEFE3NpohwGm36q5i5wtfp a7KLNsSOdx3Zl8Kdn8HovrltwtmEnQ4hXqL4UCsDHzXF8ndut2GgcSwnM00pSC8YYx+U 7UDmmOE3gWED17W1xEeHHfwH2lJd29hqZAmeSQL2R2BAqDFxtI3y3iFd0A2ET46LiRKe rK6A== X-Gm-Message-State: AOAM533cE7WKE/k1fvfg1alk6MN3Fjx7ZofZ42gn7xuOb3oAtGxb8ai+ WG86YAnlH/taL1Nvf9pIZ7NEalFO+edAChyTdqnhLgeGHKV1mJBbwHOWNLfSQdW5Qn0BUpv6IGf NlFhIs3VrH+knIQ== X-Received: by 2002:a5d:64e4:: with SMTP id g4mr12745246wri.366.1620398621515; Fri, 07 May 2021 07:43:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq+8a9eTWd9LLo0lKbFnav+n6uJJCUttMkNpC1ladPYpd+vHRsfQgfmgc2chAdH48leiYagg== X-Received: by 2002:a5d:64e4:: with SMTP id g4mr12745233wri.366.1620398621414; Fri, 07 May 2021 07:43:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 05/17] linux-user: Replace alloca() by g_try_new() in ppoll() syscall Date: Fri, 7 May 2021 16:43:03 +0200 Message-Id: <20210507144315.1994337-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2fa6b89b3de..0bf4273fc7a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1605,11 +1605,10 @@ static abi_long do_ppoll(abi_long arg1, abi_long ar= g2, abi_long arg3, { struct target_pollfd *target_pfd; unsigned int nfds =3D arg2; - struct pollfd *pfd; + g_autofree struct pollfd *pfd =3D NULL; unsigned int i; abi_long ret; =20 - pfd =3D NULL; target_pfd =3D NULL; if (nfds) { if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { @@ -1621,7 +1620,10 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg= 2, abi_long arg3, return -TARGET_EFAULT; } =20 - pfd =3D alloca(sizeof(struct pollfd) * nfds); + pfd =3D g_try_new(struct pollfd, nfds); + if (!pfd) { + return -TARGET_ENOMEM; + } for (i =3D 0; i < nfds; i++) { pfd[i].fd =3D tswap32(target_pfd[i].fd); pfd[i].events =3D tswap16(target_pfd[i].events); --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398630; cv=none; d=zohomail.com; s=zohoarc; b=DAe7Pib0/oSHBVL9/lakX5JrgVhCCLKhJ0mrjSplpMzhSQtMXd8MR/YQ6KWglyNwZDqzsCCuPyqmhnM5Ujrw4XiWHhepnzIWkd1UEU7eZRnhH37L3uf0u++jDDl1xO0BYG/EbZMo2tcJejs0UVI/JItkwMtUgd90l8yf1Stnp/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398630; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2L5mr2b7hhw5EkGSTWl47QqXXqBmVyFmMYU/e54ubTE=; b=UnC/yqdsUcc5yoATjuNEtF6hFsPqrFVs3FvCe3mcZ07J9jPg6j7ovaOq1FCfLstt4KLuJCJYXZueFGk1QN7g1jxJJa3sZXtLw5APwoNoh1bdsoSnAUktJrk+5vt2lEYxkBKFn+Mr0FW8NeXAe+WPD0xRzSrYjI+nRaQgI668Fxw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620398630359591.9777975742894; Fri, 7 May 2021 07:43:50 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-_xnPC-QoN6ys2nerwPXlig-1; Fri, 07 May 2021 10:43:47 -0400 Received: by mail-wr1-f71.google.com with SMTP id j33-20020adf91240000b029010e4009d2ffso1235041wrj.0 for ; Fri, 07 May 2021 07:43:47 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id f4sm9261707wrz.33.2021.05.07.07.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398629; 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=2L5mr2b7hhw5EkGSTWl47QqXXqBmVyFmMYU/e54ubTE=; b=SorAX5dc2LcT4RbwUVVxlDFS3JFsyE7ZGfeLCAt6dgaG16f21fb8ociBNSiMy1ws2ImotF uFiXdzPZXVwcEVkVOzF7GeuJWsqxuqTh9Usx7hcBLZSPu65iXNmunNSoAoH1KyTCEy0S6v 3sCpu08MnZkh8cwH4ZCZkBGgstgSZ8U= X-MC-Unique: _xnPC-QoN6ys2nerwPXlig-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2L5mr2b7hhw5EkGSTWl47QqXXqBmVyFmMYU/e54ubTE=; b=El1vBOZ5EsOkehaLSt6FZs1I5Izwi21LH6uxmUOXtnNEZ7FlhZG7UFL/kL3MMuTLlu Jl9frGHETpuNogujffVXgwERw10GhJxDWGk3HxE51QH9B8Qo4tI2PYqif4awMDAa2aYj HuyNNCRQxxcUPeFkaYki48JaOEMhsWVcs9gLLRLxGI3g6NFPz89lXSu8XDd8E7X8nuzB 6L3jg2ba/s1eZOssDBelw6LsiOzPpurcVHR3qCC6hWVWzQoSGDHNuI4zpHs7NFZsUkAJ YBPRtUy4+9YLu3XUTQsZGKCoYRhC6OUCiLy8NeWyDLRJKQ5vRGhYMxQBBzR2bxRjH8Ni vN2g== X-Gm-Message-State: AOAM531/EmII9qJ+C7Bh+6TTCWp4YtiiB/l3fGXs2d8Vplpx4lngCYWZ 3brK5R/YIv/fmgRlRnqS9SpjvAgYN3JkfE68ptV7hDpHmKYdMkeMc4ED6dZYWUO+oNSDKAm93pl 7+ulAy2kLytQc4Q== X-Received: by 2002:a5d:6682:: with SMTP id l2mr12867711wru.15.1620398626337; Fri, 07 May 2021 07:43:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9DMJA8+x/NYI0yJJsbEcLCTwgBtgsQmZh7JNyu0BIiNXSApGIllKxUmvSifBrFhmtnMgQDw== X-Received: by 2002:a5d:6682:: with SMTP id l2mr12867692wru.15.1620398626166; Fri, 07 May 2021 07:43:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 06/17] linux-user: Replace alloca() by g_try_malloc() in setsockopt() syscall Date: Fri, 7 May 2021 16:43:04 +0200 Message-Id: <20210507144315.1994337-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0bf4273fc7a..a263aea85ff 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2191,7 +2191,6 @@ static abi_long do_setsockopt(int sockfd, int level, = int optname, { abi_long ret; int val; - struct ip_mreqn *ip_mreq; struct ip_mreq_source *ip_mreq_source; =20 switch(level) { @@ -2235,15 +2234,21 @@ static abi_long do_setsockopt(int sockfd, int level= , int optname, break; case IP_ADD_MEMBERSHIP: case IP_DROP_MEMBERSHIP: + { + g_autofree struct ip_mreqn *ip_mreq =3D NULL; + if (optlen < sizeof (struct target_ip_mreq) || optlen > sizeof (struct target_ip_mreqn)) return -TARGET_EINVAL; =20 - ip_mreq =3D (struct ip_mreqn *) alloca(optlen); + ip_mreq =3D g_try_malloc(optlen); + if (!ip_mreq) { + return -TARGET_ENOMEM; + } target_to_host_ip_mreq(ip_mreq, optval_addr, optlen); ret =3D get_errno(setsockopt(sockfd, level, optname, ip_mreq, = optlen)); break; - + } case IP_BLOCK_SOURCE: case IP_UNBLOCK_SOURCE: case IP_ADD_SOURCE_MEMBERSHIP: @@ -2492,7 +2497,8 @@ set_timeout: } case TARGET_SO_BINDTODEVICE: { - char *dev_ifname, *addr_ifname; + char *dev_ifname; + g_autofree char *addr_ifname =3D NULL; =20 if (optlen > IFNAMSIZ - 1) { optlen =3D IFNAMSIZ - 1; @@ -2502,7 +2508,10 @@ set_timeout: return -TARGET_EFAULT; } optname =3D SO_BINDTODEVICE; - addr_ifname =3D alloca(IFNAMSIZ); + addr_ifname =3D g_try_malloc(IFNAMSIZ); + if (!addr_ifname) { + return -TARGET_ENOMEM; + } memcpy(addr_ifname, dev_ifname, optlen); addr_ifname[optlen] =3D 0; ret =3D get_errno(setsockopt(sockfd, SOL_SOCKET, optname, --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398637; cv=none; d=zohomail.com; s=zohoarc; b=LcRfn0VSCcB9AduqFoqchkxF+Ruvg+EZR5nbocT8Ybv3HhfwRAyP2F9RjtKgB3EMsNdKaeibv/d9snECAmKS/maQYt6tayDmnP9nyF+UeDmU/oc+KxV6oXiaPDcYveYd2iTkDcvTc7kyqOn63RWA1ACDy+iswwBlHq2t1AWtFks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398637; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=9UwtNiSXhDRvxxEBq2bA0+BsvH/APBPHI+6JmS4Uqh4=; b=CFJK8n1wT5MjOBka/gtFUUkLtU3Q6sbDEynhNRBTy1G+6MFRElqTRzoqK4xGHTsfHivHK9OMK+BloX4ctuM59IVl8tFd9fiMpAof7Mae9+X3wSnzBsaaksc96VDJ9FT/NOTX2eV2bqJncsenEHuwJ81NLld+TEJLmo3BaDr8WO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398637242862.5988956299205; Fri, 7 May 2021 07:43:57 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-5-8mP09EuROky4H3qXmW1SlA-1; Fri, 07 May 2021 10:43:52 -0400 Received: by mail-wm1-f71.google.com with SMTP id g199-20020a1c9dd00000b02901355dd71edaso3986527wme.7 for ; Fri, 07 May 2021 07:43:52 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id d3sm8221624wri.75.2021.05.07.07.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398634; 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=9UwtNiSXhDRvxxEBq2bA0+BsvH/APBPHI+6JmS4Uqh4=; b=ba0pIw39FsH2AzeV8xuN5DnIEiSYjJyNvPT2mgy/9e+WQYps0UUhjxUReMAFiXuqikIJtg br/WpRct94ZKK9GXQVZM7VzOfpU4JR5SpTtkYNhtdOulbCufUAhvx7TB3vgiJlyH9zKx7Y UqrfEzVM63odubiq13gR4zmZa2OXkjs= X-MC-Unique: 8mP09EuROky4H3qXmW1SlA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9UwtNiSXhDRvxxEBq2bA0+BsvH/APBPHI+6JmS4Uqh4=; b=Kjh3ezwFiKEC7wiWJbnEA85CA+wl6vitIYTrN3KIJZMWCpsOGUL6CArM4EEPYVY0U4 R2DiHfla4v1nDw5Pre0pHJzvf+oVs0dY9QPG7Khm41F54wiJgDqWzehcFa9TbHEhiaLB ACEbYLtncw2rutc59oeR2nQN+ZOtUyRhqs3mlc0U6R7tjkBQebUbj3IC/goTjieYMY5M cs/HK6VtTqZsFttUFxDDd7XhegYy3ScRSR4N3O8oHbmQMOIONTRWEN6i+7c71Grn6xyT lG1alvVd66DxX1jJBiNmFE5/AbwoYyAYoIg6Qr6ByxZZOttj9Yasa+BqZjuF8dgkLknP igOg== X-Gm-Message-State: AOAM531GucPNb/2NlBFv3+B73eq2feiA1msRusQwccJ0Q3j8XONP9LFR zpbRWfRS2TNI7N8OPBSM+Fi3dPvOzDgIatAf7AcqUl9sZBP3DKSXjrU112R2FhVxSm6c9GwE4hs QYIGxJMGzoMaUlg== X-Received: by 2002:a5d:4acc:: with SMTP id y12mr12640285wrs.233.1620398631054; Fri, 07 May 2021 07:43:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpO9HD46hd1zWh+qoigRuizkz+et7j2kyahnyJH43scB9tmRKhQTHHgYM62Qg0Bn5FVKcPCg== X-Received: by 2002:a5d:4acc:: with SMTP id y12mr12640261wrs.233.1620398630869; Fri, 07 May 2021 07:43:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 07/17] linux-user: Replace alloca() by g_try_malloc() in various socket syscall Date: Fri, 7 May 2021 16:43:05 +0200 Message-Id: <20210507144315.1994337-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 50 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a263aea85ff..7c5c821f48d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3307,14 +3307,17 @@ static abi_long do_socket(int domain, int type, int= protocol) static abi_long do_bind(int sockfd, abi_ulong target_addr, socklen_t addrlen) { - void *addr; + g_autofree void *addr =3D NULL; abi_long ret; =20 if ((int)addrlen < 0) { return -TARGET_EINVAL; } =20 - addr =3D alloca(addrlen+1); + addr =3D g_try_malloc(addrlen + 1); + if (!addr) { + return -TARGET_ENOMEM; + } =20 ret =3D target_to_host_sockaddr(sockfd, addr, target_addr, addrlen); if (ret) @@ -3327,14 +3330,17 @@ static abi_long do_bind(int sockfd, abi_ulong targe= t_addr, static abi_long do_connect(int sockfd, abi_ulong target_addr, socklen_t addrlen) { - void *addr; + g_autofree void *addr =3D NULL; abi_long ret; =20 if ((int)addrlen < 0) { return -TARGET_EINVAL; } =20 - addr =3D alloca(addrlen+1); + addr =3D g_try_malloc(addrlen + 1); + if (!addr) { + return -TARGET_ENOMEM; + } =20 ret =3D target_to_host_sockaddr(sockfd, addr, target_addr, addrlen); if (ret) @@ -3519,7 +3525,7 @@ static abi_long do_accept4(int fd, abi_ulong target_a= ddr, abi_ulong target_addrlen_addr, int flags) { socklen_t addrlen, ret_addrlen; - void *addr; + g_autofree void *addr =3D NULL; abi_long ret; int host_flags; =20 @@ -3541,7 +3547,10 @@ static abi_long do_accept4(int fd, abi_ulong target_= addr, return -TARGET_EFAULT; } =20 - addr =3D alloca(addrlen); + addr =3D g_try_malloc(addrlen); + if (!addr) { + return -TARGET_ENOMEM; + } =20 ret_addrlen =3D addrlen; ret =3D get_errno(safe_accept4(fd, addr, &ret_addrlen, host_flags)); @@ -3559,7 +3568,7 @@ static abi_long do_getpeername(int fd, abi_ulong targ= et_addr, abi_ulong target_addrlen_addr) { socklen_t addrlen, ret_addrlen; - void *addr; + g_autofree void *addr =3D NULL; abi_long ret; =20 if (get_user_u32(addrlen, target_addrlen_addr)) @@ -3573,7 +3582,10 @@ static abi_long do_getpeername(int fd, abi_ulong tar= get_addr, return -TARGET_EFAULT; } =20 - addr =3D alloca(addrlen); + addr =3D g_try_malloc(addrlen); + if (!addr) { + return -TARGET_ENOMEM; + } =20 ret_addrlen =3D addrlen; ret =3D get_errno(getpeername(fd, addr, &ret_addrlen)); @@ -3591,7 +3603,7 @@ static abi_long do_getsockname(int fd, abi_ulong targ= et_addr, abi_ulong target_addrlen_addr) { socklen_t addrlen, ret_addrlen; - void *addr; + g_autofree void *addr =3D NULL; abi_long ret; =20 if (get_user_u32(addrlen, target_addrlen_addr)) @@ -3605,7 +3617,10 @@ static abi_long do_getsockname(int fd, abi_ulong tar= get_addr, return -TARGET_EFAULT; } =20 - addr =3D alloca(addrlen); + addr =3D g_try_malloc(addrlen); + if (!addr) { + return -TARGET_ENOMEM; + } =20 ret_addrlen =3D addrlen; ret =3D get_errno(getsockname(fd, addr, &ret_addrlen)); @@ -3640,7 +3655,6 @@ static abi_long do_socketpair(int domain, int type, i= nt protocol, static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags, abi_ulong target_addr, socklen_t addrlen) { - void *addr; void *host_msg; void *copy_msg =3D NULL; abi_long ret; @@ -3662,7 +3676,11 @@ static abi_long do_sendto(int fd, abi_ulong msg, siz= e_t len, int flags, } } if (target_addr) { - addr =3D alloca(addrlen+1); + g_autofree void *addr =3D g_try_malloc(addrlen + 1); + + if (!addr) { + return -TARGET_ENOMEM; + } ret =3D target_to_host_sockaddr(fd, addr, target_addr, addrlen); if (ret) { goto fail; @@ -3686,7 +3704,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, si= ze_t len, int flags, abi_ulong target_addrlen) { socklen_t addrlen, ret_addrlen; - void *addr; + g_autofree void *addr =3D NULL; void *host_msg; abi_long ret; =20 @@ -3707,12 +3725,14 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, = size_t len, int flags, ret =3D -TARGET_EINVAL; goto fail; } - addr =3D alloca(addrlen); + addr =3D g_try_malloc(addrlen); + if (!addr) { + return -TARGET_ENOMEM; + } ret_addrlen =3D addrlen; ret =3D get_errno(safe_recvfrom(fd, host_msg, len, flags, addr, &ret_addrlen)); } else { - addr =3D NULL; /* To keep compiler quiet. */ addrlen =3D 0; /* To keep compiler quiet. */ ret =3D get_errno(safe_recvfrom(fd, host_msg, len, flags, NULL, 0)= ); } --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398642; cv=none; d=zohomail.com; s=zohoarc; b=ZywxJ9QS63aSPokbvScSKYcTcd//ukuc6EfrNY4ttV5Ml4TlQz/n+OdaBxu6j6NrOL/5PTxNHf+ujyKfRpVvH8ambCRzxUE1Sa7CFVKwVGKJ1Vy9/qof0S4wmy4aCk7ywMo4J6DoEr3FtX2eu2a4i1pqeytxiHCYhwshYxbMSrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398642; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=0aEFCYf2HLWMKyL3vu/hasMYJfVES1sketKqALkOn8E=; b=nkRipTfEcaMzKVqeeA+B5G2lo06fZcbAOX5Ud/bb0vhoMnsqfdgcsu9cN9+MNiZMSRedJBfBFNWCDy32uYG7rdFidM2jn8YPdA4jKoECKnokpvmDCBo0g/eguI/F/JPFLqnW7Zemyh8+I95AkYs4h/ArAlKJkvJ47HPRhHFmYEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620398642212975.2462757887454; Fri, 7 May 2021 07:44:02 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-37EddMzOOgGKwZCb9J6YlQ-1; Fri, 07 May 2021 10:43:57 -0400 Received: by mail-wr1-f70.google.com with SMTP id d20-20020adfc3d40000b029010e1a640bbfso3692720wrg.21 for ; Fri, 07 May 2021 07:43:56 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id q12sm9079882wrx.17.2021.05.07.07.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398640; 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=0aEFCYf2HLWMKyL3vu/hasMYJfVES1sketKqALkOn8E=; b=FRnr4im3S2xBtHFd49O9DhNEsMYlkEOzBgA/MsRyX3ulC0BD30mdDMHR5uaafLvAkNJmqL AeJIcs1/mb8l/Pw2kezoDDnZo/xmWllroTpauu8OyYcob2TbRgHFX7KFw3nlj9RtNDxt4l l6bNwuE4K6wc4aAdpYZlKCBo3i4xzi4= X-MC-Unique: 37EddMzOOgGKwZCb9J6YlQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0aEFCYf2HLWMKyL3vu/hasMYJfVES1sketKqALkOn8E=; b=dOmIUHtfNZmqGpGKFeXbQxxoM/t+27lzNCjLEEstzxcKBG5fdDpICHoSQ8B0siUQXY 0kxkaRQfLW5RoUZ75CyxYc4xEQ9wdvHVv6DK1LJmlDVTdfL0aRMKUoZKx5XfCzWFZv5h aOVbaD6aVw7fDHyQqVwSzamSWqnWVm26gRuGm8/dMJ/rtO0ry5xP5od7fvRTwavH+j// KdAEExj9aIIyhoE2y5GiAXvskeFfOhWEOgCeuIWL6IBja2Q++9JFOSV34eIu6+T3gyOi HY+btDwEnPCxp3oa0o6ENvmHu0+OifmEuMdm6osZcavRSixTcNAUgGZijOsU2UXYyh1Z nX8w== X-Gm-Message-State: AOAM5339r+ZiTGdwxrUfcnFGmSHTJNQIEchrzSc9iPJJLgMJIwUsP6B1 x3iivD+iLBkEIG0C6nmwupnfqpgR2CPzFFg1WjdqC+70YMMDzWo9ukWcd5YWTAqXsJvCqBlly3t OXeddkhCAAwUM2g== X-Received: by 2002:a1c:e912:: with SMTP id q18mr21780857wmc.59.1620398635880; Fri, 07 May 2021 07:43:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuxDw+Z5ejCnnQGzrscKMxB38QYBMH5R95NR75yg2DPkosJ/eaQfVzqQPNjxuH9z1wWTJ1gA== X-Received: by 2002:a1c:e912:: with SMTP id q18mr21780843wmc.59.1620398635604; Fri, 07 May 2021 07:43:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 08/17] linux-user/syscall: Move code around in do_sendrecvmsg_locked() Date: Fri, 7 May 2021 16:43:06 +0200 Message-Id: <20210507144315.1994337-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Avoid initializing variables too early, since there is 2 possible failure points before they get used. Move them after the lock_iovec() call. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7c5c821f48d..593241362a9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3379,15 +3379,8 @@ static abi_long do_sendrecvmsg_locked(int fd, struct= target_msghdr *msgp, msg.msg_name =3D NULL; msg.msg_namelen =3D 0; } - msg.msg_controllen =3D 2 * tswapal(msgp->msg_controllen); - msg.msg_control =3D alloca(msg.msg_controllen); - memset(msg.msg_control, 0, msg.msg_controllen); - - msg.msg_flags =3D tswap32(msgp->msg_flags); =20 count =3D tswapal(msgp->msg_iovlen); - target_vec =3D tswapal(msgp->msg_iov); - if (count > IOV_MAX) { /* sendrcvmsg returns a different errno for this condition than * readv/writev, so we must catch it here before lock_iovec() does. @@ -3396,14 +3389,20 @@ static abi_long do_sendrecvmsg_locked(int fd, struc= t target_msghdr *msgp, goto out2; } =20 + target_vec =3D tswapal(msgp->msg_iov); vec =3D lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, target_vec, count, send); if (vec =3D=3D NULL) { ret =3D -host_to_target_errno(errno); goto out2; } + msg.msg_iovlen =3D count; msg.msg_iov =3D vec; + msg.msg_flags =3D tswap32(msgp->msg_flags); + msg.msg_controllen =3D 2 * tswapal(msgp->msg_controllen); + msg.msg_control =3D alloca(msg.msg_controllen); + memset(msg.msg_control, 0, msg.msg_controllen); =20 if (send) { if (fd_trans_target_to_host_data(fd)) { --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398644; cv=none; d=zohomail.com; s=zohoarc; b=CkmxrSiV57G0ccn0EvDRaaGijnDqU6mmrpIGzfZba5Oqhpg7HNNJ7CLSPFXUpWQWxzbz9xqwdA5YsUMdL41H8ztKpbgBbM3jbmWyJlausDTykDhYiuf8xx3U/3BeMfWxGUtcSgIDTyEPHbjsnuNfIRWjmkRv0a0TDgwniy9I5FA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398644; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=VXb/SdsglaW/QeR809+FkWbDDukXToeT9LG+jBzD2Ak=; b=ASQc8ZNPoKtErZdOOOYb4H2Okg7fXCEL3OfMwPnunQ9++02fiy+muebHNNyfELevS3lCWRtELF17eOK7tKkQtHwBdqMvTinx/kByDD7SeCiedkIZdVqTkYBElAakI0mDAR2IVUiVCchwVZUie50HMU+jBVhc13TpHPZd+O4qzTA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398644611840.555535910525; Fri, 7 May 2021 07:44:04 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-v0QgpFftNRamJ5G_is59Yw-1; Fri, 07 May 2021 10:44:01 -0400 Received: by mail-wr1-f70.google.com with SMTP id 65-20020adf82c70000b0290107593a42c3so3700923wrc.5 for ; Fri, 07 May 2021 07:44:01 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id v13sm8883864wrt.65.2021.05.07.07.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398643; 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=VXb/SdsglaW/QeR809+FkWbDDukXToeT9LG+jBzD2Ak=; b=NdV3KcBaBxPdcdPawJGW+qo0sV7BVOUVGrszLU/9qcz7zpAPjXoHay0i9/pdpiM+Kq0Dgg 316Xc/zDa6O27uQm2rcM8antPHx1WVFHMjwuQa43L+Nn+Z/xGEFMeZ0JOHKJSYR46s1oKf 7XYtQy536rtL4oGTXN6gj+qbsJmU73c= X-MC-Unique: v0QgpFftNRamJ5G_is59Yw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VXb/SdsglaW/QeR809+FkWbDDukXToeT9LG+jBzD2Ak=; b=DB3B4LUACF26Dde1cKnSvUc908U4Us0oJImm8e6k9D2A2LTFTd2+j/rjrjNlp1Appc 4CVKhD8pMGK24J1aJwFh/jzrij/s4+Gq9maDH1+6TkE3+CKJji7mc3+qSOa+kdRZ95r0 xxOuqzhLDVMn/t8GNkdpRtED7mxLLqrZGo3uIF5wUMKKhwcHA0mekJIul/4aiAygf+0v OFwWSdv1/hToZeI1gYH3nglZhMdqA/qJBc1WTCzpzsWM2bfzNb8sCyECVe3XApUKEBWH jSSh4c81wgau+/ole4+T5KTTQ99s05doMkIPQ8YFQjsT2YDJJSVCKzclZMzdrFAjci1c UspA== X-Gm-Message-State: AOAM5328x5NgqGovLA6m3v+JhUhokZwpK4Zd/pVq2u9kANyHNYgfdhGb pLAknWenXWleZdxEgmgvWYaTcZ08SgR1rcg3oGvCxTIqg4coxIVc8Pj1fetTSssR31nzxy0Z47X 6ZeAgjmkaeSZLxw== X-Received: by 2002:adf:f5c6:: with SMTP id k6mr13450291wrp.338.1620398640705; Fri, 07 May 2021 07:44:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIYqu7g0FIq8SCVQnMmTws2rDcXfTUEbAeQnUtRQ+O103KeVplYGEoYEo0zclOShBCiqkK6w== X-Received: by 2002:adf:f5c6:: with SMTP id k6mr13450277wrp.338.1620398640536; Fri, 07 May 2021 07:44:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/17] linux-user/syscall: Replace alloca() by GLib alloc() in sendrecvmsg Date: Fri, 7 May 2021 16:43:07 +0200 Message-Id: <20210507144315.1994337-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 593241362a9..c88e240ff93 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3358,13 +3358,19 @@ static abi_long do_sendrecvmsg_locked(int fd, struc= t target_msghdr *msgp, abi_ulong count; struct iovec *vec; abi_ulong target_vec; + g_autofree void *msg_control =3D NULL; =20 if (msgp->msg_name) { msg.msg_namelen =3D tswap32(msgp->msg_namelen); - msg.msg_name =3D alloca(msg.msg_namelen+1); + msg.msg_name =3D g_try_malloc(msg.msg_namelen + 1); + if (!msg.msg_name) { + ret =3D -TARGET_ENOMEM; + goto out2; + } ret =3D target_to_host_sockaddr(fd, msg.msg_name, tswapal(msgp->msg_name), msg.msg_namelen); + g_free(msg.msg_name); if (ret =3D=3D -TARGET_EFAULT) { /* For connected sockets msg_name and msg_namelen must * be ignored, so returning EFAULT immediately is wrong. @@ -3401,8 +3407,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct = target_msghdr *msgp, msg.msg_iov =3D vec; msg.msg_flags =3D tswap32(msgp->msg_flags); msg.msg_controllen =3D 2 * tswapal(msgp->msg_controllen); - msg.msg_control =3D alloca(msg.msg_controllen); - memset(msg.msg_control, 0, msg.msg_controllen); + msg.msg_control =3D msg_control =3D g_malloc0(msg.msg_controllen); =20 if (send) { if (fd_trans_target_to_host_data(fd)) { --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398649; cv=none; d=zohomail.com; s=zohoarc; b=Tkmv7EQeZNdeMzF0KtUanrnYzQnwnmJfzB6lRBuwjNWji6Q3CIJ9noqIg6iwKKbo8eX39vt28q36zrRrIqM/IiXcdNQR8BEVI7hekPWeuiPQHLm9qFglHyltz2VIwZTETnvI3kNPAT0rYIL3jGKanH3hYI5cih/B8lxekIIEXfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398649; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=inqMaBp73JqX5XGgGohxXCnv5ua7seSf5zgYq5n1Z5+GDGGglGW3+pqODGjkyOSOKi/+OB6o98oRr4OXjR2Eksm8ge7decFlpdPLGaeaYB6YBJfzJ9nAvnpocf8U7oBXhzYhFkTmcYjHEztloKXl5+SUFtveIo430pnSVEZMwco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620398649383942.8997353263106; Fri, 7 May 2021 07:44:09 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-CZRjydftNKCEWaOXYfwbBg-1; Fri, 07 May 2021 10:44:06 -0400 Received: by mail-wm1-f71.google.com with SMTP id o18-20020a1ca5120000b02901333a56d46eso3990876wme.8 for ; Fri, 07 May 2021 07:44:06 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id r5sm7924414wmh.23.2021.05.07.07.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398648; 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=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=RBmkarIQePHLIY2cHeYblK3Le+SfkAv/DMlfnWz3Z80p4bfKAtHk9C0ErRYKaZyZ8YGo0F FpmJVndZIkwN0Rd9LgDGpBsUoNqJ4lFKq8Ziv3sH+snifJQh7Qf9rULgip1liuMTEgsBQh qExhO4BWsLQaKm/GOMqSghWN4Tsa720= X-MC-Unique: CZRjydftNKCEWaOXYfwbBg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/bdOhY3sBOcIHJeoCe6CkJ1QfZvAaT12hvfPxmFulM0=; b=nq4/PbYHqo5fxhxkEMuPJQWjnHQh83S7DviyTKg+GGELJlaSMOUp1hjWCHZKcbk4Xc J1kI7Uo1tsdZiH9m241nO3DMl5+/4htpjs7Cyzt/JZOOjWhpVfuP53b4QUu3mVJy09it yWkc8A6gprzg4+4Mdy+fXIe3JaG6qnSY1g9L/UMU5hFKuEZlHEpXmMJnyyky5W6icmry Sh5QDcWATx6Bkf0dzTEi4KdcS9gwHwluYPWlg2aIIR/HIozzaalZefkdrvnaDQMMacUI XQgvcudNu3UJ3GbivVKlmbpAarZE8GBaEy7AJ+dglG3nW5aIKwNB07AzIASZQ/HQLs3/ RJ0Q== X-Gm-Message-State: AOAM533dx2KD+CCbGTRHNekWwl4hjA/kMbEgvtouNfaEDAU/qn0Duy9s +MYAvRn8i/bGSG+Md7dv5Pb6jCG+aNukw7OesiQwnjugIAjOi+SZdESa3NsILR//BS3hVlJ3iEQ 02Kc2t9Hy/nknyA== X-Received: by 2002:a5d:4a51:: with SMTP id v17mr9368896wrs.259.1620398645491; Fri, 07 May 2021 07:44:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAGBqHXqPnxWmUTdUgr41RWwEb2R01PCsDEiapDu7vy61qLy24zEvVbo/zgUT9ufemsXGN8A== X-Received: by 2002:a5d:4a51:: with SMTP id v17mr9368879wrs.259.1620398645319; Fri, 07 May 2021 07:44:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 10/17] audio/alsaaudio: Replace ALSA alloca() by malloc() equivalent Date: Fri, 7 May 2021 16:43:08 +0200 Message-Id: <20210507144315.1994337-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Define the cleanup functions for the snd_pcm_[hw/sw]_params_t types, and replace the ALSA alloca() calls by equivalent ALSA malloc(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- audio/alsaaudio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index fcc2f62864f..f39061ebc42 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -70,6 +70,9 @@ struct alsa_params_obt { snd_pcm_uframes_t samples; }; =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(snd_pcm_hw_params_t, snd_pcm_hw_params_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(snd_pcm_sw_params_t, snd_pcm_sw_params_free) + static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...) { va_list ap; @@ -410,9 +413,9 @@ static void alsa_dump_info (struct alsa_params_req *req, static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t thres= hold) { int err; - snd_pcm_sw_params_t *sw_params; + g_autoptr(snd_pcm_sw_params_t) sw_params =3D NULL; =20 - snd_pcm_sw_params_alloca (&sw_params); + snd_pcm_sw_params_malloc(&sw_params); =20 err =3D snd_pcm_sw_params_current (handle, sw_params); if (err < 0) { @@ -444,7 +447,7 @@ static int alsa_open(bool in, struct alsa_params_req *r= eq, AudiodevAlsaOptions *aopts =3D &dev->u.alsa; AudiodevAlsaPerDirectionOptions *apdo =3D in ? aopts->in : aopts->out; snd_pcm_t *handle; - snd_pcm_hw_params_t *hw_params; + g_autoptr(snd_pcm_hw_params_t) hw_params =3D NULL; int err; unsigned int freq, nchannels; const char *pcm_name =3D apdo->has_dev ? apdo->dev : "default"; @@ -455,7 +458,7 @@ static int alsa_open(bool in, struct alsa_params_req *r= eq, freq =3D req->freq; nchannels =3D req->nchannels; =20 - snd_pcm_hw_params_alloca (&hw_params); + snd_pcm_hw_params_malloc(&hw_params); =20 err =3D snd_pcm_open ( &handle, --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398659; cv=none; d=zohomail.com; s=zohoarc; b=lZoHcwOzE9Hx1B+aYxSWwBMJOKtqHfXZvW5veunqlYtqSpoTucOIyiwx+gBgINN6370HnkPYcu+s4OKCj1GPiZMCLXHyw09kyhf6zNtNiinRlgunE2zncfYl43kPYR1BZqjMf+STqhXF71JI6/32+GBmmgfnHYE/0HwnT/keT6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398659; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=LTsvX/otw5M7TG+3dUKEvSePlS48V26N+Mr55ie/fDA=; b=iyBS98jkkxiO5NSFwdBXE10Jx9Di7OtFYr47627Go0YIlEr/A/vD3ykm2SYMNaSfCeUSg1YgtVs1G6vEIfSpwiyILCcRWgf52RGnoh25TUG0UTco3Ycr4yktNat0O5VR8Fe6QhAQygk48XhRi/tehDzBtKj8yBgEtaUVTKKqJB8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398659788708.9202484410638; Fri, 7 May 2021 07:44:19 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-0XkjKfiWNKqOtLuGXvk7uQ-1; Fri, 07 May 2021 10:44:11 -0400 Received: by mail-wr1-f70.google.com with SMTP id 93-20020adf93e60000b029010d9bb1923eso3695438wrp.4 for ; Fri, 07 May 2021 07:44:11 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id w25sm6720771wmk.39.2021.05.07.07.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398658; 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=LTsvX/otw5M7TG+3dUKEvSePlS48V26N+Mr55ie/fDA=; b=W8vdty0G7co2nVEPWyMT8PZLlJt3W/57AV/bxxAh4t2/IuLBeOWS2tmdeDZcCYtq+Dc+pe IB7QiHqaPkONfnVcJVLTEvPiLcxpEjmL65blCxpmA68QOnkvYe73hSlNtji55NiuCx9hdW nlIqK/R0EBjKhl/OX7G9nsJWgh6EVbw= X-MC-Unique: 0XkjKfiWNKqOtLuGXvk7uQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LTsvX/otw5M7TG+3dUKEvSePlS48V26N+Mr55ie/fDA=; b=WwE/2tLEmCKwUPwlA5LIpFSflJ2ILDZkI09TUhxGzyIt5/2YPQByFdf4WSPhguFKGD fnY23m/xOq9GM4e7YGKvsJguwfZMfEDJwQkL1ffooXG2/YBUNLvv1ojr48d6ldUHQqTA G0jIUWjyEm4udb8C+C8qtfaHWlBgIi475KOj2YiqQMg7iYX886KehH4jM+KJgNbCIhDh qo+lhTzt/pLqsCNewux/gxK8B/oPpx96SrLBQukU3uH13WftdBoohuvOgACI9JZ985bS VQp2XiURg5IftCsygZj3Y6yZpwZPGrrrR5kCg/WOZfpwHaxJnT/JwtQZ6TilxE6h/7/n dbeQ== X-Gm-Message-State: AOAM533ZkKwODSnhj41nzCHPf20rlCMApiykLZPah1PMPzFH2G4IX+hv VvshdQ00eSwYcSZw0w+IGpDgKTK7x31ZkX30+ULsKMpdD8q256z/D2dD6nl5o87/T40mueYICY2 s28ATmuhGtrFGMg== X-Received: by 2002:a5d:498c:: with SMTP id r12mr12851504wrq.31.1620398650416; Fri, 07 May 2021 07:44:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTUSY9yat3Yq68EUlkMCcRoADc9UMIi0CNyQErfTSuxO4A4BB59fJXUwarlSImz3l6WDzCOA== X-Received: by 2002:a5d:498c:: with SMTP id r12mr12851489wrq.31.1620398650237; Fri, 07 May 2021 07:44:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Berger , Stefan Berger Subject: [PATCH v3 11/17] backends/tpm: Replace g_alloca() by g_malloc() Date: Fri, 7 May 2021 16:43:09 +0200 Message-Id: <20210507144315.1994337-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Replace a g_alloca() call by a autofree g_malloc() one, moving the allocation before the MUTEX guarded block. Reviewed-by: Stefan Berger Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- backends/tpm/tpm_emulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index a012adc1934..9553cdd891f 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -123,12 +123,11 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, uns= igned long cmd, void *msg, CharBackend *dev =3D &tpm->ctrl_chr; uint32_t cmd_no =3D cpu_to_be32(cmd); ssize_t n =3D sizeof(uint32_t) + msg_len_in; - uint8_t *buf =3D NULL; + g_autofree uint8_t *buf =3D g_malloc(n); int ret =3D -1; =20 qemu_mutex_lock(&tpm->mutex); =20 - buf =3D g_alloca(n); memcpy(buf, &cmd_no, sizeof(cmd_no)); memcpy(buf + sizeof(cmd_no), msg, msg_len_in); =20 --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398659; cv=none; d=zohomail.com; s=zohoarc; b=jiQe5vhTdpd3b46THSvY31Xv6fuBUhOBeNYaH4h+Dv0SxBunJ7SfHm9cUQpuPDAeYZ1aG0B6vS9wSB1mxVfrhD3/tb1BOrD4w+V3cqIH2+OL1aMI2ThMiUzNNbJ5Yh6uxqW4fSRVigguHZ7HtltiRxGl2T3oYFUoIVhrK1v7sGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398659; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=B3vDcPc2Lwo5z0s8ItWutJUQDssHj4SCpM1PcCRAn5U=; b=BRhMt4+6TdiWTcQ4gEMYqBq2gbxsEHPv9LVGL4OrS62Y4I5l0PHW9wiR+10/KmpRoSgYXlmEoYChsJlcELGy6GtFJShxhLZZgHIvIFJn1IuJwVT0ZgSzGrSbl+1f5sFZ55OnHi7BsqS0E5zGYgfqbMyO9J7d0LW9LteqgVQpNPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398659004106.68190102280221; Fri, 7 May 2021 07:44:19 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-Jyn7JuudOsK688QMQhgRcA-1; Fri, 07 May 2021 10:44:16 -0400 Received: by mail-wm1-f71.google.com with SMTP id b16-20020a7bc2500000b029014587f5376dso3125478wmj.1 for ; Fri, 07 May 2021 07:44:15 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id r5sm7924795wmh.23.2021.05.07.07.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398657; 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=B3vDcPc2Lwo5z0s8ItWutJUQDssHj4SCpM1PcCRAn5U=; b=Dt46niDFld6lbPOre/2refLkrp2sAnAxAXyAHzJSCkAZOoRf2MGYgHWkidgcr7OrN8qseo qY6yeY3gASGpIed+A8K44pc/lNnojw5PTOw//9aY4Q+yXc5YIftpaRhnzVtWx8mKcPEWpb FInXrNHnIipVA0H5bOzQLke13KcizPk= X-MC-Unique: Jyn7JuudOsK688QMQhgRcA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B3vDcPc2Lwo5z0s8ItWutJUQDssHj4SCpM1PcCRAn5U=; b=l4xpKOttyvzMoso+tnZi9n+NTJ5i8jAYP+QZCPX1DU/arvVrNxbtrdbwWbNZe6Byc4 zX4pfR1O/qjb8tkaAEPFfucrk3oSt/PVOlT58O0I7WZAMv8Bz8Jr9kY0IGH+E0MIqkHA uJdKSJHetwcCnB/7cdT9Ixiljj5tC6rkjzULGfB3fkWLwmlXU+rChdqoXQPltGQc/Vdt tu97xu7Sv4tB0ywAMfZT1MsPth7/NpnGoJIzFbwowgA+nD/POAUpREvD6b/wJ2Dczt5G xUAhcJAwKbGzIkYN/4LzN3J5E3Mrf25nGbS7N70KUpQEc1JZ+b9PMoQzAJ4xSfq47uET BgAQ== X-Gm-Message-State: AOAM5326Ah5HqPcG8rkeq0ypa1JBxKSH6vIolVdXmn50byLcR8sHiYZR PlxTTKd26jSrj4d6kuob63V2Ugh2cjwjIR2GxYR7bZ+1rvHcaJyxWlzVRq4khoF2upSItmujm+1 ckvvK3seJWwZP7A== X-Received: by 2002:a7b:cc15:: with SMTP id f21mr21011228wmh.86.1620398655112; Fri, 07 May 2021 07:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzepcSCNHFzx7Vk1l7Yecw5eu3JmKlqle2NYs72V/81IbdrlCspu8WvBmn62kYIs0w4K4g+cA== X-Received: by 2002:a7b:cc15:: with SMTP id f21mr21011214wmh.86.1620398654950; Fri, 07 May 2021 07:44:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 12/17] gdbstub: Constify GdbCmdParseEntry Date: Fri, 7 May 2021 16:43:10 +0200 Message-Id: <20210507144315.1994337-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9103ffc9028..83d47c67325 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1981,7 +1981,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, voi= d *user_ctx) exit(0); } =20 -static GdbCmdParseEntry gdb_v_commands_table[] =3D { +static const GdbCmdParseEntry gdb_v_commands_table[] =3D { /* Order is important if has same prefix */ { .handler =3D handle_v_cont_query, @@ -2324,7 +2324,7 @@ static void handle_set_qemu_phy_mem_mode(GdbCmdContex= t *gdb_ctx, void *user_ctx) } #endif =20 -static GdbCmdParseEntry gdb_gen_query_set_common_table[] =3D { +static const GdbCmdParseEntry gdb_gen_query_set_common_table[] =3D { /* Order is important if has same prefix */ { .handler =3D handle_query_qemu_sstepbits, @@ -2342,7 +2342,7 @@ static GdbCmdParseEntry gdb_gen_query_set_common_tabl= e[] =3D { }, }; =20 -static GdbCmdParseEntry gdb_gen_query_table[] =3D { +static const GdbCmdParseEntry gdb_gen_query_table[] =3D { { .handler =3D handle_query_curr_tid, .cmd =3D "C", @@ -2420,7 +2420,7 @@ static GdbCmdParseEntry gdb_gen_query_table[] =3D { #endif }; =20 -static GdbCmdParseEntry gdb_gen_set_table[] =3D { +static const GdbCmdParseEntry gdb_gen_set_table[] =3D { /* Order is important if has same prefix */ { .handler =3D handle_set_qemu_sstep, --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398668; cv=none; d=zohomail.com; s=zohoarc; b=JolSc4gIfxAi2mivAW+elAnkaUzcXT478PHvluATupM6GNulH4GMPUi8LsWHRCFV0qwN+QWJ1bGWiq90Wxh7HvRv7J9bO79AaGEsYatCtDcmJTb8jugXEXpf2wY+5zl7+JreFpq4ABMbRI16ahjp8nHyQZiJtq7YL/Tex5mLNEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398668; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=kLWd0gsOs/zJbnWSmwYcEDNmDuRZ+yJPcTXC6c2hf6w=; b=OWw/OsjMW+WUNsEiBSx6vUMlP0GVZw6Yk25PjuLPAT6cbDM+B3OZ//Sw4Op3P92EgQATjodSqifDshrAwgD9kpkpzgXYinxxuJJdkYsuUynGubhVc854xH9Sq6208TEEpftFohKOkDHBps2aWZ7usBWFhuCzoV9uw6KNskCt4ew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620398668460205.25354973533945; Fri, 7 May 2021 07:44:28 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-rzGL-EiKPAOZb4zH5LtrFw-1; Fri, 07 May 2021 10:44:22 -0400 Received: by mail-wr1-f72.google.com with SMTP id 65-20020adf82c70000b0290107593a42c3so3701238wrc.5 for ; Fri, 07 May 2021 07:44:21 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id f11sm13853458wmq.41.2021.05.07.07.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398666; 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=kLWd0gsOs/zJbnWSmwYcEDNmDuRZ+yJPcTXC6c2hf6w=; b=MFrzvjTXwYIckGvZ1IpCmpikzdFw6zgtcpQueFv8JUypgROa8mrJp9l8xvpVujuTlOaLdd 0I+pYXJHoE0y6iFct2zeDJxCHAW+APb+5nfkWpPssSq1OK3J71PvnX1/cb8tY46waCs7p7 0LkrgpUaFttpAkSf1/qi2qP9YrHI7eo= X-MC-Unique: rzGL-EiKPAOZb4zH5LtrFw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kLWd0gsOs/zJbnWSmwYcEDNmDuRZ+yJPcTXC6c2hf6w=; b=ar5lUhq1hIMzztOT5h8KQm7PRDTXxshNbE3YOdK6EbtlDtotZc0WRUPn6F4+GotrzT mB5m7X0wa7sTOFacSaNCrpcQqj7Q6bmcvRYdTWFUFaM39c+w0QHnSwX86y+iePhl3ZKq gBxez6GIO9KYSMs0cIYGcdOky+zcQ8NWg18FAHk+lIvU9RL59xbA1/MOxiDUIEMxI9K5 DKHNhNf5jPEXjVZAXrOwM6WwzzlSWzWvP2v1hkWrBTPD81DprdHbA9DfWzOFH7sWCf6n hroWd/TSzRRaAg84sYu3tXaKujc3sSlB+IzLOwIyF/OPHoLVnb0uyOfV5cDmAPC31b49 emxg== X-Gm-Message-State: AOAM530ZrJKeFuQwWJu5FX2++g6IZXiJ+0/ReMNa/IZ7ZtNtz8HGxoZv apJu/qw5gscm6M3XGj+6yq72ztS51FhySaluV3qSg6x0kia04vIcCHf1Dfoan9hY/kFF2iYHXB+ L0G1gmGKa8DjwOw== X-Received: by 2002:a05:600c:284:: with SMTP id 4mr10237628wmk.88.1620398660595; Fri, 07 May 2021 07:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAOOvRCHRw9pYpzgMzgqmnnpC9HZrmREjC7M9ldlWU6MI2H0ObL9x1a/PosyHMj8fhzWACXw== X-Received: by 2002:a05:600c:284:: with SMTP id 4mr10237606wmk.88.1620398660291; Fri, 07 May 2021 07:44:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 13/17] gdbstub: Replace GdbCmdContext with plain g_array() Date: Fri, 7 May 2021 16:43:11 +0200 Message-Id: <20210507144315.1994337-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Alex Benn=C3=A9e Instead of jumping through hoops let glib deal with both tracking the number of elements and auto freeing the memory once we are done. This allows is to drop the usage of ALLOCA(3) which the man-page mentions its "use is discouraged". Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210506160741.9841-1-alex.bennee@linaro.org> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 314 +++++++++++++++++++++++++----------------------------- 1 file changed, 146 insertions(+), 168 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 83d47c67325..5e9e8e3e006 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1338,6 +1338,8 @@ typedef union GdbCmdVariant { } thread_id; } GdbCmdVariant; =20 +#define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) + static const char *cmd_next_param(const char *param, const char delimiter) { static const char all_delimiters[] =3D ",;:=3D"; @@ -1363,54 +1365,46 @@ static const char *cmd_next_param(const char *param= , const char delimiter) } =20 static int cmd_parse_params(const char *data, const char *schema, - GdbCmdVariant *params, int *num_params) + GArray *params) { - int curr_param; const char *curr_schema, *curr_data; =20 - *num_params =3D 0; - - if (!schema) { - return 0; - } + g_assert(schema); + g_assert(params->len =3D=3D 0); =20 curr_schema =3D schema; - curr_param =3D 0; curr_data =3D data; while (curr_schema[0] && curr_schema[1] && *curr_data) { + GdbCmdVariant this_param; + switch (curr_schema[0]) { case 'l': if (qemu_strtoul(curr_data, &curr_data, 16, - ¶ms[curr_param].val_ul)) { + &this_param.val_ul)) { return -EINVAL; } - curr_param++; curr_data =3D cmd_next_param(curr_data, curr_schema[1]); break; case 'L': if (qemu_strtou64(curr_data, &curr_data, 16, - (uint64_t *)¶ms[curr_param].val_ull)) { + (uint64_t *)&this_param.val_ull)) { return -EINVAL; } - curr_param++; curr_data =3D cmd_next_param(curr_data, curr_schema[1]); break; case 's': - params[curr_param].data =3D curr_data; - curr_param++; + this_param.data =3D curr_data; curr_data =3D cmd_next_param(curr_data, curr_schema[1]); break; case 'o': - params[curr_param].opcode =3D *(uint8_t *)curr_data; - curr_param++; + this_param.opcode =3D *(uint8_t *)curr_data; curr_data =3D cmd_next_param(curr_data, curr_schema[1]); break; case 't': - params[curr_param].thread_id.kind =3D + this_param.thread_id.kind =3D read_thread_id(curr_data, &curr_data, - ¶ms[curr_param].thread_id.pid, - ¶ms[curr_param].thread_id.tid); - curr_param++; + &this_param.thread_id.pid, + &this_param.thread_id.tid); curr_data =3D cmd_next_param(curr_data, curr_schema[1]); break; case '?': @@ -1419,19 +1413,14 @@ static int cmd_parse_params(const char *data, const= char *schema, default: return -EINVAL; } + g_array_append_val(params, this_param); curr_schema +=3D 2; } =20 - *num_params =3D curr_param; return 0; } =20 -typedef struct GdbCmdContext { - GdbCmdVariant *params; - int num_params; -} GdbCmdContext; - -typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); +typedef void (*GdbCmdHandler)(GArray *params, void *user_ctx); =20 /* * cmd_startswith -> cmd is compared using startswith @@ -1471,8 +1460,8 @@ static inline int startswith(const char *string, cons= t char *pattern) static int process_string_cmd(void *user_ctx, const char *data, const GdbCmdParseEntry *cmds, int num_cmds) { - int i, schema_len, max_num_params =3D 0; - GdbCmdContext gdb_ctx; + int i; + g_autoptr(GArray) params =3D g_array_new(false, true, sizeof(GdbCmdVar= iant)); =20 if (!cmds) { return -1; @@ -1488,24 +1477,13 @@ static int process_string_cmd(void *user_ctx, const= char *data, } =20 if (cmd->schema) { - schema_len =3D strlen(cmd->schema); - if (schema_len % 2) { - return -2; + if (cmd_parse_params(&data[strlen(cmd->cmd)], + cmd->schema, params)) { + return -1; } - - max_num_params =3D schema_len / 2; } =20 - gdb_ctx.params =3D - (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_para= ms); - memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_params= ); - - if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, - gdb_ctx.params, &gdb_ctx.num_params)) { - return -1; - } - - cmd->handler(&gdb_ctx, user_ctx); + cmd->handler(params, user_ctx); return 0; } =20 @@ -1528,18 +1506,18 @@ static void run_cmd_parser(const char *data, const = GdbCmdParseEntry *cmd) } } =20 -static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_detach(GArray *params, void *user_ctx) { GDBProcess *process; uint32_t pid =3D 1; =20 if (gdbserver_state.multiprocess) { - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } =20 - pid =3D gdb_ctx->params[0].val_ul; + pid =3D get_param(params, 0)->val_ul; } =20 process =3D gdb_get_process(pid); @@ -1562,22 +1540,22 @@ static void handle_detach(GdbCmdContext *gdb_ctx, v= oid *user_ctx) put_packet("OK"); } =20 -static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_thread_alive(GArray *params, void *user_ctx) { CPUState *cpu; =20 - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } =20 - if (gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { + if (get_param(params, 0)->thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { put_packet("E22"); return; } =20 - cpu =3D gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, - gdb_ctx->params[0].thread_id.tid); + cpu =3D gdb_get_cpu(get_param(params, 0)->thread_id.pid, + get_param(params, 0)->thread_id.tid); if (!cpu) { put_packet("E22"); return; @@ -1586,17 +1564,17 @@ static void handle_thread_alive(GdbCmdContext *gdb_= ctx, void *user_ctx) put_packet("OK"); } =20 -static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_continue(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params) { - gdb_set_cpu_pc(gdb_ctx->params[0].val_ull); + if (params->len) { + gdb_set_cpu_pc(get_param(params, 0)->val_ull); } =20 gdbserver_state.signal =3D 0; gdb_continue(); } =20 -static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_cont_with_sig(GArray *params, void *user_ctx) { unsigned long signal =3D 0; =20 @@ -1604,8 +1582,8 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_c= tx, void *user_ctx) * Note: C sig;[addr] is currently unsupported and we simply * omit the addr parameter */ - if (gdb_ctx->num_params) { - signal =3D gdb_ctx->params[0].val_ul; + if (params->len) { + signal =3D get_param(params, 0)->val_ul; } =20 gdbserver_state.signal =3D gdb_signal_to_target(signal); @@ -1615,27 +1593,27 @@ static void handle_cont_with_sig(GdbCmdContext *gdb= _ctx, void *user_ctx) gdb_continue(); } =20 -static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_set_thread(GArray *params, void *user_ctx) { CPUState *cpu; =20 - if (gdb_ctx->num_params !=3D 2) { + if (params->len !=3D 2) { put_packet("E22"); return; } =20 - if (gdb_ctx->params[1].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { + if (get_param(params, 1)->thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { put_packet("E22"); return; } =20 - if (gdb_ctx->params[1].thread_id.kind !=3D GDB_ONE_THREAD) { + if (get_param(params, 1)->thread_id.kind !=3D GDB_ONE_THREAD) { put_packet("OK"); return; } =20 - cpu =3D gdb_get_cpu(gdb_ctx->params[1].thread_id.pid, - gdb_ctx->params[1].thread_id.tid); + cpu =3D gdb_get_cpu(get_param(params, 1)->thread_id.pid, + get_param(params, 1)->thread_id.tid); if (!cpu) { put_packet("E22"); return; @@ -1645,7 +1623,7 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx,= void *user_ctx) * Note: This command is deprecated and modern gdb's will be using the * vCont command instead. */ - switch (gdb_ctx->params[0].opcode) { + switch (get_param(params, 0)->opcode) { case 'c': gdbserver_state.c_cpu =3D cpu; put_packet("OK"); @@ -1660,18 +1638,18 @@ static void handle_set_thread(GdbCmdContext *gdb_ct= x, void *user_ctx) } } =20 -static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_insert_bp(GArray *params, void *user_ctx) { int res; =20 - if (gdb_ctx->num_params !=3D 3) { + if (params->len !=3D 3) { put_packet("E22"); return; } =20 - res =3D gdb_breakpoint_insert(gdb_ctx->params[0].val_ul, - gdb_ctx->params[1].val_ull, - gdb_ctx->params[2].val_ull); + res =3D gdb_breakpoint_insert(get_param(params, 0)->val_ul, + get_param(params, 1)->val_ull, + get_param(params, 2)->val_ull); if (res >=3D 0) { put_packet("OK"); return; @@ -1683,18 +1661,18 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx= , void *user_ctx) put_packet("E22"); } =20 -static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_remove_bp(GArray *params, void *user_ctx) { int res; =20 - if (gdb_ctx->num_params !=3D 3) { + if (params->len !=3D 3) { put_packet("E22"); return; } =20 - res =3D gdb_breakpoint_remove(gdb_ctx->params[0].val_ul, - gdb_ctx->params[1].val_ull, - gdb_ctx->params[2].val_ull); + res =3D gdb_breakpoint_remove(get_param(params, 0)->val_ul, + get_param(params, 1)->val_ull, + get_param(params, 2)->val_ull); if (res >=3D 0) { put_packet("OK"); return; @@ -1717,7 +1695,7 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, = void *user_ctx) * the remote gdb to fallback to older methods. */ =20 -static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_set_reg(GArray *params, void *user_ctx) { int reg_size; =20 @@ -1726,19 +1704,19 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, = void *user_ctx) return; } =20 - if (gdb_ctx->num_params !=3D 2) { + if (params->len !=3D 2) { put_packet("E22"); return; } =20 - reg_size =3D strlen(gdb_ctx->params[1].data) / 2; - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[1].data, reg_size); + reg_size =3D strlen(get_param(params, 1)->data) / 2; + hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_size= ); gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->dat= a, - gdb_ctx->params[0].val_ull); + get_param(params, 0)->val_ull); put_packet("OK"); } =20 -static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_get_reg(GArray *params, void *user_ctx) { int reg_size; =20 @@ -1747,14 +1725,14 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, = void *user_ctx) return; } =20 - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E14"); return; } =20 reg_size =3D gdb_read_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf, - gdb_ctx->params[0].val_ull); + get_param(params, 0)->val_ull); if (!reg_size) { put_packet("E14"); return; @@ -1766,22 +1744,22 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, = void *user_ctx) put_strbuf(); } =20 -static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_write_mem(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params !=3D 3) { + if (params->len !=3D 3) { put_packet("E22"); return; } =20 /* hextomem() reads 2*len bytes */ - if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { + if (get_param(params, 1)->val_ull > strlen(get_param(params, 2)->data)= / 2) { put_packet("E22"); return; } =20 - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[2].data, - gdb_ctx->params[1].val_ull); - if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].v= al_ull, + hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, + get_param(params, 1)->val_ull); + if (target_memory_rw_debug(gdbserver_state.g_cpu, get_param(params, 0)= ->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, true)) { put_packet("E14"); @@ -1791,22 +1769,22 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx= , void *user_ctx) put_packet("OK"); } =20 -static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_read_mem(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params !=3D 2) { + if (params->len !=3D 2) { put_packet("E22"); return; } =20 /* memtohex() doubles the required space */ - if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { + if (get_param(params, 1)->val_ull > MAX_PACKET_LENGTH / 2) { put_packet("E22"); return; } =20 - g_byte_array_set_size(gdbserver_state.mem_buf, gdb_ctx->params[1].val_= ull); + g_byte_array_set_size(gdbserver_state.mem_buf, get_param(params, 1)->v= al_ull); =20 - if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].v= al_ull, + if (target_memory_rw_debug(gdbserver_state.g_cpu, get_param(params, 0)= ->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, false)) { put_packet("E14"); @@ -1818,19 +1796,19 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx,= void *user_ctx) put_strbuf(); } =20 -static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_write_all_regs(GArray *params, void *user_ctx) { target_ulong addr, len; uint8_t *registers; int reg_size; =20 - if (!gdb_ctx->num_params) { + if (!params->len) { return; } =20 cpu_synchronize_state(gdbserver_state.g_cpu); - len =3D strlen(gdb_ctx->params[0].data) / 2; - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + len =3D strlen(get_param(params, 0)->data) / 2; + hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); registers =3D gdbserver_state.mem_buf->data; for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len >= 0; addr++) { @@ -1841,7 +1819,7 @@ static void handle_write_all_regs(GdbCmdContext *gdb_= ctx, void *user_ctx) put_packet("OK"); } =20 -static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_read_all_regs(GArray *params, void *user_ctx) { target_ulong addr, len; =20 @@ -1859,14 +1837,14 @@ static void handle_read_all_regs(GdbCmdContext *gdb= _ctx, void *user_ctx) put_strbuf(); } =20 -static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_file_io(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params >=3D 1 && gdbserver_state.current_syscall_cb) { + if (params->len >=3D 1 && gdbserver_state.current_syscall_cb) { target_ulong ret, err; =20 - ret =3D (target_ulong)gdb_ctx->params[0].val_ull; - if (gdb_ctx->num_params >=3D 2) { - err =3D (target_ulong)gdb_ctx->params[1].val_ull; + ret =3D (target_ulong)get_param(params, 0)->val_ull; + if (params->len >=3D 2) { + err =3D (target_ulong)get_param(params, 1)->val_ull; } else { err =3D 0; } @@ -1874,7 +1852,7 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, vo= id *user_ctx) gdbserver_state.current_syscall_cb =3D NULL; } =20 - if (gdb_ctx->num_params >=3D 3 && gdb_ctx->params[2].opcode =3D=3D (ui= nt8_t)'C') { + if (params->len >=3D 3 && get_param(params, 2)->opcode =3D=3D (uint8_t= )'C') { put_packet("T02"); return; } @@ -1882,23 +1860,23 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, = void *user_ctx) gdb_continue(); } =20 -static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_step(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params) { - gdb_set_cpu_pc((target_ulong)gdb_ctx->params[0].val_ull); + if (params->len) { + gdb_set_cpu_pc((target_ulong)get_param(params, 0)->val_ull); } =20 cpu_single_step(gdbserver_state.c_cpu, get_sstep_flags()); gdb_continue(); } =20 -static void handle_backward(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_backward(GArray *params, void *user_ctx) { if (replay_mode !=3D REPLAY_MODE_PLAY) { put_packet("E22"); } - if (gdb_ctx->num_params =3D=3D 1) { - switch (gdb_ctx->params[0].opcode) { + if (params->len =3D=3D 1) { + switch (get_param(params, 0)->opcode) { case 's': if (replay_reverse_step()) { gdb_continue(); @@ -1920,20 +1898,20 @@ static void handle_backward(GdbCmdContext *gdb_ctx,= void *user_ctx) put_packet(""); } =20 -static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_cont_query(GArray *params, void *user_ctx) { put_packet("vCont;c;C;s;S"); } =20 -static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_cont(GArray *params, void *user_ctx) { int res; =20 - if (!gdb_ctx->num_params) { + if (!params->len) { return; } =20 - res =3D gdb_handle_vcont(gdb_ctx->params[0].data); + res =3D gdb_handle_vcont(get_param(params, 0)->data); if ((res =3D=3D -EINVAL) || (res =3D=3D -ERANGE)) { put_packet("E22"); } else if (res) { @@ -1941,17 +1919,17 @@ static void handle_v_cont(GdbCmdContext *gdb_ctx, v= oid *user_ctx) } } =20 -static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_attach(GArray *params, void *user_ctx) { GDBProcess *process; CPUState *cpu; =20 g_string_assign(gdbserver_state.str_buf, "E22"); - if (!gdb_ctx->num_params) { + if (!params->len) { goto cleanup; } =20 - process =3D gdb_get_process(gdb_ctx->params[0].val_ul); + process =3D gdb_get_process(get_param(params, 0)->val_ul); if (!process) { goto cleanup; } @@ -1972,7 +1950,7 @@ cleanup: put_strbuf(); } =20 -static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_kill(GArray *params, void *user_ctx) { /* Kill the target */ put_packet("OK"); @@ -2007,43 +1985,43 @@ static const GdbCmdParseEntry gdb_v_commands_table[= ] =3D { }, }; =20 -static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_commands(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } =20 - if (process_string_cmd(NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_v_commands_table, ARRAY_SIZE(gdb_v_commands_table))) { put_packet(""); } } =20 -static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user= _ctx) +static void handle_query_qemu_sstepbits(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "ENABLE=3D%x,NOIRQ=3D%x,NOTIM= ER=3D%x", SSTEP_ENABLE, SSTEP_NOIRQ, SSTEP_NOTIMER); put_strbuf(); } =20 -static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_set_qemu_sstep(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } =20 - sstep_flags =3D gdb_ctx->params[0].val_ul; + sstep_flags =3D get_param(params, 0)->val_ul; put_packet("OK"); } =20 -static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_qemu_sstep(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "0x%x", sstep_flags); put_strbuf(); } =20 -static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_curr_tid(GArray *params, void *user_ctx) { CPUState *cpu; GDBProcess *process; @@ -2060,7 +2038,7 @@ static void handle_query_curr_tid(GdbCmdContext *gdb_= ctx, void *user_ctx) put_strbuf(); } =20 -static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_threads(GArray *params, void *user_ctx) { if (!gdbserver_state.query_cpu) { put_packet("l"); @@ -2073,25 +2051,25 @@ static void handle_query_threads(GdbCmdContext *gdb= _ctx, void *user_ctx) gdbserver_state.query_cpu =3D gdb_next_attached_cpu(gdbserver_state.qu= ery_cpu); } =20 -static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_= ctx) +static void handle_query_first_threads(GArray *params, void *user_ctx) { gdbserver_state.query_cpu =3D gdb_first_attached_cpu(); - handle_query_threads(gdb_ctx, user_ctx); + handle_query_threads(params, user_ctx); } =20 -static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_c= tx) +static void handle_query_thread_extra(GArray *params, void *user_ctx) { g_autoptr(GString) rs =3D g_string_new(NULL); CPUState *cpu; =20 - if (!gdb_ctx->num_params || - gdb_ctx->params[0].thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { + if (!params->len || + get_param(params, 0)->thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { put_packet("E22"); return; } =20 - cpu =3D gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, - gdb_ctx->params[0].thread_id.tid); + cpu =3D gdb_get_cpu(get_param(params, 0)->thread_id.pid, + get_param(params, 0)->thread_id.tid); if (!cpu) { return; } @@ -2116,7 +2094,7 @@ static void handle_query_thread_extra(GdbCmdContext *= gdb_ctx, void *user_ctx) } =20 #ifdef CONFIG_USER_ONLY -static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_offsets(GArray *params, void *user_ctx) { TaskState *ts; =20 @@ -2131,17 +2109,17 @@ static void handle_query_offsets(GdbCmdContext *gdb= _ctx, void *user_ctx) put_strbuf(); } #else -static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_rcmd(GArray *params, void *user_ctx) { const guint8 zero =3D 0; int len; =20 - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } =20 - len =3D strlen(gdb_ctx->params[0].data); + len =3D strlen(get_param(params, 0)->data); if (len % 2) { put_packet("E01"); return; @@ -2149,7 +2127,7 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx,= void *user_ctx) =20 g_assert(gdbserver_state.mem_buf->len =3D=3D 0); len =3D len / 2; - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); qemu_chr_be_write(gdbserver_state.mon_chr, gdbserver_state.mem_buf->da= ta, gdbserver_state.mem_buf->len); @@ -2157,7 +2135,7 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx,= void *user_ctx) } #endif =20 -static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_supported(GArray *params, void *user_ctx) { CPUClass *cc; =20 @@ -2178,8 +2156,8 @@ static void handle_query_supported(GdbCmdContext *gdb= _ctx, void *user_ctx) } #endif =20 - if (gdb_ctx->num_params && - strstr(gdb_ctx->params[0].data, "multiprocess+")) { + if (params->len && + strstr(get_param(params, 0)->data, "multiprocess+")) { gdbserver_state.multiprocess =3D true; } =20 @@ -2187,7 +2165,7 @@ static void handle_query_supported(GdbCmdContext *gdb= _ctx, void *user_ctx) put_strbuf(); } =20 -static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_= ctx) +static void handle_query_xfer_features(GArray *params, void *user_ctx) { GDBProcess *process; CPUClass *cc; @@ -2195,7 +2173,7 @@ static void handle_query_xfer_features(GdbCmdContext = *gdb_ctx, void *user_ctx) const char *xml; const char *p; =20 - if (gdb_ctx->num_params < 3) { + if (params->len < 3) { put_packet("E22"); return; } @@ -2208,15 +2186,15 @@ static void handle_query_xfer_features(GdbCmdContex= t *gdb_ctx, void *user_ctx) } =20 gdb_has_xml =3D true; - p =3D gdb_ctx->params[0].data; + p =3D get_param(params, 0)->data; xml =3D get_feature_xml(p, &p, process); if (!xml) { put_packet("E00"); return; } =20 - addr =3D gdb_ctx->params[1].val_ul; - len =3D gdb_ctx->params[2].val_ul; + addr =3D get_param(params, 1)->val_ul; + len =3D get_param(params, 2)->val_ul; total_len =3D strlen(xml); if (addr > total_len) { put_packet("E00"); @@ -2240,18 +2218,18 @@ static void handle_query_xfer_features(GdbCmdContex= t *gdb_ctx, void *user_ctx) } =20 #if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) -static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_xfer_auxv(GArray *params, void *user_ctx) { TaskState *ts; unsigned long offset, len, saved_auxv, auxv_len; =20 - if (gdb_ctx->num_params < 2) { + if (params->len < 2) { put_packet("E22"); return; } =20 - offset =3D gdb_ctx->params[0].val_ul; - len =3D gdb_ctx->params[1].val_ul; + offset =3D get_param(params, 0)->val_ul; + len =3D get_param(params, 1)->val_ul; ts =3D gdbserver_state.c_cpu->opaque; saved_auxv =3D ts->info->saved_auxv; auxv_len =3D ts->info->auxv_len; @@ -2286,12 +2264,12 @@ static void handle_query_xfer_auxv(GdbCmdContext *g= db_ctx, void *user_ctx) } #endif =20 -static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_attached(GArray *params, void *user_ctx) { put_packet(GDB_ATTACHED); } =20 -static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user= _ctx) +static void handle_query_qemu_supported(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "sstepbits;sstep"); #ifndef CONFIG_USER_ONLY @@ -2301,21 +2279,21 @@ static void handle_query_qemu_supported(GdbCmdConte= xt *gdb_ctx, void *user_ctx) } =20 #ifndef CONFIG_USER_ONLY -static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, +static void handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); put_strbuf(); } =20 -static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *use= r_ctx) +static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } =20 - if (!gdb_ctx->params[0].val_ul) { + if (!get_param(params, 0)->val_ul) { phy_memory_mode =3D 0; } else { phy_memory_mode =3D 1; @@ -2438,45 +2416,45 @@ static const GdbCmdParseEntry gdb_gen_set_table[] = =3D { #endif }; =20 -static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_gen_query(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } =20 - if (!process_string_cmd(NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } =20 - if (process_string_cmd(NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_table, ARRAY_SIZE(gdb_gen_query_table))) { put_packet(""); } } =20 -static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_gen_set(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } =20 - if (!process_string_cmd(NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } =20 - if (process_string_cmd(NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { put_packet(""); } } =20 -static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_target_halt(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TR= AP); gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398671; cv=none; d=zohomail.com; s=zohoarc; b=l5hZT6TyorRGcgyT9CgoFg9vjA3CiOvJ3TDpYHuiLL8UJ/6s2glwVclvv4g/HBdZTgMUxtrjx3L9GhfweMhq0mmth+iE5SBtmWV9NvGmgKYPrmdq6iQra+gXNhfkEzypR/sbVJ49MwJV69UDW28UXJ4bUnV4PKR8LLpJIOcfZlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398671; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=YCw70biCZtmrujveEn0uP9uiPeh7MzcdOYuA3fJ6mTo=; b=lk8oSejcWu3DyBBpwU+3vcaOBFeIy7ftGlPxOqyoR8jAgHofCnrg3BtjGkuXpCcvY2cAHM1kWpmVCaceqZwImR3dhQ3ub2S9ahoLPqGzX1+J+Yzd/71J+lFFx7b4+tXMR3bB1y3dL5iMh5GLp32Ere6pj9ZOtPBoOLQai6wFgoU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398671746823.4415178481228; Fri, 7 May 2021 07:44:31 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-6mcHXfygOS6BcJ1jrwocRQ-1; Fri, 07 May 2021 10:44:26 -0400 Received: by mail-wr1-f69.google.com with SMTP id d20-20020adfc3d40000b029010e1a640bbfso3693262wrg.21 for ; Fri, 07 May 2021 07:44:26 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id l22sm12827268wmq.28.2021.05.07.07.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398670; 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=YCw70biCZtmrujveEn0uP9uiPeh7MzcdOYuA3fJ6mTo=; b=dLCZ8Cf4Nou+grFOV0xMy5kMiIJo0evSxjhCYQUH1BiHETUa8bkEbZ66b5SAMgEsy+51kN BLDauGKaF/pviSEW/XyC8IR6FtXlXruNqvUmESpvmxCKdntAPmbbM0b0u7rBx20PtppF3z ZfcrgHpRwd+qWouyA2Y3KxufrLczn94= X-MC-Unique: 6mcHXfygOS6BcJ1jrwocRQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YCw70biCZtmrujveEn0uP9uiPeh7MzcdOYuA3fJ6mTo=; b=E9MZHBad2jnf65wzJXP/X8LPeyohGBErLsL3fvJ2bTPxiwRWu8qHJv5MRaLcwuZXiu JzbQHsirhSf1v5jROLuwTtVXTuJxGq0qTT37enfQDtPOsSdgIfEXD2H408rB4CnXUDQ2 5uh0jQT2tBJSpDYXvZ0NYK1JEdjoMXGO2w99t5HYcUDVwL3/0fu8PX0coHyHrWpGaWMx sK55f8JFb+awQnf9IT1izVbUzMvoRfuHqQcHW+E5jj0AGZY21y501t+R8K4K8bdV/ipr 5BiZUh8UnmmYbIpicD/NPg2Ze5r9+1glwU0WSqAp/bOzdltmbud/MxTp2x6z7pbj3DfB OkhA== X-Gm-Message-State: AOAM530iyJvb4cGXw/VHKP9Tm207Oc5Eecf3U6LQ+DOkdVFQ5ta8J9UO KjYnPtNatVkMxRO6poXFXHRWqFytd+Ef/NaqJHz8Q4kgAClkW6z37CKQrJNHEJW9vhrK1plgCve /+INb9Bgbv8b9og== X-Received: by 2002:adf:eb82:: with SMTP id t2mr9296089wrn.337.1620398665153; Fri, 07 May 2021 07:44:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSRPyNjkkgTHtIXUz9NIoTTHnH7rmh5hjO3wk8/LS9dlME7+ZDoSyRfzMsFicSB1f9FbtI1A== X-Received: by 2002:adf:eb82:: with SMTP id t2mr9296078wrn.337.1620398665044; Fri, 07 May 2021 07:44:25 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Jeffery , Joel Stanley Subject: [PATCH v3 14/17] hw/misc/pca9552: Replace g_newa() by g_new() Date: Fri, 7 May 2021 16:43:12 +0200 Message-Id: <20210507144315.1994337-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead, replacing g_newa() by g_new(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/misc/pca9552.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c index b7686e27d7f..facf103cbfb 100644 --- a/hw/misc/pca9552.c +++ b/hw/misc/pca9552.c @@ -71,7 +71,7 @@ static void pca955x_display_pins_status(PCA955xState *s, return; } if (trace_event_get_state_backends(TRACE_PCA955X_GPIO_STATUS)) { - char *buf =3D g_newa(char, k->pin_count + 1); + g_autofree char *buf =3D g_new(char, k->pin_count + 1); =20 for (i =3D 0; i < k->pin_count; i++) { if (extract32(pins_status, i, 1)) { --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398674; cv=none; d=zohomail.com; s=zohoarc; b=i28YmyW96gWVCarafq8pVgYfLH9kgwJUNbGP/Zznvd+1Ie1lAU2FHJ0iDbpuD3XSzZvmJd4SHhtTDTY5nysrzQRnW630DBttCxhPMJ5BUuNeJ5npbm5wsH1A0cN3VHsRf2psHTAs0GddY6CveTcgkJQaGq6hqsKznbnxoM/+zKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398674; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=C+MYJWIsLohbCHlMSEIGcZQyDaEDuU9Kl0ow5213YNc=; b=dAIAflB/Ca/fiixo5I5ICNWXAocagfdGSydejrUKf1pOau5hucV2HwV/6I6SfR9EFSbRy6kV6Ph+IMpFeVIOw7RjwRCfsOALt3Ajno6YIAeMpR/2f0oSQt80oLwfD7XSVEcn2suzV3wFVsEgqIVQkdPfOPLShYr5T9BtwpaQUKg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398674151243.33781101969453; Fri, 7 May 2021 07:44:34 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-1DQMP748NHyBokZ4Pu5rng-1; Fri, 07 May 2021 10:44:31 -0400 Received: by mail-wr1-f70.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso3680750wrk.14 for ; Fri, 07 May 2021 07:44:31 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id r13sm8833726wrn.2.2021.05.07.07.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398672; 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=C+MYJWIsLohbCHlMSEIGcZQyDaEDuU9Kl0ow5213YNc=; b=NfUb/IMMZ15ZlLYpuzJQaGCRBYaJFx5IA74sPv2Fygnr0h/ipFqG2/osM+6EnDj16GbE6F 7PXBTQ0s9ZWDLAWla3OzRJo1dokMY5OlLj/VDPfepjuoUsTdZ9BdJiAdPdLBVjzPvmVvUW 26iVOIvToYAs2u/J+lxo57sSOgE1cuQ= X-MC-Unique: 1DQMP748NHyBokZ4Pu5rng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C+MYJWIsLohbCHlMSEIGcZQyDaEDuU9Kl0ow5213YNc=; b=PgvTFsjVyhgvxpmcIphWWt599ZE46FnwETjdnmQ5tZjEIuXTDG8xp0FDKJ4nxD0dxO EAadTnRGNprIcRAecJD74bpfXy0Cu2qEL8vfeBFX4zQ82JxB6qr99zafv3GqwnEb5/7n 2O2XuURlH5SvLkvXgs37m+gvhAHiSnjuCoCg9p8v1qxe1Re2ZCwHyIsfmiLqyqF8SdS4 hL8pnZStpF8pkmmX6zjS4kG2M74K9HH0qBPYsv8TQUlS7TSRuWfAX3fJvZvTd55eU6gV xapbgc92CC87lh/Sjf2mONoHjvFj8j67ZB2QSUsqccQHA+kDJ3wh7KkIK5hGWacE8RS6 nnjw== X-Gm-Message-State: AOAM532EtUxJA9fq7ik5WVNbzPAa0McuH6qTk3ukeJIiAhXPP8T/RtTO sELHIkpTWtjiP6FEduVYfZUgqY30hzdE8IP6GPnqMzODGaccMAlsmKg08iT9kz/d94QQp1w3XgM YTl8cU5BLETPZvw== X-Received: by 2002:adf:f80f:: with SMTP id s15mr12876023wrp.341.1620398670260; Fri, 07 May 2021 07:44:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV3LXdgDeT9W3nPy2PYFEyT0xnL/c2fIbnfgtcygElbhUWgwrD2nI+U4GtCxZ9QE5ZsaU17g== X-Received: by 2002:adf:f80f:: with SMTP id s15mr12876009wrp.341.1620398670157; Fri, 07 May 2021 07:44:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Greg Kurz , David Gibson , kvm@vger.kernel.org (open list:Overall KVM CPUs) Subject: [PATCH v3 15/17] target/ppc/kvm: Replace alloca() by g_malloc() Date: Fri, 7 May 2021 16:43:13 +0200 Message-Id: <20210507144315.1994337-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Use autofree heap allocation instead, replacing it by a g_malloc call. Reviewed-by: Greg Kurz Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/ppc/kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 104a308abb5..23c4ea377e8 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 bu= fsize, 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 **e= rrp) { - struct kvm_get_htab_header *buf; + g_autofree struct kvm_get_htab_header *buf =3D NULL; size_t chunksize =3D sizeof(*buf) + n_valid * HASH_PTE_SIZE_64; ssize_t rc; =20 - buf =3D alloca(chunksize); + buf =3D g_malloc(chunksize); buf->index =3D index; buf->n_valid =3D n_valid; buf->n_invalid =3D n_invalid; --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398679; cv=none; d=zohomail.com; s=zohoarc; b=e1Scg2CYFIeVjUmDfdAendc1WlGYTrAhCro1ckevsxHUGLyb21drBAUgCXEyKfUIIf6u285RWfbUYfToK6Mb4Vy/TYdDSw9qcIHuUkWzGBOY+IGzbWSqL737u6qyDf+yBeFbyanXVok5npO4qHafkCMtsSG/yTyX1VVzKxQ9vGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398679; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ZhnR5sl6IQkPWyz310rG2u37bBKdYZca+FWR4sH4smk=; b=itL/PRyQP77M3MemLV3bF96q3zU2blXL7ASYayerpET7CHoM/iuPZjhoFtEikd+bLrIw2ZV6m4eMLuRAcMpWuIOBL8VtjA9Y5BAAsTrxjrHAM2qLXZWnYPzu0NYvWiJePVITNHR5+NZC3tgC4IzOxFC6jmZGlRnWr1Bq+/E7tm8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398679457699.532876491135; Fri, 7 May 2021 07:44:39 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-V0OYhUf-PFWJmyJv_oOxgw-1; Fri, 07 May 2021 10:44:36 -0400 Received: by mail-wm1-f71.google.com with SMTP id z9-20020a1c65090000b029014b497b2d98so1458490wmb.8 for ; Fri, 07 May 2021 07:44:36 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id v21sm13520162wml.5.2021.05.07.07.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398678; 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=ZhnR5sl6IQkPWyz310rG2u37bBKdYZca+FWR4sH4smk=; b=hZlCG4MOC8W4RsqFNbKAgaTKXS7QvUpEV528FYKFPpsLXg/eN0neCCi2UnCluoBSoKGE1E grvwSvIJ+WiBcRe0hmwVUgk1jb+oHR3MEyc4cy6Zjq8h6Kw+8NAcSFY88SrdCuHLXAGm9C CL7qER2tyQUbFwyKQHYX8QWU3DoQYlA= X-MC-Unique: V0OYhUf-PFWJmyJv_oOxgw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZhnR5sl6IQkPWyz310rG2u37bBKdYZca+FWR4sH4smk=; b=e78pMAifsOm89XRd1cQ/N1wKlvvzcUAfX7QJTpLwN0X4Nh3yqcq4lE2IJVGHDM8jCa TcEoHrmVi7wb+wJceU12VLoIcw26/KoqfMPgOJrMFOUPVaUwb6jlr9UK46oQx+bufDrZ tlT8q8jJxCHQcZ6jE44pk37DCpSJrL1IPC3EIsKcERMj/MbCQiSWxARixRfKLWC3Ntn6 ccVNyfqBWFYzbqZ8m/spJFyTZZKMdH57ToDHAMJ79Q/eBA+ZpKK5+4v38ygolgpZ4jS/ ZvpAHOhAnLqmoGRVwxib8IWvzB8PjrzZPhsSzOxQAytH5ZW358v4eLsgi2QT0aYAr3uO nNhg== X-Gm-Message-State: AOAM533FnUp2u7hYu67jE0H6bwWlVIzq1SM4KISe0vZLl6wupKt2s+Zx /qCbhl1DzHhh0xmQ9vnW4ZPnR5rgIy6rsIgcMNuFERoJRvIi2aXm08C0lRo/9oQln3/Lg71Srf8 zNVRw04MOeg9USw== X-Received: by 2002:a5d:6981:: with SMTP id g1mr12599753wru.426.1620398675119; Fri, 07 May 2021 07:44:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy8lnmrGYH8Fsy8pQZm8qEaMhZejrbeQOUztL4n5JHO8452/CrhiGGEhSj68CBg7KRdDUmFg== X-Received: by 2002:a5d:6981:: with SMTP id g1mr12599729wru.426.1620398674953; Fri, 07 May 2021 07:44:34 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 16/17] configure: Prohibit alloca() by using -Walloca CPPFLAG Date: Fri, 7 May 2021 16:43:14 +0200 Message-Id: <20210507144315.1994337-17-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Now that we removed all alloca() calls in the repository, add the -Walloca CPPFLAG to trigger a build failure if such stack allocation is used. Rationale: The ALLOCA(3) man-page mentions its "use is discouraged". Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- As there is an alloca() call in libslirp, this patch is pending on the following libslirp patch to be merged: https://lists.freedesktop.org/archives/slirp/2021-May/000150.html (and the submodule updated). --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 4f374b48890..67cb6d5421c 100755 --- a/configure +++ b/configure @@ -552,7 +552,7 @@ ARFLAGS=3D"${ARFLAGS-rv}" # provides these semantics.) QEMU_CFLAGS=3D"-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS" QEMU_CFLAGS=3D"-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" -QEMU_CFLAGS=3D"-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" +QEMU_CFLAGS=3D"-Wstrict-prototypes -Wredundant-decls -Walloca $QEMU_CFLAGS" QEMU_CFLAGS=3D"-D_GNU_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_LARGEFILE_SOURCE = $QEMU_CFLAGS" =20 # Flags that are needed during configure but later taken care of by Meson --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398683; cv=none; d=zohomail.com; s=zohoarc; b=UxKtVa3zGFn7vzEBYekuBLK1fHeD91o8A5Tlt6wWmPfMUbUTDyc13yvCpyfL/ReEUhjD1v2PPJdP+FEhytn/GDyfYP0t0DCxC4mwN9g4C85Pe0aGPaQ3P1qkG/p7Mp67Y2vopG6aKRgwktldZ0lvgmdHFIoSQt9MsCiWjQQF4v8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398683; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=3LzYOi9y3/bAg2bf530/ErMOAU+nSy3193hDlzyrvOQ=; b=N4W7PuwVVNDRTExwuJYrtbEQ1zVtZqMOjLE0FmyL7+dMmSnUwhc5i/XVS27mwyFIOkFfQ2iT4y3A5ixw2cyGQwXr77TRiPIHkRjwFzVYuSKL1mt87VKczwMJnrG1L4THAw/tkryRRwvR826ipssCoDjOW9KcbJtiNu9QliIqlQ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398683912147.38339787616292; Fri, 7 May 2021 07:44:43 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-d1c2osf9MUqG495Q3hlwgw-1; Fri, 07 May 2021 10:44:41 -0400 Received: by mail-wr1-f72.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso3680933wrk.14 for ; Fri, 07 May 2021 07:44:40 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id a9sm7223387wmj.1.2021.05.07.07.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398682; 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=3LzYOi9y3/bAg2bf530/ErMOAU+nSy3193hDlzyrvOQ=; b=T+CYQsN0PkVXYgqaHMxK+gvJwsXsfdqrvJ3vKUt9/VapK8iwtF79BIOtBjD2Q5anSizQeS 3bGbj5ByttxYMzDMKWm2DfITFKpj0rnJ3PKOkmmT7uIFMa743XXfaYE+8lUZp9CznJiAOn 19jK9C7W+H9J8lc0vgtMm68Fr+btBC4= X-MC-Unique: d1c2osf9MUqG495Q3hlwgw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3LzYOi9y3/bAg2bf530/ErMOAU+nSy3193hDlzyrvOQ=; b=jgz8Jcpld09TEdMNxe7fw58q4IE7gXHBKFi4pxmtG2Pvw1cWJZIg0ChfvyTNjYpU6D LGsxY4ienvCya4eBK4A4TLCTyZUZwqG8w4I30oGW20HYmHCsj/+53D2rkZV+ChVfrxrY QtxiZLsNjrBZw4+vcz2lxjmdt/J28/uH8J6R8iAlhQgij9RitH2iw9TP9hozflNSwv1q YEfYGnpPij44iJ6exB2kdXsmI0xty5S7xz5PRnzmSjHdQ9lEAK4Oa3dxvYJNGpRoj9Pv FlKsx+ww1BJy7A3x/rJpeqCzWU7H/iQY2991k6SJNbYPe7+xSB1eDTbpjki/7vSQiTpU /KNA== X-Gm-Message-State: AOAM533bxK22+77eh603VeH/N88tSy4g9EMwR7IKUsEsxnH0FlA/Tof9 vG6/mbFFYW1NCuU8Bm9wfqnxyc0k4AO3C39tGHPYMEMGnMr2Xsd2JMyckwvAJS0Z5lRiQ297pPs mOjy8JekbiYHjvw== X-Received: by 2002:a05:6000:144:: with SMTP id r4mr12809716wrx.128.1620398679874; Fri, 07 May 2021 07:44:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqPj6e70tDk+0Kapo/Q8l2xehNQRZ54fEglCYWvPkgmcAvqV1wQP9ylia+jNgLIxhdTdu4Bw== X-Received: by 2002:a05:6000:144:: with SMTP id r4mr12809703wrx.128.1620398679711; Fri, 07 May 2021 07:44:39 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [NOTFORMERGE PATCH v3 17/17] configure: libSLiRP buildsys kludge Date: Fri, 7 May 2021 16:43:15 +0200 Message-Id: <20210507144315.1994337-18-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Only enable -Walloca when libSLiRP is not built. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- configure | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 67cb6d5421c..ab5b6248253 100755 --- a/configure +++ b/configure @@ -552,7 +552,7 @@ ARFLAGS=3D"${ARFLAGS-rv}" # provides these semantics.) QEMU_CFLAGS=3D"-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS" QEMU_CFLAGS=3D"-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" -QEMU_CFLAGS=3D"-Wstrict-prototypes -Wredundant-decls -Walloca $QEMU_CFLAGS" +QEMU_CFLAGS=3D"-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" QEMU_CFLAGS=3D"-D_GNU_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_LARGEFILE_SOURCE = $QEMU_CFLAGS" =20 # Flags that are needed during configure but later taken care of by Meson @@ -5255,6 +5255,14 @@ case "$slirp" in ;; esac =20 +# Kludge pending an alloca() call removed from libSLiRP, see: +# https://lists.freedesktop.org/archives/slirp/2021-May/000150.html +case "$slirp" in + internal | disabled) + QEMU_CFLAGS=3D"-Walloca $QEMU_CFLAGS" + ;; +esac + ########################################## # check for usable __NR_keyctl syscall =20 --=20 2.26.3 From nobody Sun May 19 05:00:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620408002; cv=none; d=zohomail.com; s=zohoarc; b=CzTXFNFOkI2vlPLQaGkXq9GLaXsIjMCGj9nleU8WpZX9FCqVn1t6psjG12mxsmM1QSXz1XF7YKFehYJ6yeGwQoIDi6+QODrenos4D2nnWOJAI6qcF2555fH2jyLWG0WpBSPf2T3ga9cwZXjCfx9chteFuWczOKAKO8c8pOJzHfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620408002; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject; bh=wOFcyNIJjuiw01s2VBdGQ50UDrGE+IFT929JvHJBSgU=; b=JWvBISWgR20Kf0etkkE0cePY7SAtJXmZB2wmXg5MDaE8VQseYvsWKWEokPgbdfM/PnxM87PFRyDCD3Z6tgzUI5e92TETigAKxRWnBd/7i7VFpmImHYAWY/0EpVGqqsmPIA79bbsIQ6UsLtMf9PhUnwbVPVuCqySyBs2WFToaMMc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620408002209634.7481052426884; Fri, 7 May 2021 10:20:02 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-pioI9-lDOTmyPI8CkwuZ7w-1; Fri, 07 May 2021 13:19:58 -0400 Received: by mail-wr1-f70.google.com with SMTP id n2-20020adfb7420000b029010e47b59f31so1188320wre.9 for ; Fri, 07 May 2021 10:19:58 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id z14sm10304337wrt.54.2021.05.07.10.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 10:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620408001; 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=wOFcyNIJjuiw01s2VBdGQ50UDrGE+IFT929JvHJBSgU=; b=EFhK/NrqSFg2NQ2sAuH3NNiSqcoYRQJDyLqWMR1X9RRBsM0s4YcWO9WsZ09/B6+fGugw5Y 62ouA/bi01VR7/JhYDuUg0QwVHVfxBgNnZiW15e6zfeY83W/DCsX+3ntStt8YlVMB6GFIJ hZ7fw6tvd1RprX7S/FW4OWmpvuucsuc= X-MC-Unique: pioI9-lDOTmyPI8CkwuZ7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wOFcyNIJjuiw01s2VBdGQ50UDrGE+IFT929JvHJBSgU=; b=B1Wm721wh5a8OxG5BKCT3WBg6SA8xorjzo0tISQZjy0M6AO6sgD7TTI9hAOzimraPk SK60hqX7ewl9SInG0aLn1CdqrwwZIEoJrsHnmgyhboYhCZTmv5fDEXuveuo2hmxIHFab o/zAX0tz+HcWTQlBgsSmX/33rav1QykA2ZU991OKUHe0zK/Djp1N1NXwDAqgJPMGynUL lRWSrB4VvCbq59pl1x6JrwmdytsBCiaU/OPngi9LYhMIOM72qZc2NGNUWeVCi8judMLW zhSL93we+9oqK2EIfsH1stH8BkUaw6VcKI6kzYWdwYRwKG3pLw4bQqgsvc1lPkXZjADj bwpg== X-Gm-Message-State: AOAM531HN7ZFyP5MOi2XYjC0+TZOsrhOaIFwVuf7JqVBGbnzOCGhMUMP QIirltIPCzQbMGgxUlF8QUz9+bapxK+MmNgIvwRqxldmtR3u9b54F5OyB+4j8gDgkIjDOyUhqiG 4mE11v9T2IpP7Kw== X-Received: by 2002:a05:6000:508:: with SMTP id a8mr13680521wrf.315.1620407997131; Fri, 07 May 2021 10:19:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwg84xHcRqOfwXcWS/7YUAZoCtC8jV/rXCCK4OED+w2zkmovp5Als6sBpwh/F9cPaEN8+yiqQ== X-Received: by 2002:a05:6000:508:: with SMTP id a8mr13680500wrf.315.1620407996964; Fri, 07 May 2021 10:19:56 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth , Paolo Bonzini , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 18/17] tests/unit/test-char: Replace g_alloca() by buffer on the stack Date: Fri, 7 May 2021 19:19:48 +0200 Message-Id: <20210507171948.2062076-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Directly reserve the CharBackend on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-char.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c index 5b3b48ebacd..54ce26226b3 100644 --- a/tests/unit/test-char.c +++ b/tests/unit/test-char.c @@ -574,7 +574,7 @@ static void char_udp_test_internal(Chardev *reuse_chr, = int sock) struct sockaddr_in other; SocketIdleData d =3D { 0, }; Chardev *chr; - CharBackend *be; + CharBackend tmpbe, *be =3D &tmpbe; socklen_t alen =3D sizeof(other); int ret; char buf[10]; @@ -590,7 +590,6 @@ static void char_udp_test_internal(Chardev *reuse_chr, = int sock) chr =3D qemu_chr_new("client", tmp, NULL); g_assert_nonnull(chr); =20 - be =3D g_alloca(sizeof(CharBackend)); qemu_chr_fe_init(be, chr, &error_abort); } =20 --=20 2.26.3