Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Feb 1999 05:30:03 -0800 (PST)
From:      "Matthew D. Fuller" <fullermd@futuresouth.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/10152: fortune(6) gives bogus diagnostic sometimes [RFC]
Message-ID:  <199902191330.FAA00855@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/10152; it has been noted by GNATS.

From: "Matthew D. Fuller" <fullermd@futuresouth.com>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc: Mikhail Teterin <mi@misha.cisco.com>
Subject: Re: bin/10152: fortune(6) gives bogus diagnostic sometimes [RFC]
Date: Fri, 19 Feb 1999 02:42:20 -0600

 OK, call for opinions on this.
 
 I see where the errors are coming from, but I'm not sure what an
 appropriate fix is, if a 'fix' is even appropriate.
 
 The error in this case is occuring here:
     if (access(datfile, R_OK) < 0) {
         free(datfile);
         DPRINTF(2, (stderr, "FALSE (no \".dat\" file)\n"));
         return FALSE;
     }
 
 Note that the warning message is NOT printed unless you use the
 undocumented debug flag, which is only enabled when fortune is compiled
 with -DDEBUG (which we always do by default).  I've attached a patch
 later to document this in the manpage.
 
 When you run it as fortune -DD (see the 2 after DPRINTF there?  That's
 how many times -D must be specified for the message in question to be
 printed), you see this:
 (ttyp1):{1672}% fortune -DD
 adding file "/usr/share/games/fortune/fortunes"
 path = "/usr/share/games/fortune/fortunes"
 is_fortfile(/usr/share/games/fortune/fortunes) returns FALSE (no ".dat" file)
 fortune:/usr/share/games/fortune/fortunes not a fortune file or directory
 
 The final error message is dies on doesn't help you at all unless you see
 the rest of it.  There's a number of other reasons is_fortfile() can bomb
 out, so changing the message directly isn't quite the answer.  Maybe
 is_fortfile() should spout a warning for permission denied?  Most of the
 other warnings are non-fatal, and not even worthy of a warning, but this
 one seems to be; even if you're not in -D[...] mode.
 
 Regardless, I think the changes should be added into the manpage, since it
 seems to always be compiled with -DDEBUG.
 
 How does this look?  It only deals with THIS problem, not with any
 related things, but it's better than nothing:
 
 
 Index: fortune.6
 ===================================================================
 RCS file: /usr/cvs/src/games/fortune/fortune/fortune.6,v
 retrieving revision 1.5
 diff -u -r1.5 fortune.6
 --- fortune.6	1997/02/22 14:46:50	1.5
 +++ fortune.6	1999/02/19 08:28:10
 @@ -43,7 +43,7 @@
  .Nd "print a random, hopefully interesting, adage"
  .Sh SYNOPSIS
  .Nm fortune
 -.Op Fl aefilosw
 +.Op Fl aDefilosw
  .Op Fl m Ar pattern
  .Oo
  .Op Ar \&N%
 @@ -63,6 +63,9 @@
  (See the
  .Fl o
  option for more information on offensive fortunes.)
 +.It Fl D
 +Enable additional debugging output.
 +Specify this option multiple times for more verbose output.
  .It Fl e
  Consider all fortune files to be of equal size (see discussion below
  on multiple files).
 Index: fortune.c
 ===================================================================
 RCS file: /usr/cvs/src/games/fortune/fortune/fortune.c,v
 retrieving revision 1.10
 diff -u -r1.10 fortune.c
 --- fortune.c	1997/06/14 00:37:08	1.10
 +++ fortune.c	1999/02/19 08:37:49
 @@ -799,8 +799,12 @@
  	datfile = copy(file, (unsigned int) (strlen(file) + 4)); /* +4 for ".dat" */
  	strcat(datfile, ".dat");
  	if (access(datfile, R_OK) < 0) {
 +		DPRINTF(2, (stderr, "FALSE (no readable \".dat\" file)\n"));
 +#ifdef DEBUG
 +		if (Debug < 2)
 +			DPRINTF(0, (stderr, "Warning: file \"%s\" unreadable\n", datfile));
 +#endif
  		free(datfile);
 -		DPRINTF(2, (stderr, "FALSE (no \".dat\" file)\n"));
  		return FALSE;
  	}
  	if (datp != NULL)
 
 
 
 
 ---
 
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 | Matthew Fuller     http://www.over-yonder.net/~fullermd |
 * fullermd@futuresouth.com       fullermd@over-yonder.net *
 | UNIX Systems Administrator      Specializing in FreeBSD |
 *   FutureSouth Communications   ISPHelp ISP Consulting   *
 |  "The only reason I'm burning my candle at both ends,   |
 *    is because I haven't figured out how to light the    *
 |                     middle yet"                         |
 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902191330.FAA00855>