]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change optimize get option
authorBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 16:27:45 +0000 (18:27 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 7 Oct 2025 16:27:45 +0000 (18:27 +0200)
src/kds_s2000w_handler_opts.c

index 8ea46f0b6ef33203e3ef6867b998b6337c5c1fe1..2acd93083733bdf204c492824c5a4be6623e3693 100644 (file)
@@ -336,20 +336,17 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value
                _kds_s2000w_handler_opts_set_options(h);
        }
 
-       if (h->current_scanner_config != NULL)
-               config = json_object_object_get(h->current_scanner_config, "Configuration");
+       config = json_object_object_get(h->current_scanner_config, "Configuration");
 
        option_descriptor* descriptor = kds_s2000w_option_descriptors_full_get_by_number(option);
-       json_object* value_object = NULL;
        if (strcmp(descriptor->config_name, OPTION_COUNT) == 0) {
-               config = json_object_object_get(h->current_scanner_config, "Configuration");
-               int32_t* int_value_ptr = (int32_t*) value;
-               *int_value_ptr = kds_s2000w_option_descriptors_get_max_option_count();
+               int32_t* int_value = (int32_t*) value;
+               *int_value = kds_s2000w_option_descriptors_get_max_option_count();
                return;
        }
 
+       json_object* value_object = json_object_object_get(config, descriptor->config_name);
        if (strcmp(descriptor->config_name, SCAN_SOURCE) == 0) {
-               value_object = json_object_object_get(config, descriptor->config_name);
                _kds_s2000w_handler_opts_write_value(value_object, descriptor->descriptor->type, value);
 
                if (strcmp(value, "Flatbed") == 0)
@@ -364,7 +361,6 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value
                return;
        }
 
-       value_object = json_object_object_get(config, descriptor->config_name);
        _kds_s2000w_handler_opts_write_value(value_object, descriptor->descriptor->type, value);
 }