blob: 48810cf3cd4bcc5a3bea8f508e582703798cc3f0 [file] [log] [blame]
Martin Roth0ad5fbd2020-12-24 12:06:38 -07001#!/usr/bin/env sh
Martin Rothf7906722016-04-06 16:32:37 -06002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
4
Martin Rothf7906722016-04-06 16:32:37 -06005# DESCR: Check that variables have fully qualified types
6
7LC_ALL=C export LC_ALL
8
9INCLUDED_DIRS='^src/\|^util/\|payloads/libpayload\|payloads/coreinfo'
Elyes HAOUAS8297fa12020-02-22 10:37:49 +010010EXCLUDED_DIRS='^src/vendorcode\|cbfstool/lzma\|cbfstool/lz4'
Martin Rothf7906722016-04-06 16:32:37 -060011INCLUDED_FILES='\.[ch]:'
12
13# Use git grep if the code is in a git repo, otherwise use grep.
Alex Thiessen73f19dc2018-01-16 23:05:48 +000014if [ -n "$(command -v git)" ] && \
15 [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
16then
Martin Rothf7906722016-04-06 16:32:37 -060017 GREP_FILES="git grep -n"
18else
19 GREP_FILES="grep -rn"
20fi
21
22${GREP_FILES} 'unsigned[[:space:]]' | \
23 grep "$INCLUDED_DIRS" | \
24 grep -v "$EXCLUDED_DIRS" | \
25 grep "$INCLUDED_FILES" | \
26 grep -v 'unsigned[[:space:]]*int\|unsigned[[:space:]]*long\|unsigned[[:space:]]*char\|unsigned[[:space:]]*short' | \
27 grep -v ':[[:space:]]*/\*\|:[[:space:]]*\*'