summaryrefslogtreecommitdiff
path: root/src/config-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/config-file.c')
-rw-r--r--src/config-file.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/config-file.c b/src/config-file.c
index 02061ae..033fba2 100644
--- a/src/config-file.c
+++ b/src/config-file.c
@@ -236,7 +236,6 @@ int nv_write_config_file(const char *filename, const CtrlSystem *system,
time_t now;
ReturnStatus status;
CtrlAttributePerms perms;
- NVCTRLAttributeValidValuesRec valid;
CtrlTargetNode *node;
CtrlTarget *t;
char *prefix, scratch[4];
@@ -363,23 +362,18 @@ int nv_write_config_file(const char *filename, const CtrlSystem *system,
continue;
}
- /* Ignore display attributes, they are written later on */
+ /*
+ * Ignore display attributes (they are written later on) and only
+ * write attributes that can be written for an X screen target
+ */
status = NvCtrlGetAttributePerms(t, a->type, a->attr, &perms);
- if (status != NvCtrlSuccess ||
+ if (status != NvCtrlSuccess || !(perms.write) ||
+ !(perms.valid_targets & CTRL_TARGET_PERM_BIT(X_SCREEN_TARGET)) ||
(perms.valid_targets & CTRL_TARGET_PERM_BIT(DISPLAY_TARGET))) {
continue;
}
- /* Only write attributes that can be written */
-
- status = NvCtrlGetValidAttributeValues(t, a->attr, &valid);
- if (status != NvCtrlSuccess ||
- !(valid.permissions & ATTRIBUTE_TYPE_WRITE) ||
- (valid.permissions & ATTRIBUTE_TYPE_DISPLAY)) {;
- continue;
- }
-
status = NvCtrlGetAttribute(t, a->attr, &val);
if (status != NvCtrlSuccess) {
continue;
@@ -468,21 +462,14 @@ int nv_write_config_file(const char *filename, const CtrlSystem *system,
continue;
}
- /* Make sure this is a display attribute */
+ /* Make sure this is a display and writable attribute */
status = NvCtrlGetAttributePerms(t, a->type, a->attr, &perms);
- if (status != NvCtrlSuccess ||
+ if (status != NvCtrlSuccess || !(perms.write) ||
!(perms.valid_targets & CTRL_TARGET_PERM_BIT(DISPLAY_TARGET))) {
continue;
}
- status = NvCtrlGetValidAttributeValues(t, a->attr, &valid);
- if (status != NvCtrlSuccess ||
- !(valid.permissions & ATTRIBUTE_TYPE_WRITE) ||
- !(valid.permissions & ATTRIBUTE_TYPE_DISPLAY)) {
- continue;
- }
-
status = NvCtrlGetAttribute(t, a->attr, &val);
if (status == NvCtrlSuccess) {
fprintf(stream, "%s%c%s=%d\n", prefix,