From 2265d20c1a568c7633d086ccf0233761ff942a2c Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 8 Nov 2004 15:43:21 +0000 Subject: 2004-11-07 Paul Jakma * buffer.c: Add missing include of log.h. (buffer_flush_available) written is compared against mostly against unsigned types, only for the writev do we need signed compare, so declare it as size_t and cast it to ssize_t just for the error compare when we've called writev. * buffer.h: Add comment that buffer data sizes really should be size_t. --- lib/ChangeLog | 12 +++++++++++- lib/buffer.c | 8 +++++--- lib/buffer.h | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index e256bbe4..2acd0023 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,6 +1,16 @@ 2004-11-07 Paul Jakma - * lib/version.h.in: add autoconf configure_input output var + * buffer.c: Add missing include of log.h. + (buffer_flush_available) written is compared against + mostly against unsigned types, only for the writev do we need + signed compare, so declare it as size_t and cast it to ssize_t + just for the error compare when we've called writev. + * buffer.h: Add comment that buffer data sizes really should be + size_t. + +2004-11-07 Paul Jakma + + * version.h.in: add autoconf configure_input output var 2004-11-04 Andrew J. Schorr diff --git a/lib/buffer.c b/lib/buffer.c index 9d931a9b..3701e121 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -24,6 +24,7 @@ #include "memory.h" #include "buffer.h" +#include "log.h" #include /* Make buffer data. */ @@ -580,9 +581,9 @@ in one shot. */ struct buffer_data *d; struct buffer_data *next; - ssize_t written; + size_t written; struct iovec iov[MAX_CHUNKS]; - int iovcnt = 0; + size_t iovcnt = 0; size_t nbyte = 0; for (d = b->head; d && (iovcnt < MAX_CHUNKS) && (nbyte < MAX_FLUSH); @@ -592,7 +593,8 @@ in one shot. */ nbyte += (iov[iovcnt].iov_len = d->cp-d->sp); } - if ((written = writev(fd,iov,iovcnt)) < 0) + /* only place where written should be sign compared */ + if ((ssize_t)(written = writev(fd,iov,iovcnt)) < 0) { if ((errno != EAGAIN) && (errno != EINTR)) zlog_warn("buffer_flush_available write error on fd %d: %s", diff --git a/lib/buffer.h b/lib/buffer.h index 2acd571f..65b8a8ca 100644 --- a/lib/buffer.h +++ b/lib/buffer.h @@ -29,7 +29,8 @@ struct buffer /* Data list. */ struct buffer_data *head; struct buffer_data *tail; - + + /* XXX: These unsigned longs should be size_t's */ /* Current allocated data. */ unsigned long alloc; -- cgit v1.2.1