diff --git a/sm5/findbadprint b/sm5/findbadprint
new file mode 100755
index 0000000000000000000000000000000000000000..953d69a1f320a5e7a8b3b1f0ce863cce19ef6c19
--- /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