linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
	Naveen N Rao <naveen@kernel.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Jason Baron <jbaron@akamai.com>, Ard Biesheuvel <ardb@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH v2 2/6] Provide __free(argv) for argv_split() users
Date: Sun,  5 Jan 2025 21:47:56 +0900	[thread overview]
Message-ID: <173608127627.1253657.12054758575695672674.stgit@devnote2> (raw)
In-Reply-To: <173608125422.1253657.3732758016133408588.stgit@devnote2>

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Provide __free(argv) macro for argv_split() users so that they can
avoid gotos.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 Changes in v2:
  - Fix to call argv_free() only if the argument is !IS_ERR_OR_NULL().
  - Add including cleanup.h.
---
 include/linux/string.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 493ac4862c77..07f2a90d5d9c 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -4,6 +4,7 @@
 
 #include <linux/args.h>
 #include <linux/array_size.h>
+#include <linux/cleanup.h>	/* for DEFINE_FREE() */
 #include <linux/compiler.h>	/* for inline */
 #include <linux/types.h>	/* for size_t */
 #include <linux/stddef.h>	/* for NULL */
@@ -312,6 +313,8 @@ extern void *kmemdup_array(const void *src, size_t count, size_t element_size, g
 extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
 extern void argv_free(char **argv);
 
+DEFINE_FREE(argv, char **, if (!IS_ERR_OR_NULL(_T)) argv_free(_T))
+
 /* lib/cmdline.c */
 extern int get_option(char **str, int *pint);
 extern char *get_options(const char *str, int nints, int *ints);


  parent reply	other threads:[~2025-01-05 12:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-05 12:47 [PATCH v2 0/6] tracing/kprobes: Cleanup with guard and __free Masami Hiramatsu (Google)
2025-01-05 12:47 ` [PATCH v2 1/6] tracing/kprobes: Fix to free objects when failed to copy a symbol Masami Hiramatsu (Google)
2025-01-05 12:47 ` Masami Hiramatsu (Google) [this message]
2025-01-05 14:14   ` DEFINE_FREE/CLASS && code readability (Was: [PATCH v2 2/6] Provide __free(argv) for argv_split() users) Oleg Nesterov
2025-01-06 10:26     ` Peter Zijlstra
2025-01-06 11:18       ` Peter Zijlstra
2025-01-06 14:44       ` Oleg Nesterov
2025-01-06 12:19     ` Masami Hiramatsu
2025-01-06 14:33       ` Oleg Nesterov
2025-01-05 12:48 ` [PATCH v2 3/6] tracing: Use __free() for argv in dynevent Masami Hiramatsu (Google)
2025-01-05 12:48 ` [PATCH v2 4/6] tracing: Use __free() in trace_probe for cleanup Masami Hiramatsu (Google)
2025-01-05 12:48 ` [PATCH v2 5/6] tracing: Use __free() for kprobe events to cleanup Masami Hiramatsu (Google)
2025-01-06 10:09   ` Masami Hiramatsu
2025-01-05 12:48 ` [PATCH v2 6/6] tracing/kprobes: Simplify __trace_kprobe_create() by removing gotos Masami Hiramatsu (Google)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=173608127627.1253657.12054758575695672674.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=naveen@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tz.stoyanov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).