svn commit: r194789 - head/usr.bin/usbhidctl

Bruce Evans brde at
Fri Jun 26 18:18:42 UTC 2009

On Thu, 25 Jun 2009, Xin LI wrote:

> Bruce Evans wrote:
>> On Tue, 23 Jun 2009, Xin LI wrote:
>>> Log:
>>>  Use getprogname() instead of referencing __progname.
>> Neither is permitted in FreeBSD in usage().
> I didn't see references about this?  If this is discouraged, perhaps we
> should mention it in style(9) or somewhere.

FreeBSD style(9) simply doesn't mention getprogname(), while NetBSD
share/misc/style requires it in the example usage().

Actually, it is OK to use it in FreeBSD iff the system supports the
same program having different names, like reboot/halt/etc.

> It looks like that a lot of
> programs are using (not necessarily from NetBSD), but also others.  Do
> we have some discussion in the past regarding this?

Most are still from NetBSD, except for lots in tools/regression.  Most
other uses are still correct ones, for things like setproctitle() (and
for not so correct things like fprintf() -- why not use warnx()?).

This was discussed in FreeBSD mailing lists years ago, and IIRC no one
disagreed with the existing practice of hard-coding the program name.
It can be considered a feature that if you copy or rename "cp" to
"foo", its usage message reminds you that it is still "cp".

>>> Modified:
>>>  head/usr.bin/usbhidctl/usbhid.c
>> This was obtained from NetBSD, which requires using getprogname() in
>> usage().
> This is purely coincidence...  I didn't even looked at NetBSD code in
> this case, otherwise I would have brought the TNF copyright changes,
> etc. altogether.

The __progname in usbhidctl was obtained from NetBSD.  Without this,
the usage() function would have been a normal one and you shouldn't
have needed to fix it.  NetBSD of course fixed it long ago (FreeBSD
obtained the bug in 2000 and it was fixed in NetBSD in 2001).  In my
2005 copy of NetBSD, all usage() messages in utilities seem to have
been roto-tilled to use getprogname().  This gives 343 files matching
getprogname in NetBSD 2005 (incomplete sources but I forget how incomplete).
FreeBSD now has only 88 files matching.


More information about the svn-src-all mailing list