Commit dac8b27b authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

check_format: check all public structs/enums have spdk_ prefix



Same as functions, all structures/enums that are part of the public
interface should have the spdk_ prefix, so check_format will enforce
that from now on.  Some of the files are excluded from this check,
because they already contains structures with this prefix.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I9330f0ccfcc8a25184fdd06edea67b1fadb0bed0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19690


Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@gmail.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 5bd6b6b4
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ function check_posix_includes() {
	return $rc
}

function check_naming_conventions() {
check_function_conventions() {
	local rc=0

	echo -n "Checking for proper function naming conventions..."
@@ -365,6 +365,45 @@ function check_naming_conventions() {
	return $rc
}

check_conventions_generic() {
	local out decltype=$1 excludes=(${@:2})

	# We only care about the types defined at the beginning of a line to allow stuff like nested
	# structs.  Also, we need to drop any __attribute__ declarations.
	out=$(git grep -E "^$decltype\s+\w+.*\{$" -- "include/spdk" "${excludes[@]}" \
		| sed 's/__attribute__\s*(([[:alnum:]_, ()]*))\s*//g' \
		| awk "!/$decltype\s+spdk_/ { \$(NF--)=\"\"; print }")

	if [[ -n "$out" ]]; then
		cat <<- WARN
			Found $decltype declarations without the spdk_ prefix:

			$out
		WARN
		return 1
	fi
}

check_naming_conventions() {
	check_function_conventions
	# There are still some enums without the spdk_ prefix.  Once they're renamed, we can remove
	# these excludes
	check_conventions_generic 'enum' \
		':!include/spdk/blob.h' \
		':!include/spdk/ftl.h' \
		':!include/spdk/idxd_spec.h' \
		':!include/spdk/iscsi_spec.h' \
		':!include/spdk/lvol.h' \
		':!include/spdk/nvmf_fc_spec.h' \
		':!include/spdk/vfio_user_spec.h'
	# Same with structs
	check_conventions_generic 'struct' \
		':!include/spdk/ftl.h' \
		':!include/spdk/idxd_spec.h' \
		':!include/spdk/iscsi_spec.h' \
		':!include/spdk/vfio_user_spec.h'
}

function check_include_style() {
	local rc=0