Commit dfb2950f authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

scripts/check_format: Adjust bash code to adhere to shfmt v3.8.0



This bump ensures some of the obscure formatting bugs are finally
squashed. All the adjustments introduced here adhere to what we
already try to enforce across the entire repo, but due to said bugs
could not be implemented.

Remove SHFMT_NO_EDITORCONFIG since it's not supported in latest
shfmt releases.

This patch doesn't introduce any functional change in the updated
files.

Change-Id: Ia2b011b86c8fe12376c4a8455ee638473a9f7179
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23088


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
parent 357d98ae
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -534,15 +534,15 @@ function get_bash_files() {
}

function check_bash_style() {
	local rc=0
	local rc=0 supported_shfmt_version=v3.8.0

	# find compatible shfmt binary
	shfmt_bins=$(compgen -c | grep '^shfmt' | uniq || true)
	for bin in $shfmt_bins; do
		shfmt_version=$("$bin" --version)
		if [ $shfmt_version != "v3.1.0" ]; then
			echo "$bin version $shfmt_version not used (only v3.1.0 is supported)"
			echo "v3.1.0 can be installed using 'scripts/pkgdep.sh -d'"
		if [[ $shfmt_version != "$supported_shfmt_version" ]]; then
			echo "$bin version $shfmt_version not used (only $supported_shfmt_version is supported)"
			echo "$supported_shfmt_version can be installed using 'scripts/pkgdep.sh -d'"
		else
			shfmt=$bin
			break
@@ -566,9 +566,7 @@ function check_bash_style() {

			diff=${output_dir:-$PWD}/$shfmt.patch

			# Explicitly tell shfmt to not look for .editorconfig. .editorconfig is also not looked up
			# in case any formatting arguments has been passed on its cmdline.
			if ! SHFMT_NO_EDITORCONFIG=true "$shfmt" "${shfmt_cmdline[@]}" "${sh_files[@]}" > "$diff"; then
			if ! "$shfmt" "${shfmt_cmdline[@]}" "${sh_files[@]}" > "$diff"; then
				# In case shfmt detects an actual syntax error it will write out a proper message on
				# its stderr, hence the diff file should remain empty.
				rc=1
+4 −4
Original line number Diff line number Diff line
@@ -109,10 +109,10 @@ function check_for_driver() {
		return 1
	fi

	if [[ -d /sys/module/${1} || -d \
		/sys/module/${1//-/_} || -d \
		/sys/bus/pci/drivers/${1} || -d \
		/sys/bus/pci/drivers/${1//-/_} ]]; then
	if [[ -d /sys/module/${1} ||
		-d /sys/module/${1//-/_} ||
		-d /sys/bus/pci/drivers/${1} ||
		-d /sys/bus/pci/drivers/${1//-/_} ]]; then
		return 2
	fi
	return 0
+4 −5
Original line number Diff line number Diff line
@@ -434,9 +434,8 @@ function get_config_params() {
		fi
	fi

	if [[ $SPDK_TEST_UNITTEST -eq 0 && \
		$SPDK_TEST_SCANBUILD -eq 0 && -z \
		${SPDK_TEST_AUTOBUILD:-} ]]; then
	if [[ $SPDK_TEST_UNITTEST -eq 0 &&
		$SPDK_TEST_SCANBUILD -eq 0 && -z ${SPDK_TEST_AUTOBUILD:-} ]]; then
		config_params+=' --disable-unit-tests'
	fi

+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ verify() {

	local pci status
	while read -r pci _ _ status; do
		if [[ $pci == "$dev" && \
		if [[ $pci == "$dev" &&
			$status == *"Active devices: "*"$mounts"* ]]; then
			found=1
		fi
+1 −1

File changed.

Contains only whitespace changes.

+2 −2

File changed.

Contains only whitespace changes.

+2 −2

File changed.

Contains only whitespace changes.

+1 −1

File changed.

Contains only whitespace changes.

+2 −2

File changed.

Contains only whitespace changes.

+2 −2

File changed.

Contains only whitespace changes.

+1 −1

File changed.

Contains only whitespace changes.

Loading