Skip to contentSkip to conversation

lib/igt_core: Avoid stale errno

PATCH In review Sk Anirban 2 participants 2 messages Aug 27 Library code

lore
Share & tools
lore

Sk Anirban

author
#0 lore raw

PATCH 1/1 lib/igt_core: Avoid stale errno

Commit <e311ed2c7> ("lib/igt_core: do not reset errno in igt_gettime") removed an incidental errno reset that used to mask stale errno values at subtest entry. As a result, the errorno left by g_key_file_load_from_file() reaches future tests assertion failures and is printed as a bogus "Last errno" hint.

Fix the root cause by clearing errno.

---
 lib/igt_rc.c | 2 ++
 1 file changed, 2 insertions(+)
lib/igt_rc.c +2 -0
index b7f1731fe..f00840915 100644
@@ -58,5 +58,7 @@ GKeyFile *igt_load_igtrc(void)
 	if (!key_file_env && key_file_loc)
 		free(key_file_loc);
 
+	errno = 0;
+
 	return file;
 }
Signature · 1 line
2.43.0
#1 lore raw

Hi Sk,

Quoted 3 lines · Sk Anirban

Commit <e311ed2c7> ("lib/igt_core: do not reset errno in igt_gettime") removed an incidental errno reset that used to mask stale errno values at subtest entry. As a result, the errorno left by

s/errorno/errno/

Quoted 4 lines

g_key_file_load_from_file() reaches future tests assertion failures and is printed as a bogus "Last errno" hint.

Fix the root cause by clearing errno.

imho this is not a root cause, any call to system can end in setting errno, most common place is drm_open_driver(). I also sumbmitted a change which tries to solve this but it was not merged yet (myabe not a best solution).

Why not just setting errno = 0 at a test?

Quoted 3 lines

---

Please add here a link to case you would like to solve, and just cite few lines from log which seems to you wrong.

lib/igt_rc.c GKeyFile *igt_load_igtrc(void) · line 61

Quoted 12 lines
 lib/igt_rc.c | 2 ++
 1 file changed, 2 insertions(+)
lib/igt_rc.c +1 -0
index b7f1731fe..f00840915 100644
@@ -58,5 +58,7 @@ GKeyFile *igt_load_igtrc(void)
 	if (!key_file_env && key_file_loc)
 		free(key_file_loc);
 
+	errno = 0;

imho this is a wrong place, also not sure if these will help in your case. More proper place would be at end of init sequence in igt_core (at a caller to this function, not here).

Regards,
Kamil

Quoted 6 lines
lib/igt_rc.c +1 -0
+
 	return file;
 }
Signature · 1 line
2.43.0