summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-03-22 14:51:28 +0100
committerJeremy Allison <jra@samba.org>2018-04-03 20:20:11 +0200
commitbe4cb4a70bb033f649a5cb272d104e967a6deab3 (patch)
tree5894d75a20eef73fae2b2db96cd02dfef333476c /source3/client
parent22a28ac8acb44d88d866eb29af6b1161d1013d48 (diff)
downloadsamba-be4cb4a70bb033f649a5cb272d104e967a6deab3.tar.gz
s3:client: Fix size types
This fixes compilation with -Wstrict-overflow=2. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 49d027ad4ac..23ed02d9cc0 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -186,16 +186,20 @@ static bool yesno(const char *p)
number taken from the buffer. This may not equal the number written.
****************************************************************************/
-static int writefile(int f, char *b, int n)
+static ssize_t writefile(int f, char *b, size_t n)
{
- int i;
+ size_t i = 0;
+
+ if (n == 0) {
+ errno = EINVAL;
+ return -1;
+ }
if (!translation) {
return write(f,b,n);
}
- i = 0;
- while (i < n) {
+ do {
if (*b == '\r' && (i<(n-1)) && *(b+1) == '\n') {
b++;i++;
}
@@ -204,9 +208,9 @@ static int writefile(int f, char *b, int n)
}
b++;
i++;
- }
+ } while (i < n);
- return(i);
+ return (ssize_t)i;
}
/****************************************************************************
@@ -1092,7 +1096,10 @@ static int cmd_echo(void)
static NTSTATUS writefile_sink(char *buf, size_t n, void *priv)
{
int *pfd = (int *)priv;
- if (writefile(*pfd, buf, n) == -1) {
+ ssize_t rc;
+
+ rc = writefile(*pfd, buf, n);
+ if (rc == -1) {
return map_nt_error_from_unix(errno);
}
return NT_STATUS_OK;
@@ -5954,7 +5961,7 @@ static char **completion_fn(const char *text, int start, int end)
return NULL;
} else {
char **matches;
- int i, len, samelen = 0, count=1;
+ size_t i, len, samelen = 0, count=1;
matches = SMB_MALLOC_ARRAY(char *, MAX_COMPLETIONS);
if (!matches) {