/* Given a string <path> representing a file path of format: path/to/file.gcda construct and return a new string: <dir>path/to/file.<ext>  */
static char* link_target(const char *dir, const char *path, const char *ext)
/* Given a string <path> representing a file path of format: path/to/file.gcda construct and return a new string: <dir>path/to/file.<ext>  */
static char* link_target(const char *dir, const char *path, const char *ext)
{
	char *target;
	char *old_ext;
	char *copy;
	copy = kstrdup(path, GFP_KERNEL);
	if (!copy)
		return NULL;
	old_ext = strrchr(copy, '.');
	if (old_ext)
		*old_ext = '\0';
	if (dir)
		target = kasprintf(GFP_KERNEL, "%s/%s.%s", dir, copy, ext);
	else
		target = kasprintf(GFP_KERNEL, "%s.%s", copy, ext);
	kfree(copy);
	return target;
}