From 607642fac31230e00f329771c835a468a8c1301a Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 17 May 2024 22:32:31 +0200 Subject: [PATCH] refactor get max len --- src/kds_s2000w_net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index e1ec5b0..8375822 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -230,8 +230,9 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data, // calc max length int maxlen = max_length; - if (h->pnm_image->size - h->read_info->read_size < max_length) - maxlen = h->pnm_image->size - h->read_info->read_size; + int rest_size = h->pnm_image->size - h->read_info->read_size; + if (rest_size < max_length) + maxlen = rest_size; // read image if (h->pnm_image->data != NULL && h->read_info->read_size <= 0) -- 2.39.5