delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/10/21/17:48:58

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199910212124.RAA11174@mccoy2.ECE.McGill.CA>
Subject: Re: Bug in fsetpos()?
To: djgpp-workers AT delorie DOT com
Date: Thu, 21 Oct 1999 17:24:07 -0400 (EDT)
In-Reply-To: <380EB83B.D9BB7F9@tudor21.net> from "Richard Dawe" at Oct 21, 99 07:52:43 am
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Bonjour M. Richard Dawe

> 
> I was looking at fseek(), fgetpos(), fsetpos() earlier and I noticed that
> fsetpos() appears to ignore the return value of fseek(). Is this intended?
> If not, there's a patch below to fix it. I also altered the return value
> to be -1, to be consistent with fseek(). If this is the intended
> behaviour, may I ask why?
> 
> Here's the patch:

I don't think this is a bug, fsetpos() returns 0 if it succeeds otherwise
it returns a non-zero value and sets errno to indicate the error.

However all implemetations have seen just call fseek()

int fsetpos(FILE *stream, const fpos_t *pos) {
	return fseek(stream, *pos, SEEK_SET);
}
and let errno propagates up,  I did not expect the EFAULT.
I agree that consistency is good, but this is not a bug and no particular
meaning should be taken on the return value besides != 0.

if (fsetpos(stream, pos) < 0) { .. } /* wrong */
if (fsetpos(stream, pos) != 0) { .. } /* good */


Cheers ..

-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!

- Raw text -


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