Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-24 Thread Martin Ågren
On 24 August 2017 at 20:29, Brandon Casey wrote: > On Thu, Aug 24, 2017 at 9:52 AM, Junio C Hamano wrote: >> Brandon Casey writes: >> >>> Ah, you probably meant something like this: >>> >>>const char strbuf_slopbuf = '\0'; >>> >>>

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-24 Thread Brandon Casey
On Thu, Aug 24, 2017 at 9:52 AM, Junio C Hamano wrote: > Brandon Casey writes: > >> Ah, you probably meant something like this: >> >>const char strbuf_slopbuf = '\0'; >> >> which gcc will apparently place in the read-only segment. I did not know >>

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-24 Thread Junio C Hamano
Brandon Casey writes: > Ah, you probably meant something like this: > >const char strbuf_slopbuf = '\0'; > > which gcc will apparently place in the read-only segment. I did not know > that. Yes but I highly suspect that it would be very compiler dependent and not

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Brandon Casey
On Wed, Aug 23, 2017 at 3:24 PM, Junio C Hamano wrote: > Brandon Casey writes: > >> On Wed, Aug 23, 2017 at 2:04 PM, Junio C Hamano wrote: >>> Brandon Casey writes: >>> So is there any reason why didn't do

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Junio C Hamano
Brandon Casey writes: > On Wed, Aug 23, 2017 at 2:04 PM, Junio C Hamano wrote: >> Brandon Casey writes: >> >>> So is there any reason why didn't do something like the following in >>> the first place? >> >> My guess is that we didn't

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Brandon Casey
On Wed, Aug 23, 2017 at 2:54 PM, Brandon Casey wrote: > On Wed, Aug 23, 2017 at 2:20 PM, Brandon Casey wrote: >> On Wed, Aug 23, 2017 at 2:04 PM, Junio C Hamano wrote: >>> Brandon Casey writes: >>> So is there any

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Brandon Casey
On Wed, Aug 23, 2017 at 2:20 PM, Brandon Casey wrote: > On Wed, Aug 23, 2017 at 2:04 PM, Junio C Hamano wrote: >> Brandon Casey writes: >> >>> So is there any reason why didn't do something like the following in >>> the first place? >> >>

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Brandon Casey
On Wed, Aug 23, 2017 at 2:04 PM, Junio C Hamano wrote: > Brandon Casey writes: > >> So is there any reason why didn't do something like the following in >> the first place? > > My guess is that we didn't bother; if we cared, we would have used a > single

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Junio C Hamano
Brandon Casey writes: > So is there any reason why didn't do something like the following in > the first place? My guess is that we didn't bother; if we cared, we would have used a single instance of const char in a read-only segment, instead of such a macro. > diff --git

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Brandon Casey
On Mon, Aug 21, 2017 at 10:43 AM, Martin Ågren wrote: > strbuf_setlen(., 0) writes '\0' to sb.buf[0], where buf is either > allocated and unique to sb, or the global slopbuf. The slopbuf is meant > to provide a guarantee that buf is not NULL and that a freshly >

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Junio C Hamano
Martin Ågren writes: > On 23 August 2017 at 19:24, Junio C Hamano wrote: >> Martin Ågren writes: >> >>> strbuf_setlen(., 0) writes '\0' to sb.buf[0], where buf is either >>> allocated and unique to sb, or the global slopbuf.

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Martin Ågren
On 23 August 2017 at 19:24, Junio C Hamano wrote: > Martin Ågren writes: > >> strbuf_setlen(., 0) writes '\0' to sb.buf[0], where buf is either >> allocated and unique to sb, or the global slopbuf. The slopbuf is meant >> to provide a guarantee that buf

Re: [PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-23 Thread Junio C Hamano
Martin Ågren writes: > strbuf_setlen(., 0) writes '\0' to sb.buf[0], where buf is either > allocated and unique to sb, or the global slopbuf. The slopbuf is meant > to provide a guarantee that buf is not NULL and that a freshly > initialized buffer contains the empty

[PATCH v2 3/4] strbuf_setlen: don't write to strbuf_slopbuf

2017-08-21 Thread Martin Ågren
strbuf_setlen(., 0) writes '\0' to sb.buf[0], where buf is either allocated and unique to sb, or the global slopbuf. The slopbuf is meant to provide a guarantee that buf is not NULL and that a freshly initialized buffer contains the empty string, but it is not supposed to be written to. That