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

Commit dde755a9 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Use compression id in decompress_kmodule()



Once we parsed out the compression ID, we dont need to iterate all
available compressions and we can call it directly.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180817094813.15086-9-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2af52475
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -244,18 +244,6 @@ bool is_kernel_module(const char *pathname, int cpumode)
	return m.kmod;
}

static bool decompress_to_file(const char *ext, const char *filename, int output_fd)
{
	unsigned i;

	for (i = 0; compressions[i].fmt; i++) {
		if (!strcmp(ext, compressions[i].fmt))
			return !compressions[i].decompress(filename,
							   output_fd);
	}
	return false;
}

bool dso__needs_decompress(struct dso *dso)
{
	return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
@@ -265,31 +253,25 @@ bool dso__needs_decompress(struct dso *dso)
static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
{
	int fd = -1;
	struct kmod_path m;

	if (!dso__needs_decompress(dso))
		return -1;

	if (kmod_path__parse_ext(&m, dso->long_name))
	if (dso->comp == COMP_ID__NONE)
		return -1;

	if (!m.comp)
		goto out;

	fd = mkstemp(tmpbuf);
	if (fd < 0) {
		dso->load_errno = errno;
		goto out;
		return -1;
	}

	if (!decompress_to_file(m.ext, name, fd)) {
	if (compressions[dso->comp].decompress(name, fd)) {
		dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
		close(fd);
		fd = -1;
	}

out:
	free(m.ext);
	return fd;
}