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

[PATCH v4 0/6] Add a FREE_AND_NULL() wrapper macro

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 15, 2017, 23:15 UTC
Message-ID
<20170615231549.20085-1-avarab@gmail.com>
In-Reply-To
<xmqqa858zzb3.fsf@gitster.mtv.corp.google.com>

I didn't know about the coccinelle semantic patch facility. This adds coccinelle rules to do the code changes, and adds subsequent follow-up commits which apply that change, with the series ending with a patch that I manually authored.

This fixes a bug in earlier versions of the series. I was mistakenly freeing the wrong thing in the tree-walk.c change, that change is now gone, and all the changes not made by coccinelle are in one commit, making it easier to review.

Ævar Arnfjörð Bjarmason (6):
  git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr =
    NULL
  coccinelle: add a rule to make "type" code use FREE_AND_NULL()
  coccinelle: make use of the "type" FREE_AND_NULL() rule
  coccinelle: add a rule to make "expression" code use FREE_AND_NULL()
  coccinelle: make use of the "expression" FREE_AND_NULL() rule
  *.[ch] refactoring: make use of the FREE_AND_NULL() macro
 alias.c                       |  6 ++----
 apply.c                       |  3 +--
 attr.c                        |  6 ++----
 blame.c                       |  3 +--
 branch.c                      |  3 +--
 builtin/am.c                  | 18 +++++-------------
 builtin/clean.c               |  6 ++----
 builtin/config.c              |  6 ++----
 builtin/index-pack.c          |  6 ++----
 builtin/pack-objects.c        | 12 ++++--------
 builtin/unpack-objects.c      |  3 +--
 builtin/worktree.c            |  6 ++----
 commit-slab.h                 |  3 +--
 commit.c                      |  3 +--
 config.c                      |  3 +--
 contrib/coccinelle/free.cocci | 15 +++++++++++++++
 credential.c                  |  9 +++------
 diff-lib.c                    |  3 +--
 diff.c                        |  6 ++----
 diffcore-rename.c             |  6 ++----
 dir.c                         |  9 +++------
 fast-import.c                 |  6 ++----
 git-compat-util.h             |  6 ++++++
 gpg-interface.c               | 15 +++++----------
 grep.c                        | 12 ++++--------
 help.c                        |  3 +--
 http-push.c                   | 24 ++++++++----------------
 http.c                        | 15 +++++----------
 imap-send.c                   |  3 +--
 line-log.c                    |  6 ++----
 ll-merge.c                    |  3 +--
 mailinfo.c                    |  3 +--
 object.c                      |  3 +--
 pathspec.c                    |  3 +--
 prio-queue.c                  |  3 +--
 read-cache.c                  |  6 ++----
 ref-filter.c                  |  3 +--
 refs/files-backend.c          |  3 +--
 refs/ref-cache.c              |  3 +--
 remote-testsvn.c              |  3 +--
 rerere.c                      |  3 +--
 sequencer.c                   |  3 +--
 sha1-array.c                  |  3 +--
 sha1_file.c                   |  3 +--
 split-index.c                 |  3 +--
 transport-helper.c            | 27 +++++++++------------------
 transport.c                   |  3 +--
 tree-diff.c                   |  6 ++----
 tree.c                        |  3 +--
 49 files changed, 117 insertions(+), 195 deletions(-)
-- 
2.13.1.508.gb3defc5cc
Next: Ævar Arnfjörð Bjarmason
Message 1 of 18 in “Add a FREE_AND_NULL() wrapper macro”
  1. 0/6 Add a FREE_AND_NULL() wrapper macroÆvar Arnfjörð Bjarmason, Jun 15, 2017
  2. 6/6 *.[ch] refactoring: make use of the FREE_AND_NULL() macroÆvar Arnfjörð Bjarmason, Jun 15, 2017
  3. 2/6 coccinelle: add a rule to make "type" code use FREE_AND_NULL()Ævar Arnfjörð Bjarmason, Jun 15, 2017
  4. 1/6 git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULLÆvar Arnfjörð Bjarmason, Jun 15, 2017
  5. 4/6 coccinelle: add a rule to make "expression" code use FREE_AND_NULL()Ævar Arnfjörð Bjarmason, Jun 15, 2017
  6. Junio C HamanoJun 16, 2017
  7. René ScharfeJun 25, 2017
  8. Ævar Arnfjörð BjarmasonJun 28, 2017
  9. Junio C HamanoJun 28, 2017
  10. Ævar Arnfjörð BjarmasonJun 28, 2017
  11. René ScharfeJun 28, 2017
  12. Ævar Arnfjörð BjarmasonJun 28, 2017
  13. Junio C HamanoJun 28, 2017
  14. René ScharfeJun 28, 2017
  15. Ævar Arnfjörð BjarmasonJun 28, 2017
  16. René ScharfeJun 28, 2017
  17. 5/6 coccinelle: make use of the "expression" FREE_AND_NULL() ruleÆvar Arnfjörð Bjarmason, Jun 15, 2017
  18. 3/6 coccinelle: make use of the "type" FREE_AND_NULL() ruleÆvar Arnfjörð Bjarmason, Jun 15, 2017

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.