xref: /linux/scripts/checker-valid.sh (revision 23b0f90ba871f096474e1c27c3d14f455189d2d9)
1#!/bin/sh -eu
2# SPDX-License-Identifier: GPL-2.0
3
4[ ! -x "$(command -v "$1")" ] && exit 1
5
6tmp_file=$(mktemp)
7trap "rm -f $tmp_file" EXIT
8
9cat << EOF >$tmp_file
10static inline int u(const int *q)
11{
12	__typeof_unqual__(*q) v = *q;
13	return v;
14}
15EOF
16
17# sparse happily exits with 0 on error so validate
18# there is none on stderr. Use awk as grep is a pain with sh -e
19$@ $tmp_file 2>&1 | awk -v c=1 '/error/{c=0}END{print c}'
20