From mboxrd@z Thu Jan 1 00:00:00 1970 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 873031A23A1; Sat, 31 May 2025 18:32:24 +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=1748716344; cv=none; b=V3SPbrKpsYvo2P9TmL5QeFrYsnte/3huyYEhXjBvITiG+44TmP5rfHrhliFU05BPD89HuQkAYsgDHzWt8SwQtmO7e3y/5ymOEeHADYfWrlx4s8kKmdzbob6uNiYIIcou/hsD5Wf8VGNFBpqP103bOVN/+WCK6REX6N3kuNJcsE4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748716344; c=relaxed/simple; bh=rEWUoKbhQj+k/CWWKQA+dBxFt+hJeNJpix7vaTSCieQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bTqaxFzVhsUBBWCvNSxS6qcx5hMnOXVxUO8vfohFZVvDa3hyejKScQ2STBESYE/vw0w7xWKYDUV4kzDoBKe8/L1kSuoAO84uP7beyxqVyCr0vRodhNzXjSlEfNlclf3fMQ7ykeO8WaC2JltHmf40nlBS3A9yB2Mj52nFcb7DY3c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A0SKufoF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A0SKufoF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5180C4CEEA; Sat, 31 May 2025 18:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748716344; bh=rEWUoKbhQj+k/CWWKQA+dBxFt+hJeNJpix7vaTSCieQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A0SKufoFYmq1ffAgkLw20ftiqfe+0CJfXcWWO1lxrlZXaD3IJze8F0xprNFCH+wxL EqD8oeyxIcyQ+c7tMIkBp9rutZPUWsNvYm+PhT6IB7AJ0MhKyLrSwUgRScXCQAdRuQ RbcDB0TF/3DSHm/+xscqnoGaXlSGb4IGox4qi2T51XIyzw3L2eYWWb0Lhrq3z22Jxz ZgE61kxMsRGqBN2iYwSp+ZMZMdpN1K1JYMeOKw00UltU76tYKXt65lmeR2iYKGEqBQ sAn3GzAWGGm+r1h/bzO8nqYQ0iUMgH+KDCUt7QzxtXURFaRQ8kz4hNeokw4Xkf+4Uy HkyZ4qn8dJfMQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 3/3] scripts/misc-check: check unnecessary #include Date: Sun, 1 Jun 2025 03:28:22 +0900 Message-ID: <20250531183217.3844357-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250531183217.3844357-1-masahiroy@kernel.org> References: <20250531183217.3844357-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Another issue with is that it is sometimes included even when EXPORT_SYMBOL() is not used at all. Some headers (e.g. include/linux/linkage.h>) cannot be fixed for now for the reason described in the previous commit. This commit adds a warning for *.c files that include but do not use EXPORT_SYMBOL(). Signed-off-by: Masahiro Yamada --- scripts/misc-check | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/misc-check b/scripts/misc-check index 9e618e9f93f6..e280ccab6391 100755 --- a/scripts/misc-check +++ b/scripts/misc-check @@ -53,5 +53,17 @@ check_missing_include_linux_export_h () { xargs printf "%s: warning: EXPORT_SYMBOL() is used, but #include is missing\n" >&2 } +# If you do not use EXPORT_SYMBOL(), please do not include . +# Currently, this is checked for *.c files, but not for *.h files, because some +# *.c files rely on being included indirectly. +check_unnecessary_include_linux_export_h () { + + git -C ${srctree:-.} grep --files-with-matches '#include[[:space:]]*' \ + -- '*.[c]' :^tools/ | + xargs grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_GPL_FOR_MODULES)\(.*\)' | + xargs printf "%s: warning: EXPORT_SYMBOL() is not used, but #include is present\n" >&2 +} + check_tracked_ignored_files check_missing_include_linux_export_h +check_unnecessary_include_linux_export_h -- 2.43.0