git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 30/32] ident.c: fix LGTM warning on the possible abuse of the '=' operator

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Nov 4, 2019, 13:55 UTC
Message-ID
<CA+EOSBncQa0h1of+R2BBSw=tSNFmSASi2V5EJPaRNEO_ctvbkw@mail.gmail.com>
In-Reply-To
<20191104102612.GE4348@szeder.dev>

Il giorno lun 4 nov 2019 alle ore 11:26 SZEDER Gábor <szeder.dev@gmail.com> ha scritto:

Show 8 quoted lines
>
> On Mon, Nov 04, 2019 at 09:59:21AM +0000, Elia Pinto wrote:
> > Fix the LGTM warning of the rule that finds uses of the assignment
>
> What is an "LGTM warning"?
>
> I think including the actual compiler warning in the commit message
> would be great.
Yes indeed. I thought I did it, do you think i can do better? Thanks
https://lgtm.com/rules/2158670641/
Show 37 quoted lines
>
> > operator = in places where the equality operator == would
> > make more sense.
> >
> > Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
> > ---
> >  ident.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/ident.c b/ident.c
> > index e666ee4e59..07f2f03b0a 100644
> > --- a/ident.c
> > +++ b/ident.c
> > @@ -172,12 +172,15 @@ const char *ident_default_email(void)
> >                       strbuf_addstr(&git_default_email, email);
> >                       committer_ident_explicitly_given |= IDENT_MAIL_GIVEN;
> >                       author_ident_explicitly_given |= IDENT_MAIL_GIVEN;
> > -             } else if ((email = query_user_email()) && email[0]) {
> > -                     strbuf_addstr(&git_default_email, email);
> > -                     free((char *)email);
> > -             } else
> > -                     copy_email(xgetpwuid_self(&default_email_is_bogus),
> > +             } else {
> > +                     email = query_user_email();
> > +                     if (email && email[0]) {
> > +                             strbuf_addstr(&git_default_email, email);
> > +                             free((char *)email);
> > +                     } else
> > +                             copy_email(xgetpwuid_self(&default_email_is_bogus),
> >                                  &git_default_email, &default_email_is_bogus);
> > +             }
> >               strbuf_trim(&git_default_email);
> >       }
> >       return git_default_email.buf;
> > --
> > 2.24.0.rc0.467.g566ccdd3e4.dirty
> >
Previous: SZEDER GáborNext: Phillip Wood
Message 11 of 15 in “ident.c: fix LGTM warning on the possible abuse of the '=' operator”
  1. 30/32 ident.c: fix LGTM warning on the possible abuse of the '=' operatorElia Pinto, Nov 4, 2019
  2. 31/32 commit-graph.c: fix code that could convert the result of an integer multiplication to a larger typeElia Pinto, Nov 4, 2019
  3. Junio C HamanoNov 6, 2019
  4. Danh DoanNov 7, 2019
  5. Junio C HamanoNov 7, 2019
  6. Danh DoanNov 7, 2019
  7. Johannes SchindelinNov 7, 2019
  8. Johannes SchindelinNov 7, 2019
  9. 32/32 date.c: fix code that may overflow 'int' before it is converted to 'time_t'Elia Pinto, Nov 4, 2019
  10. SZEDER GáborNov 4, 2019
  11. Elia PintoNov 4, 2019
  12. Phillip WoodNov 4, 2019
  13. Elia PintoNov 4, 2019
  14. Junio C HamanoNov 6, 2019
  15. Johannes SchindelinNov 6, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.