From: Swen Schillig Date: Thu, 9 Aug 2018 07:15:36 +0000 (+0200) Subject: ctdb: Replace calculation of bytes to read from socket by MIN() macro X-Git-Tag: tdb-1.3.17~2105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8262efbc96b06535b5d29395c71d5fa4e0d8bc63;p=thirdparty%2Fsamba.git ctdb: Replace calculation of bytes to read from socket by MIN() macro The calculation of the bytes to read from the socket can be done easier by the usage of the common MIN() macro. Signed-off-by: Swen Schillig Reviewed-by: Martin Schwenke Reviewed-by: Jeremy Allison --- diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c index da444aca2b6..698febd0847 100644 --- a/ctdb/common/ctdb_io.c +++ b/ctdb/common/ctdb_io.c @@ -160,7 +160,6 @@ static void queue_io_read(struct ctdb_queue *queue) int num_ready = 0; ssize_t nread; uint8_t *data; - int navail; /* check how much data is available on the socket for immediately guaranteed nonblocking access. @@ -196,10 +195,7 @@ static void queue_io_read(struct ctdb_queue *queue) queue->buffer.extend = 0; } - navail = queue->buffer.size - queue->buffer.length; - if (num_ready > navail) { - num_ready = navail; - } + num_ready = MIN(num_ready, queue->buffer.size - queue->buffer.length); if (num_ready > 0) { nread = sys_read(queue->fd,