From: Ævar Arnfjörð Bjarmason Date: Fri, 16 Feb 2018 12:55:02 GMT Subject: Re: [PATCH v7 1/7] strbuf: remove unnecessary NUL assignment in xstrdup_tolower() Message-ID: In-Reply-To: <20180215152711.158-2-lars.schneider@autodesk.com> On Thu, Feb 15, 2018 at 4:27 PM, wrote: > Since 3733e69464 (use xmallocz to avoid size arithmetic, 2016-02-22) we > allocate the buffer for the lower case string with xmallocz(). This > already ensures a NUL at the end of the allocated buffer. > > Remove the unnecessary assignment. > [...] > for (i = 0; i < len; i++) > result[i] = tolower(string[i]); > - result[i] = '\0'; > return result; > } I agree with this approach, but it's worth noting for other reviewers that there's been some disagreement here on-list (between Eric & I) about whether these sorts of patterns should be removed or kept (although the calloc() case is slightly different from mallocz()), see: https://public-inbox.org/git/871shum182.fsf@evledraar.gmail.com/