diff options
author | Martin Schwenke <martin@meltin.net> | 2019-06-23 21:00:38 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-07-05 05:03:24 +0000 |
commit | 2a93385997912c89fa6b547f8c32fa67283403cb (patch) | |
tree | b45dcf8a20973cc2a40c264d321c8b8514ca4d8e /ctdb | |
parent | 3f388076203c5d3c77ebb66e10d4c2bd6b7cedc7 (diff) | |
download | samba-2a93385997912c89fa6b547f8c32fa67283403cb.tar.gz |
ctdb-protocol: Avoid signed/unsigned comparison by casting
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/protocol/protocol_types.c | 16 | ||||
-rw-r--r-- | ctdb/protocol/protocol_util.c | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/ctdb/protocol/protocol_types.c b/ctdb/protocol/protocol_types.c index 5fb8f201e5d..d9388b74b1e 100644 --- a/ctdb/protocol/protocol_types.c +++ b/ctdb/protocol/protocol_types.c @@ -1680,19 +1680,19 @@ int ctdb_rec_buffer_write(struct ctdb_rec_buffer *recbuf, int fd) ssize_t n; n = write(fd, &recbuf->db_id, sizeof(uint32_t)); - if (n == -1 || n != sizeof(uint32_t)) { + if (n == -1 || (size_t)n != sizeof(uint32_t)) { return (errno != 0 ? errno : EIO); } n = write(fd, &recbuf->count, sizeof(uint32_t)); - if (n == -1 || n != sizeof(uint32_t)) { + if (n == -1 || (size_t)n != sizeof(uint32_t)) { return (errno != 0 ? errno : EIO); } n = write(fd, &recbuf->buflen, sizeof(size_t)); - if (n == -1 || n != sizeof(size_t)) { + if (n == -1 || (size_t)n != sizeof(size_t)) { return (errno != 0 ? errno : EIO); } n = write(fd, recbuf->buf, recbuf->buflen); - if (n == -1 || n != recbuf->buflen) { + if (n == -1 || (size_t)n != recbuf->buflen) { return (errno != 0 ? errno : EIO); } @@ -1711,15 +1711,15 @@ int ctdb_rec_buffer_read(int fd, TALLOC_CTX *mem_ctx, } n = read(fd, &recbuf->db_id, sizeof(uint32_t)); - if (n == -1 || n != sizeof(uint32_t)) { + if (n == -1 || (size_t)n != sizeof(uint32_t)) { return (errno != 0 ? errno : EIO); } n = read(fd, &recbuf->count, sizeof(uint32_t)); - if (n == -1 || n != sizeof(uint32_t)) { + if (n == -1 || (size_t)n != sizeof(uint32_t)) { return (errno != 0 ? errno : EIO); } n = read(fd, &recbuf->buflen, sizeof(size_t)); - if (n == -1 || n != sizeof(size_t)) { + if (n == -1 || (size_t)n != sizeof(size_t)) { return (errno != 0 ? errno : EIO); } @@ -1729,7 +1729,7 @@ int ctdb_rec_buffer_read(int fd, TALLOC_CTX *mem_ctx, } n = read(fd, recbuf->buf, recbuf->buflen); - if (n == -1 || n != recbuf->buflen) { + if (n == -1 || (size_t)n != recbuf->buflen) { return (errno != 0 ? errno : EIO); } diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index 026f342bd7d..c67aa2e056f 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -147,7 +147,7 @@ int ctdb_sock_addr_to_buf(char *buf, socklen_t buflen, ret = snprintf(buf+len, buflen-len, ":%u", ctdb_sock_addr_port(addr)); - if (ret >= buflen-len) { + if (ret < 0 || (size_t)ret >= buflen-len) { return ENOSPC; } } @@ -485,7 +485,7 @@ int ctdb_connection_to_buf(char *buf, size_t buflen, } else { ret = snprintf(buf, buflen, "%s %s", client, server); } - if (ret >= buflen) { + if (ret < 0 || (size_t)ret >= buflen) { return ENOSPC; } |