Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5771285ybe; Tue, 17 Sep 2019 13:14:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlH2IJy0Z+RxXukcxKpTdXdht46jp6PDOposnZ2xh3gUB8SIM7bN6x28/wvNPbvVnG0HWN X-Received: by 2002:a17:906:6084:: with SMTP id t4mr6290183ejj.164.1568751283124; Tue, 17 Sep 2019 13:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568751283; cv=none; d=google.com; s=arc-20160816; b=evzB4V+S+einkEw/PcJUfU7eAeMODnJS4AaetLq5fsedCskJuLvcuPB7zCk9pD/9eZ 4bt5Ky0/FHVvZGTm5cxw5cakQkC9fZJez4TN8HdBKCANxU1nRGDwVeKkLYWwDyJ4LQat U9BQWJ2rglCh/05HwjzXnYdf0Tph51TTGCe9lAFOB+KRtCtxZc67gLXtyt78OKtjm1jo G/chkxtY9FQSzNUSJahZfgmPsijUf0KUbHnO9dCmeTYPPrCRvA/EnLvw2R2/5VZZHaKf z7jWMx9hAVwuHkfpA89PY55bSwE+qCOuY46i+xHZMwaIux/F+OwHRoTLQspsHE/vsqQu K/xw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=96I8XoPyvieuJgV0VIvOicMEjhLE9HYi5wgVEebJbPo=; b=OYAhOFvtjNX9lNy9rBx0YGeP5hzlHRBvR4f6UNPxFCb/baBmdnKG2YWFVUq97DaEBl yCXfO+s24IzfxFmDQpPzdW8Y/VWZUp7plzr2DhI8zbUwpAgw0BjVeMLWqrHg9t2V/bln 0vJ61MjFGJU4bGyKGbAl9C0tTW3HRDEOuKNaz0dCzUVZNVAcW3sZKw8M5AOTlkwrHhoN 5Vs1du+0iUr4JJ71Mosvpae6DIuWlXbkZ4a8xzOg3qfzrvrsY91pygo3kv6ZrmA7fyvk nsWvzuUu7XdoYQbrS21TEthNNhT02oGFzupTnYaxIp0sEOrNNRLOUmUZ7Lbh9Vi7XOUh XFYw== 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 h26si1920164edb.141.2019.09.17.13.14.18; Tue, 17 Sep 2019 13:14:43 -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 S1728203AbfIQTnE (ORCPT + 99 others); Tue, 17 Sep 2019 15:43:04 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44004 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfIQTnE (ORCPT ); Tue, 17 Sep 2019 15:43:04 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id F1AC328DE02 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 1/2] kernel-doc: fix processing nested structs with attributes Date: Tue, 17 Sep 2019 16:41:45 -0300 Message-Id: <20190917194146.35642-2-andrealmeid@collabora.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190917194146.35642-1-andrealmeid@collabora.com> References: <20190917194146.35642-1-andrealmeid@collabora.com> 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 The current regular expression for strip attributes of structs (and for nested ones as well) also removes all whitespaces that may surround the attribute. After that, the code will split structs and iterate for each symbol separated by comma at the end of struct definition (e.g. "} alias1, alias2;"). However, if the nested struct does not have any alias and has an attribute, it will result in a empty string at the closing bracket (e.g "};"). This will make the split return nothing and $newmember will keep uninitialized. Fix that, by ensuring that the attribute substitution will leave at least one whitespace. Signed-off-by: André Almeida --- scripts/kernel-doc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 6b03012750da..f1faa036ee59 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1073,10 +1073,10 @@ sub dump_struct($$) { # strip comments: $members =~ s/\/\*.*?\*\///gos; # strip attributes - $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)//gi; - $members =~ s/\s*__aligned\s*\([^;]*\)//gos; - $members =~ s/\s*__packed\s*//gos; - $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos; + $members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)/ /gi; + $members =~ s/\s*__aligned\s*\([^;]*\)/ /gos; + $members =~ s/\s*__packed\s*/ /gos; + $members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos; # replace DECLARE_BITMAP $members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos; # replace DECLARE_HASHTABLE -- 2.23.0