From owner-freebsd-audit Mon Jul 23 3:42: 4 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id CB54A37B405 for ; Mon, 23 Jul 2001 03:42:01 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id 855893E2F; Mon, 23 Jul 2001 03:42:01 -0700 (PDT) To: Peter Pentchev Cc: audit@FreeBSD.org Subject: Re: sysctl(8) enhancement: display sysctl MIB's In-Reply-To: <20010723004034.I882@ringworld.oblivion.bg>; from roam@orbitel.bg on "Mon, 23 Jul 2001 00:40:34 +0300" Date: Mon, 23 Jul 2001 03:42:01 -0700 From: Dima Dorfman Message-Id: <20010723104201.855893E2F@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Peter Pentchev 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