mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
ctdb-protocol: Avoid signed/unsigned comparison by casting
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
3f38807620
commit
2a93385997
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user