summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-03-22 02:40:19 +0100
committerYang Tse <yangsita@gmail.com>2012-03-22 04:54:04 +0100
commit3c80309c276b8ceac13ab1a4824d216805d45afe (patch)
tree663336bf7af75d2ccc6a36a4bcace3d22ae45e54
parentc83de6d07625b813e3bbc31f9a0827c3a0007355 (diff)
downloadgnurl-3c80309c276b8ceac13ab1a4824d216805d45afe.tar.gz
gnurl-3c80309c276b8ceac13ab1a4824d216805d45afe.tar.bz2
gnurl-3c80309c276b8ceac13ab1a4824d216805d45afe.zip
fix several compiler warnings
-rw-r--r--lib/base64.c8
-rw-r--r--lib/http_digest.c6
-rw-r--r--lib/ssh.c6
-rw-r--r--lib/ssluse.c17
-rw-r--r--lib/warnless.c8
-rw-r--r--tests/libtest/Makefile.inc4
-rw-r--r--tests/libtest/lib552.c6
-rw-r--r--tests/libtest/lib571.c7
-rw-r--r--tests/libtest/testtrace.c2
9 files changed, 43 insertions, 21 deletions
diff --git a/lib/base64.c b/lib/base64.c
index 23ebb4aa9..ec46c09ab 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -58,11 +58,11 @@ static void decodeQuantum(unsigned char *dest, const char *src)
x = (x << 6);
}
- dest[2] = curlx_ultouc(x);
+ dest[2] = curlx_ultouc(x & 0xFFUL);
x >>= 8;
- dest[1] = curlx_ultouc(x);
+ dest[1] = curlx_ultouc(x & 0xFFUL);
x >>= 8;
- dest[0] = curlx_ultouc(x);
+ dest[0] = curlx_ultouc(x & 0xFFUL);
}
/*
diff --git a/lib/http_digest.c b/lib/http_digest.c
index b41e62306..45df5fc4d 100644
--- a/lib/http_digest.c
+++ b/lib/http_digest.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,6 +34,7 @@
#include "url.h" /* for Curl_safefree() */
#include "curl_memory.h"
#include "non-ascii.h" /* included for Curl_convert_... prototypes */
+#include "warnless.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -416,7 +417,8 @@ CURLcode Curl_output_digest(struct connectdata *conn,
*/
if(authp->iestyle && ((tmp = strchr((char *)uripath, '?')) != NULL)) {
md5this = (unsigned char *)aprintf("%s:%.*s", request,
- (int)(tmp - (char *)uripath), uripath);
+ curlx_sztosi(tmp - (char *)uripath),
+ uripath);
}
else
md5this = (unsigned char *)aprintf("%s:%s", request, uripath);
diff --git a/lib/ssh.c b/lib/ssh.c
index d6252f2b5..9ca927d1a 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -108,6 +108,10 @@
have their definition hidden well */
#endif
+#define sftp_libssh2_realpath(s,p,t,m) \
+ libssh2_sftp_symlink_ex((s), (p), curlx_uztoui(strlen(p)), \
+ (t), (m), LIBSSH2_SFTP_REALPATH)
+
/* Local functions: */
static const char *sftp_libssh2_strerror(unsigned long err);
static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
@@ -982,7 +986,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/*
* Get the "home" directory
*/
- rc = libssh2_sftp_realpath(sshc->sftp_session, ".",
+ rc = sftp_libssh2_realpath(sshc->sftp_session, ".",
tempHome, PATH_MAX-1);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
diff --git a/lib/ssluse.c b/lib/ssluse.c
index d31c2e07b..74563c7ee 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -145,7 +145,7 @@
static char global_passwd[64];
#endif
-static int passwd_callback(char *buf, int num, int verify
+static int passwd_callback(char *buf, int num, int encrypting
#ifdef HAVE_USERDATA_IN_PWD_CALLBACK
/* This was introduced in 0.9.4, we can set this
using SSL_CTX_set_default_passwd_cb_userdata()
@@ -154,12 +154,13 @@ static int passwd_callback(char *buf, int num, int verify
#endif
)
{
- if(verify)
- fprintf(stderr, "%s\n", buf);
- else {
- if(num > (int)strlen((char *)global_passwd)) {
- strcpy(buf, global_passwd);
- return (int)strlen(buf);
+ DEBUGASSERT(0 == encrypting);
+
+ if(!encrypting) {
+ int klen = curlx_uztosi(strlen((char *)global_passwd));
+ if(num > klen) {
+ memcpy(buf, global_passwd, klen+1);
+ return klen;
}
}
return 0;
@@ -339,6 +340,8 @@ int cert_stuff(struct connectdata *conn,
size_t len = strlen(data->set.str[STRING_KEY_PASSWD]);
if(len < sizeof(global_passwd))
memcpy(global_passwd, data->set.str[STRING_KEY_PASSWD], len+1);
+ else
+ global_passwd[0] = '\0';
#else
/*
* We set the password in the callback userdata
diff --git a/lib/warnless.c b/lib/warnless.c
index 6b77eea22..d01490b15 100644
--- a/lib/warnless.c
+++ b/lib/warnless.c
@@ -131,6 +131,7 @@ unsigned short curlx_ultous(unsigned long ulnum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
+ DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_USHORT);
return (unsigned short)(ulnum & (unsigned long) CURL_MASK_USHORT);
#ifdef __INTEL_COMPILER
@@ -149,6 +150,7 @@ unsigned char curlx_ultouc(unsigned long ulnum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
+ DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_UCHAR);
return (unsigned char)(ulnum & (unsigned long) CURL_MASK_UCHAR);
#ifdef __INTEL_COMPILER
@@ -167,6 +169,7 @@ int curlx_uztosi(size_t uznum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
+ DEBUGASSERT(uznum <= (size_t) CURL_MASK_SINT);
return (int)(uznum & (size_t) CURL_MASK_SINT);
#ifdef __INTEL_COMPILER
@@ -224,6 +227,7 @@ int curlx_sltosi(long slnum)
#endif
DEBUGASSERT(slnum >= 0);
+ DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_SINT);
return (int)(slnum & (long) CURL_MASK_SINT);
#ifdef __INTEL_COMPILER
@@ -243,6 +247,7 @@ unsigned int curlx_sltoui(long slnum)
#endif
DEBUGASSERT(slnum >= 0);
+ DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_UINT);
return (unsigned int)(slnum & (long) CURL_MASK_UINT);
#ifdef __INTEL_COMPILER
@@ -262,6 +267,7 @@ unsigned short curlx_sltous(long slnum)
#endif
DEBUGASSERT(slnum >= 0);
+ DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_USHORT);
return (unsigned short)(slnum & (long) CURL_MASK_USHORT);
#ifdef __INTEL_COMPILER
@@ -280,6 +286,7 @@ ssize_t curlx_uztosz(size_t uznum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
+ DEBUGASSERT(uznum <= (size_t) CURL_MASK_SSIZE_T);
return (ssize_t)(uznum & (size_t) CURL_MASK_SSIZE_T);
#ifdef __INTEL_COMPILER
@@ -318,6 +325,7 @@ int curlx_sztosi(ssize_t sznum)
#endif
DEBUGASSERT(sznum >= 0);
+ DEBUGASSERT((size_t) sznum <= (size_t) CURL_MASK_SINT);
return (int)(sznum & (ssize_t) CURL_MASK_SINT);
#ifdef __INTEL_COMPILER
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index b13c97e47..e24d74226 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -119,7 +119,7 @@ lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
-lib552_SOURCES = lib552.c $(SUPPORTFILES)
+lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS)
lib553_SOURCES = lib553.c $(SUPPORTFILES)
@@ -154,7 +154,7 @@ lib569_SOURCES = lib569.c $(SUPPORTFILES)
lib570_SOURCES = lib570.c $(SUPPORTFILES)
-lib571_SOURCES = lib571.c $(SUPPORTFILES)
+lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS)
lib572_SOURCES = lib572.c $(SUPPORTFILES)
diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c
index fb8b14bc2..2cc942ad4 100644
--- a/tests/libtest/lib552.c
+++ b/tests/libtest/lib552.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,6 +25,7 @@
#include "test.h"
+#include "warnless.h"
#include "memdebug.h"
struct data {
@@ -136,7 +137,8 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
- printf("%.*s", (int)(size * nmemb), (char *)ptr);
+ int amount = curlx_uztosi(size * nmemb);
+ printf("%.*s", amount, (char *)ptr);
(void)stream;
return size * nmemb;
}
diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c
index c5f7240d0..ba0aa1ce4 100644
--- a/tests/libtest/lib571.c
+++ b/tests/libtest/lib571.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -39,6 +39,7 @@
#include <curl/mprintf.h>
+#include "warnless.h"
#include "memdebug.h"
#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
@@ -54,12 +55,14 @@ static int rtp_packet_count = 0;
static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) {
char *data = (char *)ptr;
int channel = RTP_PKT_CHANNEL(data);
- int message_size = (int)(size * nmemb) - 4;
+ int message_size;
int coded_size = RTP_PKT_LENGTH(data);
size_t failure = (size * nmemb) ? 0 : 1;
int i;
(void)stream;
+ message_size = curlx_uztosi(size * nmemb) - 4;
+
printf("RTP: message size %d, channel %d\n", message_size, channel);
if(message_size != coded_size) {
printf("RTP embedded size (%d) does not match the write size (%d).\n",
diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c
index b13c54e30..64602e065 100644
--- a/tests/libtest/testtrace.c
+++ b/tests/libtest/testtrace.c
@@ -113,7 +113,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type,
switch (type) {
case CURLINFO_TEXT:
- fprintf(stderr, "%s== Info: %s", timestr, data);
+ fprintf(stderr, "%s== Info: %s", timestr, (char *)data);
default: /* in case a new one is introduced to shock us */
return 0;