*BSD News Article 19712


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!doc.ic.ac.uk!uknet!festival!castle.ed.ac.uk!richard
From: richard@castle.ed.ac.uk (Richard Tobin)
Subject: Re: fread return value
References: <vandys.745707770@cisco.com>
Message-ID: <CC09u6.Gx3@festival.ed.ac.uk>
Sender: news@festival.ed.ac.uk (remote news read deamon)
Organization: University of Edinburgh
Date: Thu, 19 Aug 1993 12:10:53 GMT
Lines: 14

In article <vandys.745707770@cisco.com> vandys@cisco.com (Andrew Valencia) writes:
>The function fread(), when passed a size of 0 and nitems 1, will return
>a value of 1.[ ...]  This tends to break the terminating condition of
>some file processing loops.

And is a violation of the ANSI/ISO C standard, which says "If size or
nmemb is zero, fread returns zero".

-- Richard
-- 
"For thousands of years, [homoeopathic magic] was known to the sorcerors of
ancient India, Babylon and Egypt, as well as of Greece and Rome, and at this
day it is still resorted to by cunning and malignant savages in Australia, 
Africa and Scotland."  - J G Frazer, The Golden Bough