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 08/14] perf tools: Do not put a variable sized type not at the end of a struct
Date: Wed, 15 Feb 2017 16:04:18 -0300	[thread overview]
Message-ID: <20170215190424.18687-9-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:

  util/parse-events.c:2024: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-tqocbplnyyhpst6drgm2u4m3@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 07be0762e53e..281e44af31e2 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2020,17 +2020,14 @@ static bool is_event_supported(u8 type, unsigned config)
 		.config = config,
 		.disabled = 1,
 	};
-	struct {
-		struct thread_map map;
-		int threads[1];
-	} tmap = {
-		.map.nr	 = 1,
-		.threads = { 0 },
-	};
+	struct thread_map *tmap = thread_map__new_by_tid(0);
+
+	if (tmap == NULL)
+		return false;
 
 	evsel = perf_evsel__new(&attr);
 	if (evsel) {
-		open_return = perf_evsel__open(evsel, NULL, &tmap.map);
+		open_return = perf_evsel__open(evsel, NULL, tmap);
 		ret = open_return >= 0;
 
 		if (open_return == -EACCES) {
@@ -2042,7 +2039,7 @@ static bool is_event_supported(u8 type, unsigned config)
 			 *
 			 */
 			evsel->attr.exclude_kernel = 1;
-			ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
+			ret = perf_evsel__open(evsel, NULL, tmap) >= 0;
 		}
 		perf_evsel__delete(evsel);
 	}
-- 
2.9.3

  parent reply	other threads:[~2017-02-15 19:06 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 ` [PATCH 07/14] perf record: Do not put a variable sized type not at the end of a struct Arnaldo Carvalho de Melo
2017-02-15 19:04 ` Arnaldo Carvalho de Melo [this message]
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-9-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