Re: [PATCH 01/19] global: improve const correctness when assigning string constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 29, 2024 at 09:58:56AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@xxxxxx> 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 <ps@xxxxxx>
> > ---
> 
> 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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux