hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/tools/perf/util/trace-event-read.c
....@@ -1,22 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2009, Steven Rostedt <srostedt@redhat.com>
3
- *
4
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; version 2 of the License (not later!)
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
- *
19
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204 */
215 #include <dirent.h>
226 #include <stdio.h>
....@@ -31,8 +15,6 @@
3115 #include <unistd.h>
3216 #include <errno.h>
3317
34
-#include "../perf.h"
35
-#include "util.h"
3618 #include "trace-event.h"
3719 #include "debug.h"
3820
....@@ -93,7 +75,7 @@
9375 r = size > BUFSIZ ? BUFSIZ : size;
9476 do_read(buf, r);
9577 size -= r;
96
- };
78
+ }
9779 }
9880
9981 static unsigned int read4(struct tep_handle *pevent)
....@@ -102,7 +84,7 @@
10284
10385 if (do_read(&data, 4) < 0)
10486 return 0;
105
- return __data2host4(pevent, data);
87
+ return tep_read_number(pevent, &data, 4);
10688 }
10789
10890 static unsigned long long read8(struct tep_handle *pevent)
....@@ -111,7 +93,7 @@
11193
11294 if (do_read(&data, 8) < 0)
11395 return 0;
114
- return __data2host8(pevent, data);
96
+ return tep_read_number(pevent, &data, 8);
11597 }
11698
11799 static char *read_string(void)
....@@ -241,7 +223,7 @@
241223 * The commit field in the page is of type long,
242224 * use that instead, since it represents the kernel.
243225 */
244
- tep_set_long_size(pevent, pevent->header_page_size_size);
226
+ tep_set_long_size(pevent, tep_get_header_page_size(pevent));
245227 }
246228 free(header_page);
247229
....@@ -297,10 +279,8 @@
297279 }
298280
299281 ret = do_read(buf, size);
300
- if (ret < 0) {
301
- free(buf);
282
+ if (ret < 0)
302283 goto out;
303
- }
304284
305285 ret = parse_event_file(pevent, buf, size, sys);
306286 if (ret < 0)
....@@ -445,7 +425,7 @@
445425
446426 tep_set_flag(pevent, TEP_NSEC_OUTPUT);
447427 tep_set_file_bigendian(pevent, file_bigendian);
448
- tep_set_host_bigendian(pevent, host_bigendian);
428
+ tep_set_local_bigendian(pevent, host_bigendian);
449429
450430 if (do_read(buf, 1) < 0)
451431 goto out;