public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/igt_eld: fix eld_is_supported failing if not supported
@ 2019-09-13 10:23 Simon Ser
  2019-09-13 10:42 ` Petri Latvala
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Ser @ 2019-09-13 10:23 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

When glob(3) doesn't find any results, it returns GLOB_NOMATCH. I've been
confused by GLOB_NOCHECK's description and thought it would return 0.

Instead of failing on the assert, return that ELDs aren't supported in case
there's no match.

While at it, also include glob's return value in the assert message.

Signed-off-by: Simon Ser <simon.ser@intel.com>
Fixes: 3374cd0b048f ("lib/igt_eld: introduce eld_is_supported")
Cc: Petri Latvala <petri.latvala@intel.com>
---

Sorry about the fuss.

 lib/igt_eld.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/igt_eld.c b/lib/igt_eld.c
index 5d1d8e01cd33..23ebf6305ae0 100644
--- a/lib/igt_eld.c
+++ b/lib/igt_eld.c
@@ -270,11 +270,14 @@ bool eld_has_igt(void)
 bool eld_is_supported(void)
 {
 	glob_t glob_buf = {0};
+	int ret;
 	bool has_elds;

-	igt_assert_f(glob("/proc/asound/card*/" ELD_PREFIX "*",
-			  GLOB_NOSORT, NULL, &glob_buf) == 0,
-		     "glob failed\n");
+	ret = glob("/proc/asound/card*/" ELD_PREFIX "*",
+		   GLOB_NOSORT, NULL, &glob_buf);
+	if (ret == GLOB_NOMATCH)
+		return false;
+	igt_assert_f(ret == 0, "glob failed: %d\n", ret);
 	has_elds = glob_buf.gl_pathc > 0;
 	globfree(&glob_buf);

--
2.23.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-14  8:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-13 10:23 [igt-dev] [PATCH i-g-t] lib/igt_eld: fix eld_is_supported failing if not supported Simon Ser
2019-09-13 10:42 ` Petri Latvala
2019-09-13 10:58   ` Ser, Simon
2019-09-13 12:07 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-09-14  8:36 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox