From e68451dd0aefbeed58fb033dadc3759755d82ebb Mon Sep 17 00:00:00 2001 From: Robert Morell Date: Mon, 5 Feb 2018 10:21:49 -0800 Subject: nvidia-settings: Don't query target relationships for nonexistent targets Currently, nvidia-settings will ask the X driver about the relationships between every type of target it knows about unconditionally. When support for Canoas targets in the X driver was removed (including the NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU attribute), this caused nvidia-settings to trigger a BadMatch error and abort (on GTK2) or print an error about failing to query relationships between targets (on GTK3). This change updates nvidia-settings to not bother to query for relationships for a target when no such targets exist in the system. In addition to fixing the BadMatch described above, it should reduce the startup latency due to fewer server round-trips in the common case. --- src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c b/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c index d358543..f20108d 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c @@ -491,6 +491,12 @@ static void add_target_relationships(CtrlTarget *target, int len; int i; + /* If no targets of this type exist in the system, don't bother querying + * the server about relationships. */ + if (target->system->targets[target_type] == NULL) { + return; + } + status = NvCtrlGetBinaryAttribute(target, 0, attr, (unsigned char **)(&pData), &len); if ((status != NvCtrlSuccess) || !pData) { -- cgit v1.2.3