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

Re: [RFC PATCH 2/2] notes.c: fixed tip when target and append note are both empty

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 18, 2022, 09:23 UTC
Message-ID
<221018.864jw1jxfx.gmgdl@evledraar.gmail.com>
In-Reply-To
<20221018031144.73730-1-tenglong.tl@alibaba-inc.com>
On Tue, Oct 18 2022, Teng Long wrote:
Show 21 quoted lines
> "Ævar Arnfjörð Bjarmason" <avarab@gmail.com> writes:
>
>> Hrm, interesting that (at least my) gcc doesn't catch if we don't
>> NULL-initialize this, but -fanalyzer does (usually it's not needed for
>> such trivial cases0. Anyawy...
>
> On my local env the warnings shows , show I change the line (initialize with
> NULL to "logmsg").
>
> But it seems like different as the last time I built... However now "suggest
> braces around initialization of subobject" appears, is it normal or we should
> repair this?
>
> builtin/merge-file.c:29:23: warning: suggest braces around initialization of subobject [-Wmissing-braces]
>         mmfile_t mmfs[3] = { 0 };
>                              ^
>                              {}
> builtin/merge-file.c:31:20: warning: suggest braces around initialization of subobject [-Wmissing-braces]
>         xmparam_t xmp = { 0 };
>                           ^
>                           {}

The fix for this is in "next": 54795d37d9e (config.mak.dev: disable suggest braces error on old clang versions, 2022-10-10)

Show 15 quoted lines
> 2 warnings generated.
> builtin/notes.c:641:13: warning: variable 'logmsg' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
>         } else if (!cp.buf.len) {
>                    ^~~~~~~~~~~
> builtin/notes.c:653:7: note: uninitialized use occurs here
>         free(logmsg);
>              ^~~~~~
> builtin/notes.c:641:9: note: remove the 'if' if its condition is always false
>         } else if (!cp.buf.len) {
>                ^~~~~~~~~~~~~~~~~~
> builtin/notes.c:570:14: note: initialize the variable 'logmsg' to silence this warning
>         char *logmsg;
>                     ^
>                      = NULL
> 1 warning generated.

Yes, we should initialize it to NULL, so this is the expected warning. Clang spots it.

Previous: Teng LongNext: Teng Long
Message 15 of 91 in “notes.c: introduce "--no-blankline" option”
  1. 0/2 notes.c: introduce "--no-blankline" optionTeng Long, Oct 13, 2022
  2. 1/2 notes.c: introduce "--no-blankline" optionTeng Long, Oct 13, 2022
  3. Junio C HamanoOct 13, 2022
  4. Teng LongOct 17, 2022
  5. Ævar Arnfjörð BjarmasonOct 13, 2022
  6. Teng LongOct 17, 2022
  7. 2/2 notes.c: fixed tip when target and append note are both emptyTeng Long, Oct 13, 2022
  8. Ævar Arnfjörð BjarmasonOct 13, 2022
  9. Phillip WoodOct 13, 2022
  10. Ævar Arnfjörð BjarmasonOct 13, 2022
  11. Phillip WoodOct 15, 2022
  12. Teng LongOct 18, 2022
  13. Teng LongOct 18, 2022
  14. Teng LongOct 18, 2022
  15. Ævar Arnfjörð BjarmasonOct 18, 2022
  16. 0/3 notes.c: introduce "--blank-line" optionTeng Long, Nov 7, 2022
  17. 1/3 notes.c: introduce "--blank-line" optionTeng Long, Nov 7, 2022
  18. Ævar Arnfjörð BjarmasonNov 7, 2022
  19. Eric SunshineNov 7, 2022
  20. Ævar Arnfjörð BjarmasonNov 7, 2022
  21. Taylor BlauNov 7, 2022
  22. Ævar Arnfjörð BjarmasonNov 7, 2022
  23. Taylor BlauNov 8, 2022
  24. Teng LongNov 8, 2022
  25. Teng LongNov 8, 2022
  26. Ævar Arnfjörð BjarmasonNov 8, 2022
  27. Teng LongNov 9, 2022
  28. Ævar Arnfjörð BjarmasonNov 7, 2022
  29. Teng LongNov 8, 2022
  30. Taylor BlauNov 7, 2022
  31. Teng LongNov 8, 2022
  32. 2/3 notes.c: fixed tip when target and append note are both emptyTeng Long, Nov 7, 2022
  33. Ævar Arnfjörð BjarmasonNov 7, 2022
  34. Taylor BlauNov 7, 2022
  35. Ævar Arnfjörð BjarmasonNov 7, 2022
  36. Taylor BlauNov 7, 2022
  37. Teng LongNov 8, 2022
  38. 3/3 notes.c: drop unreachable code in "append_edit()"Teng Long, Nov 7, 2022
  39. Ævar Arnfjörð BjarmasonNov 7, 2022
  40. Ævar Arnfjörð BjarmasonNov 7, 2022
  41. Teng LongNov 9, 2022
  42. Teng LongNov 9, 2022
  43. 0/5 notes.c: introduce "--no-blank-line" optionTeng Long, Nov 9, 2022
  44. 1/5 notes.c: cleanup 'strbuf_grow' call in 'append_edit'Teng Long, Nov 9, 2022
  45. 2/5 notes.c: cleanup for "designated init" and "char ptr init"Teng Long, Nov 9, 2022
  46. 4/5 notes.c: provide tips when target and append note are both emptyTeng Long, Nov 9, 2022
  47. 3/5 notes.c: drop unreachable code in 'append_edit()'Teng Long, Nov 9, 2022
  48. 5/5 notes.c: introduce "--no-blank-line" optionTeng Long, Nov 9, 2022
  49. 0/5 notes.c: introduce "--no-blank-line" optionTeng Long, Nov 28, 2022
  50. Junio C HamanoNov 29, 2022
  51. Taylor BlauNov 29, 2022
  52. Teng LongNov 29, 2022
  53. Junio C HamanoNov 29, 2022
  54. Teng LongDec 15, 2022
  55. Eric SunshineDec 19, 2022
  56. Teng LongDec 21, 2022
  57. Junio C HamanoDec 21, 2022
  58. Teng LongDec 22, 2022
  59. Eric SunshineDec 23, 2022
  60. 0/5 notes.c: introduce "--separator" optioTeng Long, Jan 12, 2023
  61. 1/5 notes.c: cleanup 'strbuf_grow' call in 'append_edit'Teng Long, Jan 12, 2023
  62. Eric SunshineJan 15, 2023
  63. Teng LongJan 28, 2023
  64. 2/5 notes.c: cleanup for "designated init" and "char ptr init"Teng Long, Jan 12, 2023
  65. Ævar Arnfjörð BjarmasonJan 12, 2023
  66. Teng LongJan 28, 2023
  67. 4/5 notes.c: provide tips when target and append note are both emptyTeng Long, Jan 12, 2023
  68. Ævar Arnfjörð BjarmasonJan 12, 2023
  69. Eric SunshineJan 15, 2023
  70. 3/5 notes.c: drop unreachable code in 'append_edit()'Teng Long, Jan 12, 2023
  71. Eric SunshineJan 15, 2023
  72. Eric SunshineJan 15, 2023
  73. Teng LongJan 28, 2023
  74. Eric SunshineJan 30, 2023
  75. Teng LongFeb 1, 2023
  76. 5/5 notes.c: introduce "--separator" optionTeng Long, Jan 12, 2023
  77. Ævar Arnfjörð BjarmasonJan 12, 2023
  78. Eric SunshineJan 15, 2023
  79. Eric SunshineJan 15, 2023
  80. 0/3 notes.c: introduce "--separator" optionTeng Long, Feb 16, 2023
  81. 1/3 notes.c: cleanup 'strbuf_grow' call in 'append_edit'Teng Long, Feb 16, 2023
  82. Junio C HamanoFeb 16, 2023
  83. Teng LongFeb 20, 2023
  84. 2/3 notes.c: cleanup for "designated init"Teng Long, Feb 16, 2023
  85. Junio C HamanoFeb 16, 2023
  86. 3/3 notes.c: introduce "--separator" optionTeng Long, Feb 16, 2023
  87. Junio C HamanoFeb 16, 2023
  88. Teng LongFeb 20, 2023
  89. Junio C HamanoFeb 21, 2023
  90. Teng LongFeb 22, 2023
  91. Junio C HamanoFeb 22, 2023

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.