perf buildid-list: Show running kernel build id fix
authorMichael Petlan <mpetlan@redhat.com>
Fri, 27 Nov 2015 13:48:09 +0000 (14:48 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 27 Nov 2015 15:24:46 +0000 (12:24 -0300)
The --kernel option of perf buildid-list tool should show the running
kernel buildid.  The functionality has been lost during other changes of
the related code.

The build_id__sprintf() function should return length of the build-id
string,  but it was the length of the build-id raw data instead. Due to
that, some return value checking caused that the final string was not
printed out.

With this patch the build_id__sprintf() returns the correct value, so
the --kernel option works again.

Before:

# perf buildid-list --kernel
#

After:

# perf buildid-list --kernel
972c1edab5bdc06cc224af45d510af662a3c6972
#

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LPU-Reference: 1448632089.24573.114.camel@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/build-id.c

index 217b5a6..6a7e273 100644 (file)
@@ -91,7 +91,7 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf)
                bid += 2;
        }
 
-       return raw - build_id;
+       return (bid - bf) + 1;
 }
 
 int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id)