From: Horst von Brand Date: Thu, 22 Dec 2005 00:27:40 GMT Subject: Re: [PATCH] off-by-one bugs found by valgrind Message-ID: <200512220027.jBM0RetQ003481@laptop11.inf.utfsm.cl> In-Reply-To: Junio C Hamano wrote: > Pavel Roskin writes: [...] > > quote_c_style_counted() in quote.c uses a dangerous construct, when a > > variable is incremented once and used twice in the same expression. > > Sorry, I do not follow you. Isn't && a sequence point? > > > - for (sp = name; (ch = *sp++) && (sp - name) <= namelen; ) { > > - > > + for (sp = name; sp < name + namelen; sp++) { Yes, it is, so it doesn't fix any bugs; but Pavel's version is definitely more readable. -- Dr. Horst H. von Brand User #22616 counter.li.org Departamento de Informatica Fono: +56 32 654431 Universidad Tecnica Federico Santa Maria +56 32 654239 Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513