Skip to contentSkip to conversation

lib/igt_core: Handle glib errors correctly to avoid stderr spew

PATCH Superseded Paul Kocialkowski 2 participants 4 messages Jul 20, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/igt_core: Handle glib errors correctly to avoid stderr spew

This adds the required error clean/free calls after calling configuration parsing functions. In addition to properly handling memory, this avoids glib spewing out error messages on stderr, which breaks the whole CI.

---
 lib/igt_core.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/igt_core.c +10 -1
index 028ef6bd..03d9a5bf 100644
@@ -637,10 +637,16 @@ static int config_parse(void)
 							"FrameDumpPath",
 							&error);
 
+	g_clear_error(&error);
+
 	rc = g_key_file_get_integer(igt_key_file, "DUT", "SuspendResumeDelay",
 				    &error);
-	if (error && error->code == G_KEY_FILE_ERROR_INVALID_VALUE)
+	if (error && error->code == G_KEY_FILE_ERROR_INVALID_VALUE) {
+		g_error_free(error);
 		return -2;
+	}
+
+	g_clear_error(&error);
 
 	if (rc != 0)
 		igt_set_autoresume_delay(rc);
@@ -809,6 +815,7 @@ static int common_init(int *argc, char **argv,
 	ret = g_key_file_load_from_file(igt_key_file, key_file_loc,
 					G_KEY_FILE_NONE, &error);
 	if (error && error->code == G_KEY_FILE_ERROR) {
+		g_error_free(error);
 		g_key_file_free(igt_key_file);
 		igt_key_file = NULL;
 		ret = -2;
@@ -816,6 +823,8 @@ static int common_init(int *argc, char **argv,
 		goto out;
 	}
 
+	g_clear_error(&error);
+
 	ret = config_parse();
 #endif
 
Signature · 6 lines
2.13.2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 6 lines · Paul Kocialkowski

This adds the required error clean/free calls after calling configuration parsing functions. In addition to properly handling memory,
this avoids glib spewing out error messages on stderr, which breaks the
whole CI.

Fixes ee31e0b5 ("Introduce common frame dumping configuration...")
Quoted 46 lines
---
 lib/igt_core.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/igt_core.c +7 -1
index 028ef6bd..03d9a5bf 100644
@@ -637,10 +637,16 @@ static int config_parse(void)
 							"FrameDumpPat
 h",
 							&error);
 
+	g_clear_error(&error);
+
 	rc = g_key_file_get_integer(igt_key_file, "DUT",
 "SuspendResumeDelay",
 				    &error);
-	if (error && error->code == G_KEY_FILE_ERROR_INVALID_VALUE)
+	if (error && error->code == G_KEY_FILE_ERROR_INVALID_VALUE) {
+		g_error_free(error);
 		return -2;
+	}
+
+	g_clear_error(&error);
 
lib/igt_core.c +3 -0
 	if (rc != 0)
 		igt_set_autoresume_delay(rc);
@@ -809,6 +815,7 @@ static int common_init(int *argc, char **argv,
 	ret = g_key_file_load_from_file(igt_key_file, key_file_loc,
 					G_KEY_FILE_NONE, &error);
 	if (error && error->code == G_KEY_FILE_ERROR) {
+		g_error_free(error);
 		g_key_file_free(igt_key_file);
 		igt_key_file = NULL;
 		ret = -2;
@@ -816,6 +823,8 @@ static int common_init(int *argc, char **argv,
 		goto out;
 	}
 
+	g_clear_error(&error);
+
 	ret = config_parse();
 #endif
 
Signature · 6 lines
Paul Kocialkowski <[email protected]>
Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo, Finland
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH v2 1/1 lib/igt_core: Handle glib errors correctly to avoid stderr spew

In reply to Paul Kocialkowski

This adds the required error clean/free calls after calling configuration parsing functions. In addition to properly handling memory, this avoids glib spewing out error messages on stderr, which breaks the whole CI with this message:

GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory. This indicates a bug in someone's code. You must ensure an error is NULL before it's set. The overwriting error message was: Key file does not have group ?DUT?

Fixes ee31e0b5 ("Introduce common frame dumping configuration...")
Cc Paul Kocialkowski <[email protected]>
Cc Martin Peres <[email protected]>
---
 lib/igt_core.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/igt_core.c +10 -1
index 028ef6bd..03d9a5bf 100644
@@ -637,10 +637,16 @@ static int config_parse(void)
 							"FrameDumpPath",
 							&error);
 
+	g_clear_error(&error);
+
 	rc = g_key_file_get_integer(igt_key_file, "DUT", "SuspendResumeDelay",
 				    &error);
-	if (error && error->code == G_KEY_FILE_ERROR_INVALID_VALUE)
+	if (error && error->code == G_KEY_FILE_ERROR_INVALID_VALUE) {
+		g_error_free(error);
 		return -2;
+	}
+
+	g_clear_error(&error);
 
 	if (rc != 0)
 		igt_set_autoresume_delay(rc);
@@ -809,6 +815,7 @@ static int common_init(int *argc, char **argv,
 	ret = g_key_file_load_from_file(igt_key_file, key_file_loc,
 					G_KEY_FILE_NONE, &error);
 	if (error && error->code == G_KEY_FILE_ERROR) {
+		g_error_free(error);
 		g_key_file_free(igt_key_file);
 		igt_key_file = NULL;
 		ret = -2;
@@ -816,6 +823,8 @@ static int common_init(int *argc, char **argv,
 		goto out;
 	}
 
+	g_clear_error(&error);
+
 	ret = config_parse();
 #endif
 
Signature · 6 lines
2.13.2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Acked-by on v2 1/1
#3 lore raw
Quoted 9 lines · Paul Kocialkowski

This adds the required error clean/free calls after calling configuration parsing functions. In addition to properly handling memory, this avoids glib spewing out error messages on stderr, which breaks the whole CI with this message:

GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory. This indicates a bug in someone's code. You must ensure an error is NULL before it's set. The overwriting error message was: Key file does not have group ?DUT?

Quoted 6 lines
Fixes ee31e0b5 ("Introduce common frame dumping configuration...")
Cc Paul Kocialkowski <[email protected]>
Cc Martin Peres <[email protected]>

and pushed.

Signature · 6 lines
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx