[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fwrite.c bugfix



On Thu, Jul 10, 2003 at 05:35:33PM -0700, Remco Treffkorn wrote:
> 
> Fwrite is supposed to return the number of items written.

number of items, NOT number of characters:

from the man page:

RETURN VALUE
	fread  and  fwrite  return the number of items successfully
	read or written (i.e., not the number of charac-
	ters).  If an error occurs, or the end-of-file is reached, the
	return value is a short item count (or zero).

	fread  does  not  distinguish  between  end-of-file and error,
	and callers must use feof(3) and ferror(3) to
	determine which occurred.

> The original version returned -1 on complete success.

your right that return value appears broken, but your patch doesn't
fix it properly, im tired but as i read the man page the only flaw is
return count should be return bwrote.

that variable isn't well named either, its not bytes wrote, its nmemb wrote.

> If I read the man page correctly, the following patch should fix it.

the error returns were correct as i read the code and man page.
please check your tests with glibc too so you can compare behavior.

-- 
Ethan Benson
http://www.alaska.net/~erbenson/

Attachment: pgp00021.pgp
Description: PGP signature