From owner-cvs-lib Wed Oct 4 16:25:54 1995 Return-Path: owner-cvs-lib Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id QAA08318 for cvs-lib-outgoing; Wed, 4 Oct 1995 16:25:54 -0700 Received: from jhome.DIALix.COM (root@jhome.DIALix.COM [192.203.228.69]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id QAA08313 ; Wed, 4 Oct 1995 16:25:46 -0700 Received: (from peter@localhost) by jhome.DIALix.COM (8.6.12/8.6.9) id HAA07133; Thu, 5 Oct 1995 07:20:34 +0800 Date: Thu, 5 Oct 1995 07:20:34 +0800 (WST) From: Peter Wemm To: Joerg Wunsch cc: Nate Williams , CVS-commiters@freefall.freebsd.org, cvs-lib@freefall.freebsd.org Subject: Re: cvs commit: src/lib/libc/stdio gets.c In-Reply-To: <199510042241.XAA04988@uriah.heep.sax.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-lib@FreeBSD.org Precedence: bulk On Wed, 4 Oct 1995, J Wunsch wrote: > > As Nate Williams wrote: > > > > ... If you also want to take some more > > inspiration from NetBSD, add a static variable to the sources so the > > warning is printed at run-time only once. It is still annoying, but not > > continually annoying. > > huh? This has been there all the time: > > static int warned; > static char w[] = > "warning: this program uses gets(), which is unsafe.\r\n"; > > if (!warned) { > (void) write(STDERR_FILENO, w, sizeof(w) - 1); > warned = 1; > } Yeah, that's the bit of code that I wanted to nuke, but judging by Bruce's responce when I asked about that, I thought I'd play it safe and cover my backside. The way I see it, this warning is bad because there's no guarantee that the message is going to be printed if the code path that calls gets() in the first place isn't executed often. When it finally does, the poor user is left wondering why the hell the executable has suddenly printed this new error message in the middle of the program run. If it could be done via _init tricks or something at startup, then it would probably be OK, but that's not trivial with shared libraries... Oh well.. Anyway, my vote for deleting the run-time warning is on the record. -Peter > -- > cheers, J"org > > joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE > Never trust an operating system you don't have sources for. ;-) >