summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-06-24 16:35:01 +1000
committerAmitay Isaacs <amitay@samba.org>2019-07-05 05:03:24 +0000
commit0ab5d5cece2b7d22cabfffd090cf3c675dca4af5 (patch)
tree0fd7c740dddaeb8d9511904f7466360c8be69e65 /ctdb
parent79a7cc3fb976c88a57099fdae239ddd217bcc968 (diff)
downloadsamba-0ab5d5cece2b7d22cabfffd090cf3c675dca4af5.tar.gz
ctdb-common: Fix signed/unsigned comparisons by casting
One case needs an extra variable declared. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/ctdb_util.c5
-rw-r--r--ctdb/common/event_script.c4
-rw-r--r--ctdb/common/sock_io.c2
3 files changed, 7 insertions, 4 deletions
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index 0f367c2100e..3f8fff925f0 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -111,7 +111,10 @@ bool ctdb_set_helper(const char *type, char *helper, size_t size,
("Unable to set %s - dir is NULL\n", type));
return false;
} else {
- if (snprintf(helper, size, "%s/%s", dir, file) >= size) {
+ int ret;
+
+ ret = snprintf(helper, size, "%s/%s", dir, file);
+ if (ret < 0 || (size_t)ret >= size) {
DEBUG(DEBUG_ERR,
("Unable to set %s - path too long\n", type));
return false;
diff --git a/ctdb/common/event_script.c b/ctdb/common/event_script.c
index 8bdfdd0b5ca..edd607f7a14 100644
--- a/ctdb/common/event_script.c
+++ b/ctdb/common/event_script.c
@@ -159,7 +159,7 @@ int event_script_chmod(const char *script_dir,
script_file = script_name;
} else {
ret = snprintf(buf, sizeof(buf), "%s.script", script_name);
- if (ret >= sizeof(buf)) {
+ if (ret < 0 || (size_t)ret >= sizeof(buf)) {
return ENAMETOOLONG;
}
script_file = buf;
@@ -196,7 +196,7 @@ int event_script_chmod(const char *script_dir,
"%s/%s",
script_dir,
script_file);
- if (ret >= sizeof(filename)) {
+ if (ret < 0 || (size_t)ret >= sizeof(filename)) {
return ENAMETOOLONG;
}
diff --git a/ctdb/common/sock_io.c b/ctdb/common/sock_io.c
index b5c9332526b..81e82c59ca0 100644
--- a/ctdb/common/sock_io.c
+++ b/ctdb/common/sock_io.c
@@ -198,7 +198,7 @@ static void sock_queue_handler(struct tevent_context *ev,
goto fail;
}
- if (num_ready > queue->buflen - queue->end) {
+ if ((size_t)num_ready > queue->buflen - queue->end) {
queue->buf = talloc_realloc_size(queue, queue->buf,
queue->end + num_ready);
if (queue->buf == NULL) {