Re: [Intel-gfx] [PATCH i-g-t] i915/gem_exec_capture: Check the strlen() for an empty file

2019-01-29 Thread Antonio Argenziano



On 29/01/19 03:24, Chris Wilson wrote:

igt_sysfs_get() only returns NULL if the open() fails, and a valid
string otherwise. So if the read() fails with ENODEV (because sysfs
doesn't provide the driver with an ->open() callback), we return an
empty string, and "No error captured" otherwise.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109481
Signed-off-by: Chris Wilson 


LGTM.

Reviwed-by: Antonio Argenziano 


---
  tests/i915/gem_exec_capture.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index eca73ab11..56837dfca 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -519,6 +519,11 @@ static bool has_capture(int fd)
return async > 0;
  }
  
+static size_t safer_strlen(const char *s)

+{
+   return s ? strlen(s) : 0;
+}
+
  igt_main
  {
const struct intel_execution_engine *e;
@@ -544,7 +549,7 @@ igt_main
  
  		dir = igt_sysfs_open(fd, NULL);

igt_require(igt_sysfs_set(dir, "error", "Begone!"));
-   igt_require(igt_sysfs_get(dir, "error"));
+   igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0);
}
  
  	for (e = intel_execution_engines; e->name; e++) {



___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] i915/gem_exec_capture: Check the strlen() for an empty file

2019-01-29 Thread Chris Wilson
igt_sysfs_get() only returns NULL if the open() fails, and a valid
string otherwise. So if the read() fails with ENODEV (because sysfs
doesn't provide the driver with an ->open() callback), we return an
empty string, and "No error captured" otherwise.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109481
Signed-off-by: Chris Wilson 
---
 tests/i915/gem_exec_capture.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index eca73ab11..56837dfca 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -519,6 +519,11 @@ static bool has_capture(int fd)
return async > 0;
 }
 
+static size_t safer_strlen(const char *s)
+{
+   return s ? strlen(s) : 0;
+}
+
 igt_main
 {
const struct intel_execution_engine *e;
@@ -544,7 +549,7 @@ igt_main
 
dir = igt_sysfs_open(fd, NULL);
igt_require(igt_sysfs_set(dir, "error", "Begone!"));
-   igt_require(igt_sysfs_get(dir, "error"));
+   igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0);
}
 
for (e = intel_execution_engines; e->name; e++) {
-- 
2.20.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx