perf tools: Pass build id object to sysfs__read_build_id()
Passing build id object to sysfs__read_build_id function, so it can populate the size of the build_id object. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20201013192441.1299447-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
f766819cd5
commit
3ff1b8c8cc
@@ -595,13 +595,11 @@ out:
|
||||
|
||||
#endif // HAVE_LIBBFD_BUILDID_SUPPORT
|
||||
|
||||
int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
|
||||
int sysfs__read_build_id(const char *filename, struct build_id *bid)
|
||||
{
|
||||
size_t size = sizeof(bid->data);
|
||||
int fd, err = -1;
|
||||
|
||||
if (size < BUILD_ID_SIZE)
|
||||
goto out;
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
goto out;
|
||||
@@ -622,8 +620,9 @@ int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
|
||||
break;
|
||||
if (memcmp(bf, "GNU", sizeof("GNU")) == 0) {
|
||||
size_t sz = min(descsz, size);
|
||||
if (read(fd, build_id, sz) == (ssize_t)sz) {
|
||||
memset(build_id + sz, 0, size - sz);
|
||||
if (read(fd, bid->data, sz) == (ssize_t)sz) {
|
||||
memset(bid->data + sz, 0, size - sz);
|
||||
bid->size = sz;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user