[SCM] Samba Shared Repository - branch master updated
Andreas Schneider
asn at samba.org
Mon Jul 1 08:01:02 UTC 2019
The branch, master has been updated
via 043334f2eb6 util: Fix signed/unsigned comparisons by casting
via 115353a0014 util: Fix signed/unsigned comparisons by declaring as size_t
via abea597b7fc util: Fix signed/unsigned comparisons by declaring as size_t
from d5383297f03 tests-util: Adding test to verify "allow no conversion" flag
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 043334f2eb67ec82c3c6b757fef5eb986d58ad25
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Jun 21 15:11:49 2019 +1000
util: Fix signed/unsigned comparisons by casting
One case needs a variable declared, so it can be compared to -1 and
then cast to size_t for comparison.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Andreas Schneider <asn at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Mon Jul 1 08:00:29 UTC 2019 on sn-devel-184
commit 115353a00149997f01fb9964cdbc9be4c7a0cd0a
Author: Martin Schwenke <martin at meltin.net>
Date: Tue Jun 25 10:50:05 2019 +1000
util: Fix signed/unsigned comparisons by declaring as size_t
I may be missing something subtle but I can't see a reason for
declaring these as ssize_t.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit abea597b7fc5c221205143d537cf5fb009a234bf
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Jun 21 15:10:19 2019 +1000
util: Fix signed/unsigned comparisons by declaring as size_t
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Andreas Schneider <asn at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/util/fault.c | 4 ++--
lib/util/msghdr.c | 4 ++--
lib/util/pidfile.c | 2 +-
lib/util/substitute.c | 16 ++++++++--------
lib/util/sys_rw_data.c | 4 ++--
lib/util/talloc_report.c | 2 +-
lib/util/util_file.c | 8 +++++---
lib/util/util_strlist.c | 6 +++---
8 files changed, 24 insertions(+), 22 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/fault.c b/lib/util/fault.c
index bde20e33460..5be9162679e 100644
--- a/lib/util/fault.c
+++ b/lib/util/fault.c
@@ -261,10 +261,10 @@ libunwind_failed:
(unsigned long)backtrace_size));
if (backtrace_strings) {
- int i;
+ size_t i;
for (i = 0; i < backtrace_size; i++)
- DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i]));
+ DEBUGADD(0, (" #%zu %s\n", i, backtrace_strings[i]));
/* Leak the backtrace_strings, rather than risk what free() might do */
}
diff --git a/lib/util/msghdr.c b/lib/util/msghdr.c
index fec54462844..3a1d6f5a017 100644
--- a/lib/util/msghdr.c
+++ b/lib/util/msghdr.c
@@ -223,7 +223,7 @@ ssize_t msghdr_copy(struct msghdr_buf *msg, size_t msgsize,
return -1;
}
- if (bufsize >= fd_len) {
+ if (bufsize >= (size_t)fd_len) {
bufsize -= fd_len;
} else {
bufsize = 0;
@@ -256,7 +256,7 @@ ssize_t msghdr_copy(struct msghdr_buf *msg, size_t msgsize,
}
needed = offsetof(struct msghdr_buf, buf) + fd_len;
- if (needed < fd_len) {
+ if (needed < (size_t)fd_len) {
return -1;
}
needed += iov_len;
diff --git a/lib/util/pidfile.c b/lib/util/pidfile.c
index 5cd09cee75c..b90ff12a8c7 100644
--- a/lib/util/pidfile.c
+++ b/lib/util/pidfile.c
@@ -82,7 +82,7 @@ int pidfile_path_create(const char *path, int *outfd)
ret = errno;
goto fail_unlink;
}
- if (len >= sizeof(tmp)) {
+ if ((size_t)len >= sizeof(tmp)) {
ret = ENOSPC;
goto fail_unlink;
}
diff --git a/lib/util/substitute.c b/lib/util/substitute.c
index 2c18257da25..2249035f704 100644
--- a/lib/util/substitute.c
+++ b/lib/util/substitute.c
@@ -52,14 +52,14 @@ static void string_sub2(char *s,const char *pattern, const char *insert, size_t
bool allow_trailing_dollar)
{
char *p;
- ssize_t ls, lp, li, i;
+ size_t ls, lp, li, i;
if (!insert || !pattern || !*pattern || !s)
return;
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
+ ls = strlen(s);
+ lp = strlen(pattern);
+ li = strlen(insert);
if (len == 0)
len = ls + 1; /* len is number of *bytes* */
@@ -176,14 +176,14 @@ _PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s,
_PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
{
char *p;
- ssize_t ls,lp,li;
+ size_t ls,lp,li;
if (!insert || !pattern || !s)
return;
- ls = (ssize_t)strlen(s);
- lp = (ssize_t)strlen(pattern);
- li = (ssize_t)strlen(insert);
+ ls = strlen(s);
+ lp = strlen(pattern);
+ li = strlen(insert);
if (!*pattern)
return;
diff --git a/lib/util/sys_rw_data.c b/lib/util/sys_rw_data.c
index de71716291c..a0d69f76eaf 100644
--- a/lib/util/sys_rw_data.c
+++ b/lib/util/sys_rw_data.c
@@ -60,7 +60,7 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
memcpy(iov_copy, orig_iov, sizeof(struct iovec) * iovcnt);
iov = iov_copy;
- while (sent < to_send) {
+ while (sent < (size_t)to_send) {
bool ok;
ok = iov_advance(&iov, &iovcnt, thistime);
@@ -104,7 +104,7 @@ ssize_t read_data(int fd, void *buffer, size_t n)
nread = 0;
- while (nread < n) {
+ while ((size_t)nread < n) {
ssize_t ret;
ret = sys_read(fd, ((char *)buffer) + nread, n - nread);
if (ret <= 0) {
diff --git a/lib/util/talloc_report.c b/lib/util/talloc_report.c
index fb12a2f631c..0aec96603b6 100644
--- a/lib/util/talloc_report.c
+++ b/lib/util/talloc_report.c
@@ -49,7 +49,7 @@ static char *talloc_vasprintf_append_largebuf(char *buf, ssize_t *pstr_len,
}
buflen = talloc_get_size(buf);
- if (buflen > str_len) {
+ if (buflen > (size_t)str_len) {
start = buf + str_len;
space = buflen - str_len;
} else {
diff --git a/lib/util/util_file.c b/lib/util/util_file.c
index 79276153015..48ee03fb5f9 100644
--- a/lib/util/util_file.c
+++ b/lib/util/util_file.c
@@ -74,7 +74,7 @@ _PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
offset += ret;
- } while (ret == hint);
+ } while ((size_t)ret == hint);
data[offset] = '\0';
@@ -140,7 +140,7 @@ char *fgets_slash(TALLOC_CTX *mem_ctx, char *s2, size_t maxlen, FILE *f)
s[len] = 0;
}
if ((s2 == NULL) && (len > maxlen-3)) {
- int m;
+ size_t m;
char *t;
m = maxlen * 2;
@@ -327,12 +327,14 @@ _PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX
_PUBLIC_ bool file_save_mode(const char *fname, const void *packet,
size_t length, mode_t mode)
{
+ ssize_t num_written;
int fd;
fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, mode);
if (fd == -1) {
return false;
}
- if (write(fd, packet, length) != (size_t)length) {
+ num_written = write(fd, packet, length);
+ if (num_written == -1 || (size_t)num_written != length) {
close(fd);
return false;
}
diff --git a/lib/util/util_strlist.c b/lib/util/util_strlist.c
index 203a643b09b..9462e9c6ad4 100644
--- a/lib/util/util_strlist.c
+++ b/lib/util/util_strlist.c
@@ -361,7 +361,7 @@ _PUBLIC_ const char **str_list_append(const char **list1,
size_t len1 = str_list_length(list1);
size_t len2 = str_list_length(list2);
const char **ret;
- int i;
+ size_t i;
ret = talloc_realloc(NULL, list1, const char *, len1+len2+1);
if (ret == NULL) return NULL;
@@ -390,7 +390,7 @@ _PUBLIC_ const char **str_list_unique(const char **list)
{
size_t len = str_list_length(list);
const char **list2;
- int i, j;
+ size_t i, j;
if (len < 2) {
return list;
}
@@ -435,7 +435,7 @@ _PUBLIC_ const char **str_list_append_const(const char **list1,
size_t len1 = str_list_length(list1);
size_t len2 = str_list_length(list2);
const char **ret;
- int i;
+ size_t i;
ret = talloc_realloc(NULL, list1, const char *, len1+len2+1);
if (ret == NULL) return NULL;
--
Samba Shared Repository
More information about the samba-cvs
mailing list