Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5769202ybe; Tue, 17 Sep 2019 13:12:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwEdf9vWJnIB9q5Bg2cVzOIRKbFqapdH0ihii0kRtXKbsWe1KDfRfo+fNbc34aT1Hk3LLa X-Received: by 2002:aa7:c415:: with SMTP id j21mr6418245edq.282.1568751150454; Tue, 17 Sep 2019 13:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568751150; cv=none; d=google.com; s=arc-20160816; b=W5LwrPXoHYp/YtVrupGFw3f8qumoNgIKyobJJ5qEIYsbWsWxmwl2ZG9vywIU7tTxCr l5v75/yzJ2ZoZifejxXKsOSdbvIEEFrDYg6BH7Z7NbD6ya8Aq4nG2y2Xh4v6Y9j2JIDg N7SKoTGkLBoOSBzUfsQYUOye8rl+mEIODcBybRfwAkrs52KP63kYwnsYr7zevwIshJH6 dY3i+10XMfMhmcpGSc2rSSACmKJ3UxaH9v9V/4RCpxvh7EqLhH533oZcyaJvHnVVnbOB GnkODt25MRDowzOQYMGiqoyVeeCoHeKTwcmbHCTcxb/G1nnVPOVB35D7E5I1Q0wqafk5 LArg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=uoV0qQarNAvVccd8xG89o/dvGuIV6V/5mng6hrXumUg=; b=a37fR/8oJEQdAlqCGE8rsZDK3yj8GLlyohHVayiFq6LAm5cMrzIXfXEky2xK8c+1do d8mk3UTMsWDqPku2xtjoMh2CiCj5qJSsBBMGeJ9o2Oj+8GSW+bSnmPUd7ZWSuLHrTUII GVmVWZod2dd2E1OrH/NTAXxo8t0B/8eLE3xGqMo5G5fdO02NdJMZMWLby7OLXoVi39gz uEi/6NOlMNFk9gPfsEbeJcJtcGB8mSRDVG6yMttTirNoeR7XEh3CLelycZ+AMDoZNNrt BBGb1mnZBYLFBSwiE41XSANvzcSmrdUwBa3SwuXICEA8VATxVPMZIQpxzVX8LSDi6sgf cX5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si1613864ejt.345.2019.09.17.13.12.06; Tue, 17 Sep 2019 13:12:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727970AbfIQTnC (ORCPT + 99 others); Tue, 17 Sep 2019 15:43:02 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43998 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfIQTnC (ORCPT ); Tue, 17 Sep 2019 15:43:02 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id 370E928A568 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: corbet@lwn.net, kernel@collabora.com, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH 0/2] kernel-doc: fix bug and improve dump_struct Date: Tue, 17 Sep 2019 16:41:44 -0300 Message-Id: <20190917194146.35642-1-andrealmeid@collabora.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This patch series improves kernel-doc script at dump_struct() subroutine by solving a bug and by making the parser more complete. The current way that scripts/kernel-doc dump structs do not work for nested structs with attributes (e.g. __packed) and without type alias (e.g } alias1;). This is due to the way nested structs members are parsed. Inside dump_struct(), the regex removes attributes and it surrounds whitespaces. After that, it will do a foreach(id) loop for each alias. However, we will have an empty string, and then the split function will return nothing and the foreach will not have any iteration. The code will then jump the loop and the substitution will fail since $newmember is uninitialized. This bug does not happen when the nested struct has no alias and no attribute, since at process_proto_type() a whitespace is inserted in order to ensure that the split will not fail. However, with any attribute, this whitespace will be removed. This patch solves this by replacing attributes with one whitespace, to ensure that will have at least one whitespace. Besides solving this bug at patch 1, I also add support for the ____cacheline_aligned_in_smp atribute at patch 2. For testing and reproducing, create a file `code.h`: /** * struct foobar - description * @number0: desc0 * @number1: desc1 * @number2: desc2 */ struct foo { int number0; struct { int number1; } __packed; struct { int number2; }; }; I've tested with CRYPTO_MINALIGN_ATTR, __attribute__((__aligned__(8))) and __aligned() as well. Now, run the `./script/kernel-doc code.h`, and this is the output: Use of uninitialized value $newmember in substitution (s///) at ./scripts/kernel-doc line 1152, line 18. .. c:type:: struct foo description **Definition** :: struct foo { int number0; struct { int number1; }; struct { int number2; }; }; **Members** ``number0`` desc0 ``{unnamed_struct}`` anonymous ``number2`` desc2 The output will not display the member number1 and will also display an uninitialized warning. Running after the patch will get rid of the warning and also display the description for number1: [...] **Members** ``number0`` desc0 ``{unnamed_struct}`` anonymous ``number1`` desc1 ``{unnamed_struct}`` anonymous ``number2`` desc2 To test patch [2/2], just replace __packed for ____cacheline_aligned_in_smp and compare how, at the previous stage the script believes ____cacheline... is an alias for the struct and after the patch it is removed just as the others attributes. Finally, I have compared the output of "make htmldocs" with and without this patch. No new warning were found and one warning regarding ____cacheline_aligned_in_smp at include/linux/netdevice.h was removed. Thanks, André André Almeida (2): kernel-doc: fix processing nested structs with attributes kernel-doc: add support for ____cacheline_aligned_in_smp attribute scripts/kernel-doc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.23.0