Date: Mon, 23 Jul 2001 03:42:01 -0700 From: Dima Dorfman <dima@unixfreak.org> To: Peter Pentchev <roam@orbitel.bg> Cc: audit@FreeBSD.org Subject: Re: sysctl(8) enhancement: display sysctl MIB's Message-ID: <20010723104201.855893E2F@bazooka.unixfreak.org> In-Reply-To: <20010723004034.I882@ringworld.oblivion.bg>; from roam@orbitel.bg on "Mon, 23 Jul 2001 00:40:34 %2B0300"
next in thread | previous in thread | raw e-mail | index | archive | help
Peter Pentchev <roam@orbitel.bg> writes: > @@ -369,6 +373,33 @@ > } > > /* > + * This formats and outputs the name of one variable. > + * If the -m command-line flag was specified, the MIB value > + * is also printed out. > + * > + * Returns zero on success. > + * No error conditions yet (XXX: check printf() return value? :) I don't think checking printf()'s return value does anything other than add more lines to the program. Most (none?) of the other programs don't do it. Besides, what can you do when it fails? Remember, err(3) calls it too... (well, it calls fprintf to write to stderr, but you get the idea) > + */ > + > +static int > +show_varname(const char *name, const int *oid, int len) ... > @@ -397,7 +428,7 @@ > err(1, "sysctl name %d %d %d", i, j, errno); > > if (Nflag) { > - printf("%s", name); > + show_varname(name, oid, nlen); > return (0); > } > If you're going to make show_varname() return something to indicate an error (your code doesn't do that right now, but the return type is 'int', and the comment says that it might fail in the future), you should check the return value when you call it. Actually, I think making the return type 'void' makes more sense: this is a support routine (as opposed to an interface to something), and if it detects an error, calling one of the err(3) functions would be cleaner than doing error checking all over the place. Other than that, I think it's a good idea. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010723104201.855893E2F>