[coreboot-gerrit] New patch to review for coreboot: util/lint: Find unsigned variables with no length specified

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Thu Apr 7 00:33:23 CEST 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14269

-gerrit

commit 29c6f19c184ef25db28ef3c92d23b3555eab5591
Author: Martin Roth <martinroth at google.com>
Date:   Wed Apr 6 16:32:37 2016 -0600

    util/lint: Find unsigned variables with no length specified
    
    The coding guidelines say that all objects should have fully
    qualified types (unsigned int instead of unsigned).
    
    This script finds violations of that rule.
    
    Steps for the filter:
    1) Find all lines in the coreboot tree that have the word 'unsigned'
    followed by a space.
    2) Exclude directories that aren't include or are specifically excluded.
    3) Exclude files that aren't specifically included.
    4) Filter out legimitate uses 'unsigned int' or 'unsigned long' for
    example.
    5) Filter out lines that begin with '/*' or '*'
    
    Change-Id: I46213c6a168e6aafa29a50af814bf7e0fcd32eb6
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 util/lint/lint-014-qualified-types | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/util/lint/lint-014-qualified-types b/util/lint/lint-014-qualified-types
new file mode 100755
index 0000000..58b48b7
--- /dev/null
+++ b/util/lint/lint-014-qualified-types
@@ -0,0 +1,35 @@
+#!/bin/sh
+# This file is part of the coreboot project.
+#
+# Copyright (C) 2016 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# DESCR: Check that variables have fully qualified types
+
+LC_ALL=C export LC_ALL
+
+INCLUDED_DIRS='^src/\|^util/\|payloads/libpayload\|payloads/coreinfo'
+EXCLUDED_DIRS='^src/vendorcode\|^util/romcc\|cbfstool/lzma\|cbfstool/lz4'
+INCLUDED_FILES='\.[ch]:'
+
+# Use git grep if the code is in a git repo, otherwise use grep.
+if [ -n "$(command -v git)" ] && [ -d .git ]; then
+	GREP_FILES="git grep -n"
+else
+	GREP_FILES="grep -rn"
+fi
+
+${GREP_FILES} 'unsigned[[:space:]]' | \
+	grep "$INCLUDED_DIRS" | \
+	grep -v "$EXCLUDED_DIRS" | \
+	grep "$INCLUDED_FILES" | \
+	grep -v 'unsigned[[:space:]]*int\|unsigned[[:space:]]*long\|unsigned[[:space:]]*char\|unsigned[[:space:]]*short' | \
+	grep -v ':[[:space:]]*/\*\|:[[:space:]]*\*'



More information about the coreboot-gerrit mailing list