Ensure __rte_packed_begin and __rte_packed_end show up in pairs
when checking patches.

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

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
-- 
2.47.0.vfs.0.3

Reply via email to