From owner-svn-src-head@FreeBSD.ORG Sat Oct 8 12:47:00 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8EB961065670; Sat, 8 Oct 2011 12:47:00 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7E7588FC13; Sat, 8 Oct 2011 12:47:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p98Cl09d063340; Sat, 8 Oct 2011 12:47:00 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p98Cl06s063337; Sat, 8 Oct 2011 12:47:00 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201110081247.p98Cl06s063337@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Sat, 8 Oct 2011 12:47:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226157 - head/usr.bin/kdump X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Oct 2011 12:47:00 -0000 Author: des Date: Sat Oct 8 12:47:00 2011 New Revision: 226157 URL: http://svn.freebsd.org/changeset/base/226157 Log: 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. Modified: head/usr.bin/kdump/kdump.c head/usr.bin/kdump/mkioctls Modified: head/usr.bin/kdump/kdump.c ============================================================================== --- head/usr.bin/kdump/kdump.c Sat Oct 8 12:42:19 2011 (r226156) +++ head/usr.bin/kdump/kdump.c Sat Oct 8 12:47:00 2011 (r226157) @@ -100,7 +100,7 @@ void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); void ktrstruct(char *, size_t); void usage(void); -const char *ioctlname(u_long); +void ioctlname(unsigned long, int); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, resolv = 0, abiflag = 0; @@ -504,14 +504,8 @@ ktrsyscall(struct ktr_syscall *ktr, u_in case SYS_ioctl: { const char *cp; print_number(ip, narg, c); - if ((cp = ioctlname(*ip)) != NULL) - printf(",%s", cp); - else { - if (decimal) - printf(",%jd", (intmax_t)*ip); - else - printf(",%#jx ", (intmax_t)*ip); - } + putchar(c); + ioctlname(*ip, decimal); c = ','; ip++; narg--; Modified: head/usr.bin/kdump/mkioctls ============================================================================== --- head/usr.bin/kdump/mkioctls Sat Oct 8 12:42:19 2011 (r226156) +++ head/usr.bin/kdump/mkioctls Sat Oct 8 12:47:00 2011 (r226157) @@ -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 " print "#include " 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 "}" } '