Path: utzoo!attcan!uunet!lll-winken!csd4.milw.wisc.edu!mailrus!bbn!gatech!emcard!mat From: mat@emcard.UUCP (W Mat Waites) Newsgroups: comp.os.minix Subject: Re: /usr/minix/amoeba/examples/client3.c Message-ID: <6810@emcard.UUCP> Date: 22 Mar 89 19:06:35 GMT References: <11077@louie.udel.EDU> <27232@cci632.UUCP> Reply-To: mat@emcard.UUCP (W Mat Waites) Organization: Emory Univ CDB Lines: 48 In article <27232@cci632.UUCP> tvf@ccird7.UUCP (Tom Frauenhofer) writes: >In article <11077@louie.udel.EDU> jnall%FSU.BITNET@cunyvm.cuny.edu (John Nall 904-644-5241) writes: >>pointed out to me that Andy's sample remote file client program, >>client3.c, does not work because the main routine has a read statement >>which is of the form "if ((n=read(fd,buf,bytes) < 0))" and, as stated >>on page 15 of K&R, this always sets n to 0 or 1, rather than the number >>of bytes read. > >The code is correct. If there is an error with the read, it returns -1. >Check page 160, K&R, section 8.2 (Low Level I/O - Read and Write), the second >paragraph (the one that begins "Each call returns..." - the paragraph after >the sample code). > >Thomas V. Frauenhofer ...!rutgers!rochester!cci632!ccird7!tvf Sorry, but.... What a weenie! Did you _read_ page 15? How about page 215 where the priority of operators is explicitly listed? I think not! The original fragment: if ((n=read(fd,buf,bytes) < 0)) is equivalent to: if ((n=(read(fd,buf,bytes) < 0))) ^ ^ (new parens) not: if (((n=read(fd,buf,bytes)) < 0)) ^ ^ I assume the original author meant the second modification. It is this kind of instant, authoritative smelling, incorrect information that makes Usenet a poor information source for the uninitiated. Mat -- W Mat Waites | Oh, I used to be disgusted, but now I'm just amused. gatech!emcard!mat | Since their wings got rusted, you know the angels 8-5 ET: (404) 727-7197 | wanna wear my red shoes --E. Costello