From: Bastian Dehn Date: Fri, 17 May 2024 20:32:31 +0000 (+0200) Subject: refactor get max len X-Git-Tag: v1.0.3^2~9 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=607642fac31230e00f329771c835a468a8c1301a;p=sane-kds-s2000w-net.git refactor get max len --- 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)