[v6,01/30] devtools: check packed attributes

Message ID 1732668761-5556-2-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series fix packing of structs when building with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Nov. 27, 2024, 12:52 a.m. UTC
Ensure __rte_packed_begin and __rte_packed_end show up in pairs
when checking patches.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 devtools/checkpatches.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
  

Comments

Tyler Retzlaff Dec. 5, 2024, 12:16 a.m. UTC | #1
On Tue, Nov 26, 2024 at 04:52:12PM -0800, Andre Muezerie wrote:
> Ensure __rte_packed_begin and __rte_packed_end show up in pairs
> when checking patches.
> 
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 4a8591be22..d304a84df3 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -362,6 +362,21 @@  check_aligned_attributes() { # <patch>
 	return $res
 }
 
+check_packed_attributes() { # <patch>
+	res=0
+
+	begin_count=$(grep '__rte_packed_begin' "$1" | \
+			wc -l)
+	end_count=$(grep '__rte_packed_end' "$1" | \
+			wc -l)
+	if [ $begin_count != $end_count ]; then
+		echo "__rte_packed_begin and __rte_packed_end mismatch. They should always be used in pairs."
+		res=1
+	fi
+
+	return $res
+}
+
 check_release_notes() { # <patch>
 	rel_notes_prefix=doc/guides/rel_notes/release_
 	IFS=. read year month release < VERSION
@@ -479,6 +494,14 @@  check () { # <patch-file> <commit>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking packed attributes:\n'
+	report=$(check_packed_attributes "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$subject"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	! $verbose || printf '\nChecking release notes updates:\n'
 	report=$(check_release_notes "$tmpinput")
 	if [ $? -ne 0 ] ; then