summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump/mkioctls
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2011-10-08 12:47:00 +0000
committerdes <des@FreeBSD.org>2011-10-08 12:47:00 +0000
commit0d23c50594a57a81eb8c0b7f952ee2612cf56220 (patch)
tree0c5de37367cc311a02ca5d4bc6cea313823170e1 /usr.bin/kdump/mkioctls
parenta011c99980aa09ec857ee5006943c95bfce6a95b (diff)
downloadFreeBSD-src-0d23c50594a57a81eb8c0b7f952ee2612cf56220.zip
FreeBSD-src-0d23c50594a57a81eb8c0b7f952ee2612cf56220.tar.gz
Bring ioctlname() in line with all the other *name() functions, which
actually print the name (or the numeric value, if they can't figure out the correct name) instead of just returning a pointer to it. Also, since ioctl numbers are not and probably never will be unique, drop support for using a switch statement instead of an if/else chain.
Diffstat (limited to 'usr.bin/kdump/mkioctls')
-rw-r--r--usr.bin/kdump/mkioctls40
1 files changed, 18 insertions, 22 deletions
diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls
index 7ca773d..a9c7d06 100644
--- a/usr.bin/kdump/mkioctls
+++ b/usr.bin/kdump/mkioctls
@@ -4,15 +4,8 @@
set -e
-if [ "x$1" = "x-s" ]; then
- use_switch=1
- shift
-else
- use_switch=0
-fi
-
if [ -z "$1" ]; then
- echo "usage: sh $0 [-s] include-dir"
+ echo "usage: sh $0 include-dir"
exit 1
fi
@@ -30,7 +23,7 @@ ioctl_includes=`
awk -v x="$ioctl_includes" 'BEGIN {print x}' |
gcc -E -I$1 -dM -DCOMPAT_43TTY - |
- awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
+ awk -v ioctl_includes="$ioctl_includes" '
BEGIN {
print "/* XXX obnoxious prerequisites. */"
print "#define COMPAT_43"
@@ -55,16 +48,15 @@ BEGIN {
print "#include <stdio.h>"
print "#include <cam/cam.h>"
print ""
- print "const char *ioctlname(u_long val);"
+ print "void ioctlname(unsigned long val, int decimal);"
print ""
print ioctl_includes
print ""
- print "const char *"
- print "ioctlname(u_long val)"
+ print "void"
+ print "ioctlname(unsigned long val, int decimal)"
print "{"
+ print "\tconst char *str = NULL;"
print ""
- if (use_switch)
- print "\tswitch(val) {"
}
/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
@@ -75,16 +67,20 @@ BEGIN {
break;
++i;
#
- if (use_switch)
- printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
- else
- printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
-
+ print("\t");
+ if (n++ > 0)
+ print("else ");
+ printf("if (val == %s)\n", $i);
+ printf("\t\tstr = \"%s\";\n", $i);
}
END {
- if (use_switch)
- print "\t}"
- print "\n\treturn(NULL);"
+ print "\n"
+ print "\tif (str != NULL)\n"
+ print "\t\tprintf(\"%s\", str);\n"
+ print "\telse if (decimal)\n"
+ print "\t\tprintf(\"%lu\", val);\n"
+ print "\telse\n"
+ print "\t\tprintf(\"%#lx\", val);\n"
print "}"
}
'
OpenPOWER on IntegriCloud