All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: <igt-dev@lists.freedesktop.org>,
	<intel-gfx@lists.freedesktop.org>,
	<intel-xe@lists.freedesktop.org>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Jonathan Cavitt <jonathan.cavitt@intel.com>
Subject: Re: [PATCH i-g-t] lib/kunit: Read results from debugfs
Date: Thu, 28 Mar 2024 08:09:33 -0500	[thread overview]
Message-ID: <kcd7mkgkxuemwv5zgihvofmlrmyrhkyauqwzgd3ijtx3ntmmis@6qxhiky4c2a2> (raw)
In-Reply-To: <2598806.Lt9SDvczpP@jkrzyszt-mobl2.ger.corp.intel.com>

On Wed, Mar 27, 2024 at 10:54:53PM +0100, Janusz Krzysztofik wrote:
>> >+static DIR *kunit_debugfs_open(void)
>> >+{
>> >+	const char *debugfs_path = igt_debugfs_mount();
>> >+	int debugfs_fd, kunit_fd;
>> >+	DIR *kunit_dir;
>> >+
>> >+	if (igt_debug_on(!debugfs_path))
>> >+		return NULL;
>> >+
>> >+	debugfs_fd = open(debugfs_path, O_DIRECTORY);
>> >+	if (igt_debug_on(debugfs_fd < 0))
>> >+		return NULL;
>> >+
>> >+	kunit_fd = openat(debugfs_fd, "kunit", O_DIRECTORY);
>> >+	close(debugfs_fd);
>> >+	if (igt_debug_on(kunit_fd < 0))
>> >+		return NULL;
>> >+
>> >+	kunit_dir = fdopendir(kunit_fd);
>> >+	if (igt_debug_on(!kunit_dir))
>> >+		close(kunit_fd);
>> >+
>> >+	return kunit_dir;
>>
>>
>> any reason not to use strcat() + return fopen()
>
>To me the code looked simpler than if I copied and concatenated strings to a
>local buffer of fixed size with potential truncation handling.  I guess
>you prefer your pattern over mine, but you haven't explained why.  Would you
>like to convince me?

not really important. It just seems simpler to me, with no calls into
the kernel... completely untested, but something like:

	const char *debugfs_path = igt_debugfs_mount();
	char path[PATH_MAX];

	if (igt_debug_on(!debugfs_path || (strlen(debugfs_path) + strlen("/kunit") >= PATH_MAX)))
		return NULL;

	strcat(stpcpy(path, debugfs_path), "/kunit");

	return opendir(path);

Lucas De Marchi

  parent reply	other threads:[~2024-03-28 13:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 11:22 [PATCH i-g-t] lib/kunit: Read results from debugfs Janusz Krzysztofik
2024-03-27 12:34 ` ✓ Fi.CI.BAT: success for " Patchwork
2024-03-27 12:51 ` ✓ CI.xeBAT: " Patchwork
2024-03-27 12:55 ` ✗ CI.Patch_applied: failure " Patchwork
2024-03-27 16:03 ` [PATCH i-g-t] " Lucas De Marchi
2024-03-27 21:54   ` Janusz Krzysztofik
2024-03-28 12:51     ` Janusz Krzysztofik
2024-03-28 13:09     ` Lucas De Marchi [this message]
2024-03-27 17:27 ` Kamil Konieczny
2024-03-27 22:26   ` Janusz Krzysztofik
2024-03-28 11:24     ` Kamil Konieczny
2024-03-28  2:58 ` ✗ Fi.CI.IGT: failure for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kcd7mkgkxuemwv5zgihvofmlrmyrhkyauqwzgd3ijtx3ntmmis@6qxhiky4c2a2 \
    --to=lucas.demarchi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=janusz.krzysztofik@linux.intel.com \
    --cc=jonathan.cavitt@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.