checker-valid.sh 419 B

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