Skip to content

coccinelle: detect and fix strbuf-by-value parameters

Deveshi Dwivedi git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2coccinelle: detect struct strbuf passed by valuecontrib/coccinelle/strbuf.cocci+11 -00 replies
2/2stash: do not pass strbuf by valuebuiltin/stash.c+3 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] coccinelle: detect and fix strbuf-by-value parameters

While reviewing the write_worktree_linking_files() fix [1], Jeff King suggested adding a coccinelle rule to detect functions that take struct strbuf by value. I previously posted an RFC discussing such a rule and its implementation [2].

Patch 1/2 adds a coccinelle rule to detect functions that take struct strbuf by value and rewrites the parameter to a pointer to highlight the issue.

Patch 2/2 fixes the one remaining instance found by the rule in stash.c by changing the parameter to struct strbuf * and updating the caller accordingly.

The worktree.c instance that motivated the rule is already fixed by [1], so only the stash.c case remains.

[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/CAG7UgESKLMnO_4+PSJUt-TXJxFQyxEEfpCmJfMmTw2+rhT-HWw@mail.gmail.com/

Deveshi Dwivedi (2):
coccinelle: detect struct strbuf passed by value
stash: do not pass strbuf by value

 builtin/stash.c                 |  6 +++---
 contrib/coccinelle/strbuf.cocci | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
Signature · 1 line
2.52.0.230.gd8af7cadaa