From: Bastian Dehn Date: Sun, 9 Feb 2025 18:46:13 +0000 (+0100) Subject: change cancel to bool X-Git-Tag: v1.0.34^2~4 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=656224ccc2888ecd884f270936ecc993f6a069ec;p=sane-kds-s2000w-net.git change cancel to bool --- diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index fc93f23..99bd7f5 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -51,7 +51,7 @@ handler* kds_s2000w_handler_init() h->current_scan_status->complete_scanned = false; h->current_scan_status->feeder = 1; h->read_info->scan_started = false; - h->read_info->cancel = 0; + h->read_info->cancel = false; h->read_info->read_size = 0; h->image->size = 0; h->image->data = NULL; @@ -95,7 +95,7 @@ void kds_s2000w_handler_reset(handler* h) h->current_scan_status->downloaded_images = 0; h->current_scan_status->complete_scanned = false; h->read_info->scan_started = false; - h->read_info->cancel = 0; + h->read_info->cancel = false; h->read_info->read_size = 0; } diff --git a/src/kds_s2000w_handler.h b/src/kds_s2000w_handler.h index 0afd729..2fd321f 100644 --- a/src/kds_s2000w_handler.h +++ b/src/kds_s2000w_handler.h @@ -39,7 +39,7 @@ typedef struct { typedef struct { bool scan_started; - uint8_t cancel; + bool cancel; uint64_t read_size; } readinfo; diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index 0e01aa3..64c3260 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -133,7 +133,7 @@ SANE_Status sane_kds_s2000w_net_start(SANE_Handle handle) return SANE_STATUS_CANCELLED; if (!h->read_info->scan_started) { - h->read_info->cancel = 0; + h->read_info->cancel = false; h->read_info->scan_started = true; kds_s2000w_handler_start_scan(h); } @@ -192,7 +192,7 @@ void sane_kds_s2000w_net_cancel(SANE_Handle handle) handler* h = (handler*) handle; - if (h->read_info->cancel > 0) { + if (h->read_info->cancel) { kds_s2000w_debug_printf(DEBUG, "scan completed canceled"); kds_s2000w_handler_reset(h); kds_s2000w_handler_recreate_session(h); @@ -215,7 +215,7 @@ void sane_kds_s2000w_net_cancel(SANE_Handle handle) } kds_s2000w_debug_printf(DEBUG, "scan canceled"); - h->read_info->cancel = 1; + h->read_info->cancel = true; kds_s2000w_handler_stop_scan(h); } diff --git a/tests/kds_s2000w_net_read_tests.c b/tests/kds_s2000w_net_read_tests.c index cf3c9bc..e597776 100644 --- a/tests/kds_s2000w_net_read_tests.c +++ b/tests/kds_s2000w_net_read_tests.c @@ -75,7 +75,7 @@ void sane_kds_s2000w_net_read_empty_image_test() void sane_kds_s2000w_net_read_bytes_per_line_bigger_test() { handler* h = kds_s2000w_handler_init(); - h->read_info->cancel = 0; + h->read_info->cancel = false; h->read_info->read_size = 0; h->image->size = 95003; h->image->data = malloc(sizeof(char) * 95003); diff --git a/tests/kds_s2000w_net_tests.c b/tests/kds_s2000w_net_tests.c index 05220b8..8d0e21e 100644 --- a/tests/kds_s2000w_net_tests.c +++ b/tests/kds_s2000w_net_tests.c @@ -461,7 +461,7 @@ void sane_kds_s2000w_net_cancel_test() sane_kds_s2000w_net_cancel(h); - assert_int_equal(h->read_info->cancel, 1); + assert_true(h->read_info->cancel); kds_s2000w_client_response_free(resp); resp = NULL; @@ -474,7 +474,7 @@ void sane_kds_s2000w_net_cancel_test() void sane_kds_s2000w_net_cancel_start_test() { handler* h = kds_s2000w_handler_init(); - h->read_info->cancel = 1; + h->read_info->cancel = true; SANE_Status status = sane_kds_s2000w_net_start(h); @@ -503,11 +503,11 @@ void sane_kds_s2000w_net_cancel_canceled_test() expect_function_call(__wrap_kds_s2000w_client_open_session); expect_function_call(__wrap_kds_s2000w_client_set_option); handler* h = kds_s2000w_handler_init(); - h->read_info->cancel = 1; + h->read_info->cancel = true; sane_kds_s2000w_net_cancel(h); - assert_int_equal(h->read_info->cancel, 0); + assert_false(h->read_info->cancel); kds_s2000w_client_response_free(resp_status); resp_status = NULL; @@ -542,7 +542,7 @@ void sane_kds_s2000w_net_cancel_completed_scan_feeder_test() sane_kds_s2000w_net_cancel(h); - assert_int_equal(h->read_info->cancel, 0); + assert_false(h->read_info->cancel); assert_false(h->current_scan_status->complete_scanned); kds_s2000w_client_response_free(resp_status); @@ -592,7 +592,7 @@ void sane_kds_s2000w_net_cancel_completed_scan_flatbed_test() sane_kds_s2000w_net_cancel(h); - assert_int_equal(h->read_info->cancel, 0); + assert_false(h->read_info->cancel); assert_false(h->current_scan_status->complete_scanned); kds_s2000w_client_response_free(resp_status);