From 499311b91bad1712e0e83d71ddbca91e13abd9d4 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 29 Jan 2010 11:33:12 +0300 Subject: [PATCH] add smatch_scripts/filter_kernel_deref_check.sh The check_deref_check.c file looks for places which check for null after a dereference. The problem is the kernel has a lot of macros which automatically check whether a variable is non-null. This script tries to remove the false positives which are caused by macros. Signed-off-by: Dan Carpenter --- smatch_scripts/filter_kernel_deref_check.sh | 100 ++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 smatch_scripts/filter_kernel_deref_check.sh diff --git a/smatch_scripts/filter_kernel_deref_check.sh b/smatch_scripts/filter_kernel_deref_check.sh new file mode 100755 index 00000000..39067c0d --- /dev/null +++ b/smatch_scripts/filter_kernel_deref_check.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +file=$1 +if [[ "$file" = "" ]] ; then + echo "Usage: $0 " + exit 1 +fi + +IFS=" +" + +for line in $(grep 'dereferenced before' $file) ; do + + code_file=$(echo "$line" | cut -d ' ' -f1) + lineno=$(echo "$line" | cut -d ' ' -f2) + variable=$(echo "$line" | cut -d "'" -f2) + source_line=$(tail -n $lineno $code_file | head -n 1 | sed -e 's/^\W*//') + + if echo "$source_line" | grep -q rcu_assign_pointer ; then + continue + fi + if echo "$source_line" | grep -q '^\W*tda_' ; then + continue + fi + if echo "$source_line" | grep -q tda_fail ; then + continue + fi + if echo "$source_line" | grep -q '^\W*ATH5K_' ; then + continue + fi + if echo "$source_line" | grep -qw CMDINFO ; then + continue + fi + if echo "$source_line" | grep -qw dump_desc_dbg ; then + continue + fi + if echo "$source_line" | grep -qw CAMERA_IS_OPERATIONAL ; then + continue + fi + if echo "$source_line" | grep -qw USBVISION_IS_OPERATIONAL ; then + continue + fi + if echo "$source_line" | grep -qw DEV_INIT_TEST_WITH_RETURN ; then + continue + fi + if echo "$source_line" | grep -qw TW_PRINTK ; then + continue + fi + if echo "$source_line" | grep -qw RESET_ONE_SEC_TX_CNT ; then + continue + fi + if echo "$source_line" | grep -qw SOCK_DEBUG; then + continue + fi + if echo "$source_line" | grep -qw P80211SKB_RXMETA ; then + continue + fi + if echo "$source_line" | grep -qw ACM_READY ; then + continue + fi + if echo "$source_line" | grep -qw v4l2_subdev_notify ; then + continue + fi + if echo "$source_line" | egrep -qw 'tuner_(err|info)' ; then + continue + fi + if echo "$source_line" | grep -qw DBG_SKB ; then + continue + fi + if echo "$source_line" | grep -qw for_each_mddev ; then + continue + fi + if echo "$source_line" | grep -qw v4l2_subdev_call ; then + continue + fi + if echo "$source_line" | grep -qw VALID_CALLBACK ; then + continue + fi + if [ "$variable" == "bp->dev" ] && echo "$source_line" | grep -qw DP ; then + continue + fi + if echo "$source_line" | grep -qw BNX2X_ERR ; then + continue + fi + if echo "$source_line" | grep -qw FCOE_NETDEV_DBG ; then + continue + fi + if echo "$source_line" | grep -qw __rq_for_each_bio ; then + continue + fi + if echo "$source_line" | grep -qw IPS_DMA_DIR ; then + continue + fi + if [ "$variable" == "dev" ] && echo "$source_line" | grep -qw dprintk ; then + continue + fi + + echo "$code_file $lineno '$variable': $source_line" +done + -- 2.11.4.GIT