slist: compile error in debug code
[smatch.git] / smatch_scripts / kpatch.sh
blobb92208e0a2fb08688097199fc83c5c4d82ba338f
1 #!/bin/bash -e
3 TMP_DIR=/tmp
5 help()
7 echo "Usage: $0 <filename>"
8 echo "You must be at the base of the kernel tree to run this."
9 exit 1
12 signoff()
14 name=$(mutt -Q realname | cut -d '"' -f 2)
15 [ "$name" = "" ] && name="Your Name"
16 email=$(mutt -Q from | cut -d '"' -f 2)
17 [ "$email" = "" ] && email="address@example.com"
18 echo "Signed-off-by: $name <${email}>"
21 continue_yn()
23 echo -n "Do you want to fix these check patch errors now? "
24 read ans
25 if ! echo $ans | grep -iq ^n ; then
26 exit 1;
30 qc()
32 local msg=$1
33 local ans
35 echo -n "$msg: "
36 read ans
37 if ! echo $ans | grep -qi ^y ; then
38 exit 1
42 if [ ! -f $1 ] ; then
43 help
46 MY_SIGNOFF=$(signoff)
48 fullname=$1
49 filename=$(basename $fullname)
51 DIFF_FILE=$TMP_DIR/${filename}.diff
52 MAIL_FILE=$TMP_DIR/${filename}.msg
54 echo "QC checklist"
55 qc "Have you handled all the errors properly?"
56 if git diff $fullname | grep ^+ | grep -qi alloc ; then
57 qc "Have you freed all your mallocs?"
59 if git diff $fullname | grep ^+ | grep -qi alloc ; then
60 qc "Have you check all your mallocs for NULL returns?"
63 kchecker --spammy $fullname
64 kchecker --sparse $fullname
65 echo "Press ENTER to continue"
66 read unused
68 to_addr=$(./scripts/get_maintainer.pl -f $fullname | head -n 1)
69 cc_addr=$(./scripts/get_maintainer.pl -f $fullname | tail -n +2 | \
70 perl -ne 's/\n$/, /; print')
71 cc_addr="$cc_addr, kernel-janitors@vger.kernel.org"
73 echo -n "To: " > $MAIL_FILE
74 echo "$to_addr" >> $MAIL_FILE
75 echo -n "CC: " >> $MAIL_FILE
76 echo "$cc_addr" >> $MAIL_FILE
78 echo "" > $DIFF_FILE
79 echo "$MY_SIGNOFF" >> $DIFF_FILE
80 echo "" >> $DIFF_FILE
82 git diff $fullname | tee -a $DIFF_FILE
84 ./scripts/checkpatch.pl $DIFF_FILE || continue_yn
86 echo "Press ENTER to continue"
87 read unused
89 cat $DIFF_FILE >> $MAIL_FILE
91 mutt -H $MAIL_FILE