From: Jeff King Date: Thu, 19 May 2011 10:50:09 GMT Subject: Re: [PATCH 3/3] notes remove: --stdin reads from the standard input Message-ID: <20110519105009.GA11107@sigill.intra.peff.net> In-Reply-To: <1305764061-21303-4-git-send-email-gitster@pobox.com> On Wed, May 18, 2011 at 05:14:21PM -0700, Junio C Hamano wrote: > + if (from_stdin) { > + struct strbuf sb = STRBUF_INIT; > + while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) { > + int len = sb.len; > + if (len && sb.buf[len - 1] == '\n') > + sb.buf[--len] = '\0'; > + retval |= remove_one_note(t, sb.buf, flag); > + } > + } Wouldn't strbuf_rtrim (or even strbuf_trim) be useful here? Manipulating only a copy of the len parameter while changing the strbuf itself raised warning flags, though it is correct as-is because you never actually use sb.len. Using strbuf_trim is shorter, easier to read, and will helpfully eat any extraneous whitespace, too. -Peff