From: Patrick Steinhardt Date: Thu, 30 May 2024 11:29:34 GMT Subject: Re: [PATCH 01/19] global: improve const correctness when assigning string constants Message-ID: In-Reply-To: On Wed, May 29, 2024 at 09:58:56AM -0700, Junio C Hamano wrote: > Patrick Steinhardt writes: > > > We're about to enable `-Wwrite-strings`, which changes the type of > > string constants to `const char[]`. Fix various sites where we assign > > such constants to non-const variables. > > > > Signed-off-by: Patrick Steinhardt > > --- > > This is a noisy change, and it is kind of surprising that ... > > > diff --git a/builtin/bisect.c b/builtin/bisect.c > > index a58432b9d9..dabce9b542 100644 > > --- a/builtin/bisect.c > > +++ b/builtin/bisect.c > > @@ -262,7 +262,8 @@ static int bisect_reset(const char *commit) > > return bisect_clean_state(); > > } > > > > -static void log_commit(FILE *fp, char *fmt, const char *state, > > +static void log_commit(FILE *fp, > > + const char *fmt, const char *state, > > struct commit *commit) > > { > > struct pretty_print_context pp = {0}; > > ... a change like this does not require any other change to the > code inside the function (e.g., by making further cascading changes > to what the function calls). > > But applying this step alone and building would not give us any > constness warning/error from the compiler, so the result looks good > to the compiler, I guess? Yup, any intermediate commit builds with DEVELOPER=1. Patrick