public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 07/14] perf record: Do not put a variable sized type not at the end of a struct
Date: Wed, 15 Feb 2017 16:04:17 -0300	[thread overview]
Message-ID: <20170215190424.18687-8-acme@kernel.org> (raw)
In-Reply-To: <20170215190424.18687-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

As this is a GNU extension and while harmless in this case, we can do
the same thing in a more clearer way by using an existing thread_map
constructor.

With this we avoid this while compiling with clang:

  builtin-record.c:659:21: error: field 'map' with variable sized type 'struct thread_map' not at the end of a struct or class is a GNU extension
        [-Werror,-Wgnu-variable-sized-type-not-at-end]
                  struct thread_map map;
                                    ^
  1 error generated.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-c9drclo52ezxmwa7qxklin2y@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2ddf189968dc..6cd6776052e7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -655,22 +655,23 @@ record__finish_output(struct record *rec)
 
 static int record__synthesize_workload(struct record *rec, bool tail)
 {
-	struct {
-		struct thread_map map;
-		struct thread_map_data map_data;
-	} thread_map;
+	int err;
+	struct thread_map *thread_map;
 
 	if (rec->opts.tail_synthesize != tail)
 		return 0;
 
-	thread_map.map.nr = 1;
-	thread_map.map.map[0].pid = rec->evlist->workload.pid;
-	thread_map.map.map[0].comm = NULL;
-	return perf_event__synthesize_thread_map(&rec->tool, &thread_map.map,
+	thread_map = thread_map__new_by_tid(rec->evlist->workload.pid);
+	if (thread_map == NULL)
+		return -1;
+
+	err = perf_event__synthesize_thread_map(&rec->tool, thread_map,
 						 process_synthesized_event,
 						 &rec->session->machines.host,
 						 rec->opts.sample_address,
 						 rec->opts.proc_map_timeout);
+	thread_map__put(thread_map);
+	return err;
 }
 
 static int record__synthesize(struct record *rec, bool tail);
-- 
2.9.3

  parent reply	other threads:[~2017-02-15 19:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 19:04 [GIT PULL 00/14] perf/core clang fixes Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 01/14] tools: Suppress request for warning options not existent in clang Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 02/14] tools: Set the maximum optimization level according to the compiler being used Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 03/14] tools lib subcmd: Make it an error to pass a signed value to OPTION_UINTEGER Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 04/14] Revert "perf bench futex: Sanitize numeric parameters" Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 05/14] perf bench numa: Make sure dprintf() is not defined Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 06/14] perf tests: Synthesize struct instead of using field after variable sized type Arnaldo Carvalho de Melo
2017-02-15 19:04 ` Arnaldo Carvalho de Melo [this message]
2017-02-15 19:04 ` [PATCH 08/14] perf tools: Do not put a variable sized type not at the end of a struct Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 09/14] perf probe: Avoid accessing uninitialized 'map' variable Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 10/14] perf evsel: Do not put a variable sized type not at the end of a struct Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 11/14] perf intel pt decoder: clang has no -Wno-override-init Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 12/14] perf tools: Be consistent on the type of map->symbols[] interator Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 13/14] perf pmu: Fix check for unset alias->unit array Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 14/14] perf tools: Add missing parse_events_error() prototype Arnaldo Carvalho de Melo
2017-02-16 19:54 ` [GIT PULL 00/14] perf/core clang fixes Ingo Molnar

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=20170215190424.18687-8-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.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