perf: Build with warnings and -Werror
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 23 May 2016 21:58:47 +0000 (17:58 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jun 2016 15:48:37 +0000 (11:48 -0400)
And fixes a few warnings.  I noticed this when the compiler didn't complain
about obviously wrong debug code...

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/profile/perf/Makefile
tools/profile/perf/akaros.c
tools/profile/perf/perfconv.c

index 0de3718..bed0460 100644 (file)
@@ -13,7 +13,8 @@ all: perf
 PHONY += perf
 perf: $(SOURCES)
        @echo "  CC      perf"
-       $(Q)$(XCC) -O2 -std=gnu99 -o perf $(SOURCES) $(LIBS)
+       $(Q)$(XCC) -O2 -Wall -Wno-format -Wno-unused -Werror \
+                  -std=gnu99 -o perf $(SOURCES) $(LIBS)
 
 
 PHONY += install
index 7885ffe..62fe493 100644 (file)
@@ -37,7 +37,9 @@ size_t ros_total_cores(void)
 void ros_parse_cores(const char *str, struct core_set *cores)
 {
        unsigned int fcpu, ncpu;
-       char *dstr = xstrdup(str), *tok, *sptr, *sptr2;
+       char *dstr = xstrdup(str);
+       char *sptr = NULL;
+       char *tok, *sptr2;
 
        ZERO_DATA(*cores);
        for (tok = strtok_r(dstr, ":", &sptr); tok;
index 3b8aa92..b62d5ad 100644 (file)
@@ -348,7 +348,8 @@ static void emit_pid_mmap64(struct perf_record *pr,
                                                        struct perfconv_context *cctx)
 {
        struct proftype_pid_mmap64 *rec = (struct proftype_pid_mmap64 *) pr->data;
-       size_t size = sizeof(struct perf_record_mmap) + strlen(rec->path) + 1;
+       size_t size = sizeof(struct perf_record_mmap) +
+                     strlen((char*)rec->path) + 1;
        struct perf_record_mmap *xrec = xzmalloc(size);
 
        xrec->header.type = PERF_RECORD_MMAP;
@@ -358,7 +359,7 @@ static void emit_pid_mmap64(struct perf_record *pr,
        xrec->addr = rec->addr;
        xrec->len = rec->size;
        xrec->pgoff = rec->offset;
-       strcpy(xrec->filename, rec->path);
+       strcpy(xrec->filename, (char*)rec->path);
 
        mem_file_write(&cctx->data, xrec, size, 0);
 
@@ -428,10 +429,10 @@ static void emit_new_process(struct perf_record *pr,
                                                         struct perfconv_context *cctx)
 {
        struct proftype_new_process *rec = (struct proftype_new_process *) pr->data;
-       const char *comm = strrchr(rec->path, '/');
+       const char *comm = strrchr((char*)rec->path, '/');
 
        if (!comm)
-               comm = rec->path;
+               comm = (char*)rec->path;
        else
                comm++;
        emit_comm(rec->pid, comm, cctx);