Commit f37a291c authored by Ingo Molnar's avatar Ingo Molnar
Browse files

perf_counter tools: Add more warnings and fix/annotate them



Enable -Wextra. This found a few real bugs plus a number
of signed/unsigned type mismatches/uncleanlinesses. It
also required a few annotations

All things considered it was still worth it so lets try with
this enabled for now.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 88a69dfb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ endif

# CFLAGS and LDFLAGS are for the users to override from the command line.

CFLAGS = $(M64) -ggdb3 -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6
CFLAGS = $(M64) -ggdb3 -Wall -Wextra -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6
LDFLAGS = -lpthread -lrt -lelf -lm
ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
+6 −6
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ static void dsos__fprintf(FILE *fp)

static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
{
	return dso__find_symbol(kernel_dso, ip);
	return dso__find_symbol(dso, ip);
}

static int load_kernel(void)
@@ -203,7 +203,7 @@ static u64 map__map_ip(struct map *map, u64 ip)
	return ip - map->start + map->pgoff;
}

static u64 vdso__map_ip(struct map *map, u64 ip)
static u64 vdso__map_ip(struct map *map __used, u64 ip)
{
	return ip;
}
@@ -600,7 +600,7 @@ static LIST_HEAD(hist_entry__sort_list);

static int sort_dimension__add(char *tok)
{
	int i;
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
		struct sort_dimension *sd = &sort_dimensions[i];
@@ -1069,7 +1069,7 @@ parse_line(FILE *file, struct symbol *sym, u64 start, u64 len)
	static const char *prev_color;
	unsigned int offset;
	size_t line_len;
	u64 line_ip;
	s64 line_ip;
	int ret;
	char *c;

@@ -1428,7 +1428,7 @@ static int __cmd_annotate(void)

	head += size;

	if (offset + head < stat.st_size)
	if (offset + head < (unsigned long)stat.st_size)
		goto more;

	rc = EXIT_SUCCESS;
@@ -1492,7 +1492,7 @@ static void setup_sorting(void)
	free(str);
}

int cmd_annotate(int argc, const char **argv, const char *prefix)
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
	symbol__init();

+4 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 *
 * Builtin help command
 */
#include "perf.h"
#include "util/cache.h"
#include "builtin.h"
#include "util/exec_cmd.h"
@@ -277,7 +278,7 @@ static struct cmdnames main_cmds, other_cmds;

void list_common_cmds_help(void)
{
	int i, longest = 0;
	unsigned int i, longest = 0;

	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
		if (longest < strlen(common_cmds[i].name))
@@ -415,9 +416,10 @@ static void show_html_page(const char *perf_cmd)
	open_html(page_path.buf);
}

int cmd_help(int argc, const char **argv, const char *prefix)
int cmd_help(int argc, const char **argv, const char *prefix __used)
{
	const char *alias;

	load_command_list("perf-", &main_cmds, &other_cmds);

	perf_config(perf_help_config, NULL);
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#include "util/parse-options.h"
#include "util/parse-events.h"

int cmd_list(int argc, const char **argv, const char *prefix)
int cmd_list(int argc __used, const char **argv __used, const char *prefix __used)
{
	print_events();
	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ static void pid_synthesize_mmap_samples(pid_t pid)
	while (1) {
		char bf[BUFSIZ], *pbf = bf;
		struct mmap_event mmap_ev = {
			.header.type = PERF_EVENT_MMAP,
			.header = { .type = PERF_EVENT_MMAP },
		};
		int n;
		size_t size;
@@ -650,7 +650,7 @@ static const struct option options[] = {
	OPT_END()
};

int cmd_record(int argc, const char **argv, const char *prefix)
int cmd_record(int argc, const char **argv, const char *prefix __used)
{
	int counter;

Loading