Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cbef79a8 authored by Randy Dunlap's avatar Randy Dunlap Committed by Ingo Molnar
Browse files

perf tools: Fix const char type propagation



The following perf build warnings/errors in function
argument types:

  builtin-sched.c:1894: warning: passing argument 1 of 'sort_dimension__add' discards qualifiers from pointer target type
  util/trace-event-parse.c:685: warning: passing argument 2 of 'read_expected' discards qualifiers from pointer target type
  util/trace-event-parse.c:741: warning: passing argument 4 of 'test_type_token' discards qualifiers from pointer target type
  util/trace-event-parse.c:706: warning: passing argument 2 of 'read_expected_item' discards qualifiers from pointer target type

... trigger because older GCC is not able to prove that
sort_dimension__add() does not change the string.

Some goes for test_type_token().

Fix this by improving type consistency.

Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <20091005131729.78444bfb.randy.dunlap@oracle.com>
[ Also remove ugly type cast now unnecessary. ]
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent d93a8f82
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1287,7 +1287,7 @@ static struct sort_dimension *available_sorts[] = {


static LIST_HEAD(sort_list);
static LIST_HEAD(sort_list);


static int sort_dimension__add(char *tok, struct list_head *list)
static int sort_dimension__add(const char *tok, struct list_head *list)
{
{
	int i;
	int i;


@@ -1917,7 +1917,7 @@ static void setup_sorting(void)


	free(str);
	free(str);


	sort_dimension__add((char *)"pid", &cmp_pid);
	sort_dimension__add("pid", &cmp_pid);
}
}


static const char *record_args[] = {
static const char *record_args[] = {
+4 −4
Original line number Original line Diff line number Diff line
@@ -618,7 +618,7 @@ static int test_type(enum event_type type, enum event_type expect)
}
}


static int test_type_token(enum event_type type, char *token,
static int test_type_token(enum event_type type, char *token,
		    enum event_type expect, char *expect_tok)
		    enum event_type expect, const char *expect_tok)
{
{
	if (type != expect) {
	if (type != expect) {
		die("Error: expected type %d but read %d",
		die("Error: expected type %d but read %d",
@@ -650,7 +650,7 @@ static int read_expect_type(enum event_type expect, char **tok)
	return __read_expect_type(expect, tok, 1);
	return __read_expect_type(expect, tok, 1);
}
}


static int __read_expected(enum event_type expect, char *str, int newline_ok)
static int __read_expected(enum event_type expect, const char *str, int newline_ok)
{
{
	enum event_type type;
	enum event_type type;
	char *token;
	char *token;
@@ -668,12 +668,12 @@ static int __read_expected(enum event_type expect, char *str, int newline_ok)
	return 0;
	return 0;
}
}


static int read_expected(enum event_type expect, char *str)
static int read_expected(enum event_type expect, const char *str)
{
{
	return __read_expected(expect, str, 1);
	return __read_expected(expect, str, 1);
}
}


static int read_expected_item(enum event_type expect, char *str)
static int read_expected_item(enum event_type expect, const char *str)
{
{
	return __read_expected(expect, str, 0);
	return __read_expected(expect, str, 0);
}
}