delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/12/23:41:57

Date: Fri, 12 Sep 1997 20:41:28 -0700 (PDT)
Message-Id: <199709130341.UAA20992@adit.ap.net>
Mime-Version: 1.0
To: lothloriel AT bc1 DOT com (Burton Radons/Lothloriel), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: fopen bug...?

At 02:23  9/11/1997 GMT, Burton Radons/Lothloriel wrote:
>I've just spent the last half day frowning over a tiny piece of code I
have.  It
>doesn't do anything special, it cannot possibly require more than 20k of
>volatile memory, yet somehow, it manages to get fopen to return a NULL,
when the
>program had before validated that the file it was trying to open was existing.
>
>First of all, the program does a quick search through the file hierarchy,
>starting at the current directory.  It spawns itself for subdirectories (Of
>which it recurses only once), ignores the . and .., and the files get their
>headers read and compared, then they're entered into a list if they're valid.
>This goes perfectly fine for the only valid file in the hierarchy.
>
>Then, as the program goes, main loads a subfunction that searches through that
>list, attempts to load the file and fails.  The fopen ALWAYS returns null this
>time, even though I've checked that it does, in fact, ask for the exact same
>wordage for the file in both instances.  One time it succeeds, the other
time it
>fails.
Did you fclose() the file before trying to open it again?
Also, what is errno set to? fopen should set it to something fairly
meaningful when it returns a NULL.

If you can't find it, reduce the program to the minimum that reproduces the
problem and post it here, so we don't have to guess as to other complicating
factors.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019