public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] coccinelle: detect and fix strbuf-by-value parameters
@ 2026-03-15  9:44 Deveshi Dwivedi
  2026-03-15  9:44 ` [PATCH 1/2] coccinelle: detect struct strbuf passed by value Deveshi Dwivedi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Deveshi Dwivedi @ 2026-03-15  9:44 UTC (permalink / raw)
  To: git; +Cc: peff, gitster, Deveshi Dwivedi

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/20260309192600.GC309867@coredump.intra.peff.net/
[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(-)

-- 
2.52.0.230.gd8af7cadaa


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-16 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15  9:44 [PATCH 0/2] coccinelle: detect and fix strbuf-by-value parameters Deveshi Dwivedi
2026-03-15  9:44 ` [PATCH 1/2] coccinelle: detect struct strbuf passed by value Deveshi Dwivedi
2026-03-15  9:44 ` [PATCH 2/2] stash: do not pass strbuf " Deveshi Dwivedi
2026-03-16 15:35 ` [PATCH 0/2] coccinelle: detect and fix strbuf-by-value parameters Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox