From ce4c1cf88a5e4edffefb18b4289a429e1e64aa14 Mon Sep 17 00:00:00 2001 From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Tue, 29 Oct 2002 23:02:43 +0000 Subject: [PATCH] A useful script to see if print statments match their arguments. I'll delete it from the directory, but you can find it in the ATTIC! git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@166 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- sm5/findbadprint | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 sm5/findbadprint diff --git a/sm5/findbadprint b/sm5/findbadprint new file mode 100755 index 000000000..953d69a1f --- /dev/null +++ b/sm5/findbadprint @@ -0,0 +1,43 @@ +#! /bin/bash +# This is a useful little script for debugging print statements. +# The point is that since we use our own varargs print function, +# the poor compiler can't check to see for example if there is agreement +# between the numbers of arguments and format flags. + +# Running this script replaces the different printout() and pout() statments +# with 100% genuine printfs. A few seconds of hand editing to eliminate the +# original defs, and you can get compiler warning messages. + +# Note: use this script in a COPY of your working directory. Else it will +# trash stuff. Use ./findbadprint to go one way, ./findbadprint Q to restore +# the files as they were. + +restore () { + mv $1.save $1 +} + + +hackfile () { + # first arg filename + cp $1 $1.save + cat $1.save | sed 's/printout(LOG_INFO,/printf(/g' \ + | sed 's/printout(LOG_CRIT,/printf(/g' \ + | sed 's/pout(/printf(/g' > $1 +} + + +if [ $# -eq 0 ] ; then + +hackfile smartd.c +hackfile atacmds.c +hackfile ataprint.c +hackfile smartctl.c + +else + +restore smartd.c +restore atacmds.c +restore ataprint.c +restore smartctl.c + +fi -- GitLab