Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp36009rdb; Tue, 16 Jan 2024 14:08:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWmcT9ouc9gt28ectZX59Qt5pSHNsHlzjDRymYaP4efIxNd9CUPTpHV2aKWsDV+PbSX8Dr X-Received: by 2002:ac8:59c4:0:b0:429:f3ba:c2ae with SMTP id f4-20020ac859c4000000b00429f3bac2aemr3709289qtf.113.1705442914139; Tue, 16 Jan 2024 14:08:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705442914; cv=pass; d=google.com; s=arc-20160816; b=JYxoLSUDy0lWz7kdLB8njgMQlr7CjqdQLAOCHcaU/TMrPj2M7ebMiPV5rjUliuA0fv Am3DNn+BeVAquyTDgGohbG4/6rT5RH+pKk6Yssp53wbqv96l+Vx5HIkNzn+GmU87Wnt+ HkDtecOe4a7Ev6BXrJKV5XTaR5jfgl6HEFjBmhTU8yI9NUnrmX8mUxOTU29E3JZnNMLU JmOmkNdhvL5U8FFBIiKU+9qi981pI9h+LvZqpBdLY7dLHD7wBcV6RN9YUKREjXY07HBo IODk6AR4EGmqkfwekHI6CX3uwzWmJSmSI+J1u1c+yzed577t5xGil7CRGZ/3OReyN140 vcRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=JlXxa+REQIexDrRW4yBiDLMqrYcczWW8WMc9ny/URBQ=; fh=Sfr09o0MQ6sYIUKlJOkg97Xm5QDd3eQpfy8Zxqt1ZYg=; b=dfYkM6nYPwq+TgTR+xbaokCa96U9qrKXkMxmls8iZN0GeOFPLiyIt8TeEpfcaKOQib V7X+wZieLfyV5EXRU8Z11PUj7ojbfLg1GYID39Kgj6Qw4n2dx5pA71MkhKtWEAdHb21c t4EOlu6iAOJrDlFuOKGv65EuOgKL9I0OHri8yv4EHGtFNsTGPlEVyLTFRIlsuQ83dwgA Oc96xg7FQxOg0KIBbpn537knnSFzsQO6z6pqSm3JnoWDZFrs+1Cl9c+/gIRYU3lq7t2u cZtccHGegTTBsbR7uFu4a09r9HZZr+Vkpx5oBL0t0vkbscqjXymiXCNBmh/OokFgGSB2 ssMA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-28234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28234-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b14-20020ac85bce000000b0042a09b30b04si1201911qtb.701.2024.01.16.14.08.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 14:08:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-28234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28234-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A82E51C27297 for ; Tue, 16 Jan 2024 22:08:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A48620DC1; Tue, 16 Jan 2024 20:08:37 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2551720B20 for ; Tue, 16 Jan 2024 20:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435717; cv=none; b=reXDM/d4YP3yWACdhJGKxX50UaxD8CCBBYEcRyRrKCZ0XX6PnjhLH9hVAr5yy6f0RiH7OVrQjEIV3YzN465AZVnrjtue9bRWlcALa+GVEMZxvAtHr6qRTr4wdkY1ilvEb+fYOM0qVKGJ7R+tBM3/31n8JI33FOUOu+6pyY8+FeE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435717; c=relaxed/simple; bh=+f92y93G1zWOtlpq6n0Sr2dabG7AgxMgV9bKCPRbafk=; h=Received:Date:From:To:Cc:Subject:Message-ID:In-Reply-To: References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; b=mLSFLdWIGa/XIjgcnw//OQpp2ONXWcT3lUt66A+62dGIVic/s2kprES9RBksFhaFmj6U9xxyntCYmb3FAeqN0g9Gfjznucw/PKpAgVlttlBKyOHnQ3jioJ9wOwXvg60fcBWbkJBJ+gM8IHg1VKNn1RuKsBg1rOn15yrPFc6zCIc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EE48C433F1; Tue, 16 Jan 2024 20:08:35 +0000 (UTC) Date: Tue, 16 Jan 2024 15:09:50 -0500 From: Steven Rostedt To: Christophe JAILLET Cc: nathanl@linux.ibm.com, Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [PATCH] seq_buf: make DECLARE_SEQ_BUF() usable Message-ID: <20240116150950.5f444a04@gandalf.local.home> In-Reply-To: <407c467e-1f0b-4549-951a-83c295b27733@wanadoo.fr> References: <20240116-declare-seq-buf-fix-v1-1-915db4692f32@linux.ibm.com> <407c467e-1f0b-4549-951a-83c295b27733@wanadoo.fr> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 16 Jan 2024 20:40:29 +0100 Christophe JAILLET wrote: > Le 16/01/2024 =C3=A0 15:09, Nathan Lynch via B4 Relay a =C3=A9crit=C2=A0: > > From: Nathan Lynch > >=20 > > Using the address operator on the array doesn't work: > >=20 > > /include/linux/seq_buf.h:27:27: error: initialization of =E2=80=98char = *=E2=80=99 > > from incompatible pointer type =E2=80=98char (*)[128]=E2=80=99 > > [-Werror=3Dincompatible-pointer-types] > > 27 | .buffer =3D &__ ## NAME ## _buffer, \ > > | ^ > >=20 > > Apart from fixing that, we can improve DECLARE_SEQ_BUF() by using a > > compound literal to define the buffer array without attaching a name > > to it. This makes the macro a single statement, allowing constructs > > such as: > >=20 > > static DECLARE_SEQ_BUF(my_seq_buf, MYSB_SIZE); > >=20 > > to work as intended. > >=20 > > Signed-off-by: Nathan Lynch > > Fixes: dcc4e5728eea ("seq_buf: Introduce DECLARE_SEQ_BUF and seq_buf_st= r()") > > --- > > include/linux/seq_buf.h | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > >=20 > > diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h > > index 5fb1f12c33f9..c44f4b47b945 100644 > > --- a/include/linux/seq_buf.h > > +++ b/include/linux/seq_buf.h > > @@ -22,9 +22,8 @@ struct seq_buf { > > }; > > =20 > > #define DECLARE_SEQ_BUF(NAME, SIZE) \ > > - char __ ## NAME ## _buffer[SIZE] =3D ""; \ > > struct seq_buf NAME =3D { \ > > - .buffer =3D &__ ## NAME ## _buffer, \ > > + .buffer =3D (char[SIZE]) { 0 }, \ > > .size =3D SIZE, \ > > } =20 >=20 > Hi, >=20 > just removing the & in ".buffer =3D __ ## NAME ## _buffer, \" also works = IIRC. >=20 > See [1], which unfortunately has been unnoticed. >=20 > CJ >=20 >=20 > [1]:=20 > https://lore.kernel.org/all/2a534333-b5f6-4b1d-b4b8-a1a71f91c3ff@wanadoo.= fr/ I guess I missed that. But it still doesn't fix this case: static DECLARE_SEQ_BUF(my_seq_buf, MYSB_SIZE); Which this patch does. -- Steve