From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2294 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: src/stdio/__stdio_read.c Date: Fri, 16 Nov 2012 10:29:36 +0100 Message-ID: <20121116092936.GI12537@port70.net> References: <20121116114057.34884015@keeper.home.local> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1353058191 14665 80.91.229.3 (16 Nov 2012 09:29:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 Nov 2012 09:29:51 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2295-gllmg-musl=m.gmane.org@lists.openwall.com Fri Nov 16 10:30:02 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TZIFM-0008BO-4B for gllmg-musl@plane.gmane.org; Fri, 16 Nov 2012 10:30:00 +0100 Original-Received: (qmail 24290 invoked by uid 550); 16 Nov 2012 09:29:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 24277 invoked from network); 16 Nov 2012 09:29:48 -0000 Content-Disposition: inline In-Reply-To: <20121116114057.34884015@keeper.home.local> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2294 Archived-At: * Yuri Kozlov [2012-11-16 11:40:57 +0400]: > size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) > { > ssize_t cnt; > ... > cnt = syscall(SYS_readv, ...) > > if (cnt <= 0) { > f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt); > f->rpos = f->rend = 0; > return cnt; > } > ... > } > > It not raise a problem when a signed value return as unsigned? > no, cnt is either 0 or -1 there (assuming readv works) this is how __stdio_read is used (f->read): for (; l; l-=k, dest+=k) { k = __toread(f) ? 0 : f->read(f, dest, l); if (k+1<=1) { FUNLOCK(f); return (len-l)/size; } } it handles the k == -1 and k == 0 case