public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2] chamelium: Handle errors when fetching AdapterAllowed
Date: Wed,  4 Jan 2023 15:10:19 +0200	[thread overview]
Message-ID: <20230104131019.47645-1-petri.latvala@intel.com> (raw)

Not setting AdapterAllowed in .igtrc should be considered a valid
configuration. The default value of 'false' from
g_key_file_get_boolean when the field is missing is exactly what we
want to use, and storing the missing field error in the 'error'
variable leads to an error such as

(kms_chamelium:1713) igt_chamelium-WARNING: Failed to read chamelium port ID for DP-3: Key file does not have key “AdapterAllowed” in group “Chamelium:HDMI-A-2”

v2: Check if the field exists first to get syntax validation
    happening, handle the error accordingly by bailing out (Ryszard)

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Ryszard Knop <ryszard.knop@intel.com>
---
 lib/igt_chamelium.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 79920de1..a235f3c8 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -2476,8 +2476,15 @@ static bool chamelium_read_port_mappings(struct chamelium *chamelium,
 			goto out;
 		}
 
-		port->adapter_allowed = g_key_file_get_boolean(igt_key_file, group,
-		                                               "AdapterAllowed", &error);
+		if (g_key_file_has_key(igt_key_file, group, "AdapterAllowed", NULL)) {
+			port->adapter_allowed = g_key_file_get_boolean(igt_key_file, group,
+								       "AdapterAllowed", &error);
+			if (error) {
+				igt_warn("Unable to read AdapterAllowed: %s\n", error->message);
+				ret = false;
+				goto out;
+			}
+		}
 
 		for (j = 0;
 		     j < res->count_connectors && !port->connector_id;
-- 
2.30.2

             reply	other threads:[~2023-01-04 13:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 13:10 Petri Latvala [this message]
2023-01-04 14:30 ` [igt-dev] [PATCH i-g-t v2] chamelium: Handle errors when fetching AdapterAllowed Knop, Ryszard
2023-01-04 17:44 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-01-04 22:41 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20230104131019.47645-1-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox