Merge tag 'trace-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux...
[linux-2.6-block.git] / tools / perf / util / probe-event.c
index a7ca17be5fc5019de54fa81088fd1378e5fc9178..cd1eb73cfe8316c3dd9c7462f787ce1c0f540d7a 100644 (file)
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * probe-event.c : perf-probe definition to probe_events format converter
  *
  * Written by Masami Hiramatsu <mhiramat@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
  */
 
 #include <inttypes.h>
@@ -33,7 +19,6 @@
 #include <limits.h>
 #include <elf.h>
 
-#include "util.h"
 #include "event.h"
 #include "namespaces.h"
 #include "strlist.h"
@@ -53,7 +38,8 @@
 #include "session.h"
 #include "string2.h"
 
-#include "sane_ctype.h"
+#include <linux/ctype.h>
+#include <linux/zalloc.h>
 
 #define PERFPROBE_GROUP "probe"
 
@@ -228,9 +214,9 @@ out:
 
 static void clear_perf_probe_point(struct perf_probe_point *pp)
 {
-       free(pp->file);
-       free(pp->function);
-       free(pp->lazy_line);
+       zfree(&pp->file);
+       zfree(&pp->function);
+       zfree(&pp->lazy_line);
 }
 
 static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
@@ -1189,12 +1175,11 @@ int show_available_vars(struct perf_probe_event *pevs __maybe_unused,
 
 void line_range__clear(struct line_range *lr)
 {
-       free(lr->function);
-       free(lr->file);
-       free(lr->path);
-       free(lr->comp_dir);
+       zfree(&lr->function);
+       zfree(&lr->file);
+       zfree(&lr->path);
+       zfree(&lr->comp_dir);
        intlist__delete(lr->line_list);
-       memset(lr, 0, sizeof(*lr));
 }
 
 int line_range__init(struct line_range *lr)
@@ -2228,15 +2213,15 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
        struct perf_probe_arg_field *field, *next;
        int i;
 
-       free(pev->event);
-       free(pev->group);
-       free(pev->target);
+       zfree(&pev->event);
+       zfree(&pev->group);
+       zfree(&pev->target);
        clear_perf_probe_point(&pev->point);
 
        for (i = 0; i < pev->nargs; i++) {
-               free(pev->args[i].name);
-               free(pev->args[i].var);
-               free(pev->args[i].type);
+               zfree(&pev->args[i].name);
+               zfree(&pev->args[i].var);
+               zfree(&pev->args[i].type);
                field = pev->args[i].field;
                while (field) {
                        next = field->next;
@@ -2245,8 +2230,7 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
                        field = next;
                }
        }
-       free(pev->args);
-       memset(pev, 0, sizeof(*pev));
+       zfree(&pev->args);
 }
 
 #define strdup_or_goto(str, label)     \
@@ -2327,15 +2311,15 @@ void clear_probe_trace_event(struct probe_trace_event *tev)
        struct probe_trace_arg_ref *ref, *next;
        int i;
 
-       free(tev->event);
-       free(tev->group);
-       free(tev->point.symbol);
-       free(tev->point.realname);
-       free(tev->point.module);
+       zfree(&tev->event);
+       zfree(&tev->group);
+       zfree(&tev->point.symbol);
+       zfree(&tev->point.realname);
+       zfree(&tev->point.module);
        for (i = 0; i < tev->nargs; i++) {
-               free(tev->args[i].name);
-               free(tev->args[i].value);
-               free(tev->args[i].type);
+               zfree(&tev->args[i].name);
+               zfree(&tev->args[i].value);
+               zfree(&tev->args[i].type);
                ref = tev->args[i].ref;
                while (ref) {
                        next = ref->next;
@@ -2343,8 +2327,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev)
                        ref = next;
                }
        }
-       free(tev->args);
-       memset(tev, 0, sizeof(*tev));
+       zfree(&tev->args);
 }
 
 struct kprobe_blacklist_node {
@@ -2361,8 +2344,8 @@ static void kprobe_blacklist__delete(struct list_head *blacklist)
        while (!list_empty(blacklist)) {
                node = list_first_entry(blacklist,
                                        struct kprobe_blacklist_node, list);
-               list_del(&node->list);
-               free(node->symbol);
+               list_del_init(&node->list);
+               zfree(&node->symbol);
                free(node);
        }
 }