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

Re: [PATCH 0/3] Fix code issues spotted by clang

From
Elijah Newren <newren@gmail.com>
Date
Nov 8, 2011, 16:05 UTC
Message-ID
<CABPp-BFm-BYPuGzp4hpH2ub_GBLWcZMKt8=rOR683_-+HFbb5A@mail.gmail.com>
In-Reply-To
<CACBZZX7bzFy_NCr4RTpYXXVmieaV7GrBfJgwdtCT1SwoXV_cGA@mail.gmail.com>

On Sun, Nov 6, 2011 at 5:33 AM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 20 quoted lines
>    "builtin/fast-export.c", line 54: warning: enum type mismatch: op "="
>
> This seems to me to be a legitimate issue we introduced in
> 2d8ad46919213ebbd7bb72eb5b56cca8cc3ae07f, Elijah?
>
> We're defining an enum like this:
>
>    static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
>    static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
>
> And then doing:
>
>        if (unset || !strcmp(arg, "abort"))
>                tag_of_filtered_mode = ABORT; <-- Line 54
>        else if (!strcmp(arg, "drop"))
>                tag_of_filtered_mode = DROP;
>        else if (!strcmp(arg, "rewrite"))
>                tag_of_filtered_mode = REWRITE;
>
> Presumably that assignment should be "= ERROR".

Looking back at that patch, "abort" was the word that made the most sense in the documentation and I was trying to make the code match. Unfortunately, that would result in "ABORT" being redefined (to the same value) so to squelch the compiler error I just went with the quick hack of changing "ABORT" in the enum definition to "ERROR", but didn't change "ABORT" later since "it had the same value anyway". Yeah, not the safest programming practice.

I probably should have just used FILTERED_TAG_ABORT and changed the signed_tag_mode enum to use SIGNED_TAG_ABORT (and then changed all references to "ABORT" to match one of those two)...or maybe somehow come up with a combined enum used for both (though WARN would only be useful fo signed_tag_mode, REWRITE would only be useful for tag_of_filtered_mode, etc.).

Previous: Ævar Arnfjörð Bjarmason
Message 22 of 22 in “Fix code issues spotted by clang”
  1. 0/3 Fix code issues spotted by clangÆvar Arnfjörð Bjarmason, Nov 6, 2011
  2. 1/3 apply: get rid of useless x < 0 comparison on a size_t typeÆvar Arnfjörð Bjarmason, Nov 6, 2011
  3. Junio C HamanoNov 6, 2011
  4. Giuseppe BilottaNov 7, 2011
  5. 2/3 diff/apply: cast variable in call to free()Ævar Arnfjörð Bjarmason, Nov 6, 2011
  6. 3/3 grep: get rid of useless x < 0 comparison on an enum memberÆvar Arnfjörð Bjarmason, Nov 6, 2011
  7. Andreas SchwabNov 6, 2011
  8. Ævar Arnfjörð BjarmasonNov 7, 2011
  9. Andreas SchwabNov 7, 2011
  10. Jeff KingNov 7, 2011
  11. Andreas SchwabNov 7, 2011
  12. Jeff KingNov 7, 2011
  13. Jeff KingNov 7, 2011
  14. Ævar Arnfjörð BjarmasonNov 7, 2011
  15. Andreas SchwabNov 7, 2011
  16. Jonathan NiederNov 7, 2011
  17. Junio C HamanoNov 7, 2011
  18. Jonathan NiederNov 7, 2011
  19. Junio C HamanoNov 7, 2011
  20. Jonathan NiederNov 7, 2011
  21. Ævar Arnfjörð BjarmasonNov 6, 2011
  22. Elijah NewrenNov 8, 2011

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.