Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp540358lqh; Fri, 31 May 2024 08:51:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRFTvpebyuaYo12+UZxyVUQYS4DN/qPRfR5iIDOfIticz0w2VpRWgL7KR3XK5JUz0WZ+KpW1CVwk2EUK+DXBSkRSbonDWViBbVeL0NMA== X-Google-Smtp-Source: AGHT+IGL6rdeyVjhXirPWO0kijQqTJdxxiNe9D8Ii7OekW4EU5aT/p813rq9Jk6FEqM8alMWJCAY X-Received: by 2002:a05:6512:250a:b0:52b:8728:5ea6 with SMTP id 2adb3069b0e04-52b89596257mr2149277e87.19.1717170661467; Fri, 31 May 2024 08:51:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717170661; cv=pass; d=google.com; s=arc-20160816; b=tOITYu05n1VAt/CDxo6JsPuYVa4um2bKRZ3wpjZLXVzNJ+4X+PRqfy06mQf8eG3G74 huaS2iEEUzMyxiJ3yHh7nvh3icuCrUv6vgduZctkS0I9x5fFW0jXvMhnuU70VJgQGa7G ttwuqsJilBwjvT37nCE7TMNF4X+Ipys8/Sl2ZscQrGChGgyfzUeMJrNxmRWFUYxgnabJ sdPv07ocsAhCgMWaC7rcybi5/HEYcWZJ5etJXcxpG6LDSVTCa0bXEViyIMytOHgSOL67 VtIQiBxCUqPKh86Y1KHKUg0rs1Vrwu4YDPgrEfptKfnJgBrA0CpbXNL4twaoWaoNp0vz WzJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:to :from:subject:message-id; bh=dm7LCak2ENbNoHqSKKlzS9XA+R0IAaeh/Ajhn24Eu5Q=; fh=fKx/RiJn31jKmxWIp3WB5oWkJsUZpN3UPLKNJtAF21o=; b=AdRJWCK9TUh47f22FYub3pkg4ofjs+JPVc9WSISE1P2pN/TbO1RoOPdV65laWQ2OUD yqzstasetdFSd0gypj8UuufD9caCW6+bjv5pWtWWmFRGVcdHND5hKO4gRAUVnGD9aH3/ ydKA9E/utLCJucJINDxAQhLtv9JmmUKIYr5GWmjHwZ+MiR5n3X0ZNIlxXG/bcfasqrX1 6+X6GSs44o8GNO1SSlQR8pJvb4QvHcODKRJ4AOAerRiZ8EdnjNr1G8XvL+RK52XOCcdO dxwhhyOr74z166UnJc7zwhe7iJ0YqWaXGxFW0JVjvaW3TICaALIw40qxvK2JlT1Plnpq Bk6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-5052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5052-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c62e23si1098018a12.275.2024.05.31.08.51.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 08:51:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-5052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-5052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5052-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1EF081F25CAE for ; Fri, 31 May 2024 15:51:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1ABA2158DD5; Fri, 31 May 2024 15:50:45 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A4C215887C for ; Fri, 31 May 2024 15:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717170644; cv=none; b=n6O7e+xSyi+qWJvJKPAjCM/w9nmta4ppzxnjT8EWVYpONrEjYvBnNBgK3f20zEATzTFeKYinlSwjajMFU0U2iQeLEtPY5XXcM0tcG/C/ssz7EZyR+2oClXWw9Na3j2k3s9bjKxm0B5O1VnqBmOWUoNzG5laPQ1h3t6waOY86be8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717170644; c=relaxed/simple; bh=M2vWxMddQ8y3W+TJWkQ04/VxT9aKSlpNx5Mtqncq3hk=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=B8BESdgvVFv3jxaNLY+QF3NoPQDNlyBBgycDx8VaXJDqbl1f6XJCQXivdqLtuo16p4hMzP6oL+48kiofBW8cpTdJTA13dj6ApwHlsQXs6TVnxpdgLHFdLcByVOAPSE/XmeBdBbcUWwny3vuNEeTbhNOYLICuE45BqNiaVO+WS2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 018691C0005; Fri, 31 May 2024 15:50:33 +0000 (UTC) Message-ID: <727c93065d8d1e56e9fcd5b5bed724d63dfbe871.camel@hadess.net> Subject: Re: [BlueZ 9/9] avdtp: Fix manipulating struct as an array From: Bastien Nocera To: Pauli Virtanen , linux-bluetooth@vger.kernel.org Date: Fri, 31 May 2024 17:50:33 +0200 In-Reply-To: <8c979897beeb8316616bb7c15f60093be177577c.camel@iki.fi> References: <20240530150057.444585-1-hadess@hadess.net> <20240530150057.444585-10-hadess@hadess.net> <8c979897beeb8316616bb7c15f60093be177577c.camel@iki.fi> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net On Thu, 2024-05-30 at 19:57 +0300, Pauli Virtanen wrote: > Hi, >=20 > to, 2024-05-30 kello 16:58 +0200, Bastien Nocera kirjoitti: > > Don't manipulate the "req" structs as if they were flat arrays, > > static > > analysis and humans are both equally confused by this kind of > > usage. >=20 > struct start_req { > union { > struct seid required[1]; > struct seid seids[0]; > }; > } __attribute__ ((packed)); >=20 > and access only via req->seids? That's a good idea, I'll give it a try. > > > +#define > > REQ_GET_NTH_SEID(x) \ > > + static struct seid > > * \ > > + x##_req_get_nth_seid(struct x##_req *req, int count, int > > i) \ > > + { =09 > > \ > > + if (count =3D=3D 0 || i >=3D > > count) \ > > + return > > NULL; \ > > + if (i =3D=3D > > 1) \ > > + return &req- > > >first_seid; \ > > + return &req- > > >other_seids[i]; \ >=20 > (i =3D=3D 0) and [i - 1]? *facepalm* Yes, this will need a v2, thanks for spotting that.