mirror of
https://github.com/curl/curl.git
synced 2024-11-21 01:16:58 +08:00
fix compiler warning: conversion from "long" to "size_t" may lose sign
This commit is contained in:
parent
2596fe0cb7
commit
4b43d18c4a
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2010, 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
|
||||
@ -95,16 +95,19 @@ size_t Curl_strlcat(char *dst, const char *src, size_t siz)
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
size_t dlen;
|
||||
union {
|
||||
ssize_t sig;
|
||||
size_t uns;
|
||||
} dlen;
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while(n-- != 0 && *d != '\0')
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
dlen.sig = d - dst;
|
||||
n = siz - dlen.uns;
|
||||
|
||||
if(n == 0)
|
||||
return(dlen + strlen(s));
|
||||
return(dlen.uns + strlen(s));
|
||||
while(*s != '\0') {
|
||||
if(n != 1) {
|
||||
*d++ = *s;
|
||||
@ -114,6 +117,6 @@ size_t Curl_strlcat(char *dst, const char *src, size_t siz)
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
return(dlen.uns + (s - src)); /* count does not include NUL */
|
||||
}
|
||||
#endif
|
||||
|
@ -238,7 +238,10 @@ int getpart(char **outbuf, size_t *outlen,
|
||||
char *buffer = NULL;
|
||||
char *ptr;
|
||||
char *end;
|
||||
size_t length;
|
||||
union {
|
||||
ssize_t sig;
|
||||
size_t uns;
|
||||
} len;
|
||||
size_t bufsize = 0;
|
||||
size_t outalloc = 256;
|
||||
int in_wanted_part = 0;
|
||||
@ -286,12 +289,12 @@ int getpart(char **outbuf, size_t *outlen,
|
||||
ptr++;
|
||||
end = ptr;
|
||||
EAT_WORD(end);
|
||||
if((length = end - ptr) > MAX_TAG_LEN) {
|
||||
if((len.sig = end - ptr) > MAX_TAG_LEN) {
|
||||
error = GPE_NO_BUFFER_SPACE;
|
||||
break;
|
||||
}
|
||||
memcpy(ptag, ptr, length);
|
||||
ptag[length] = '\0';
|
||||
memcpy(ptag, ptr, len.uns);
|
||||
ptag[len.uns] = '\0';
|
||||
|
||||
if((STATE_INSUB == state) && !strcmp(csub, ptag)) {
|
||||
/* end of current sub section */
|
||||
@ -333,12 +336,12 @@ int getpart(char **outbuf, size_t *outlen,
|
||||
/* get potential tag */
|
||||
end = ptr;
|
||||
EAT_WORD(end);
|
||||
if((length = end - ptr) > MAX_TAG_LEN) {
|
||||
if((len.sig = end - ptr) > MAX_TAG_LEN) {
|
||||
error = GPE_NO_BUFFER_SPACE;
|
||||
break;
|
||||
}
|
||||
memcpy(ptag, ptr, length);
|
||||
ptag[length] = '\0';
|
||||
memcpy(ptag, ptr, len.uns);
|
||||
ptag[len.uns] = '\0';
|
||||
|
||||
/* ignore comments, doctypes and xml declarations */
|
||||
if(('!' == ptag[0]) || ('?' == ptag[0])) {
|
||||
@ -352,12 +355,12 @@ int getpart(char **outbuf, size_t *outlen,
|
||||
end = ptr;
|
||||
while(*end && ('>' != *end))
|
||||
end++;
|
||||
if((length = end - ptr) > MAX_TAG_LEN) {
|
||||
if((len.sig = end - ptr) > MAX_TAG_LEN) {
|
||||
error = GPE_NO_BUFFER_SPACE;
|
||||
break;
|
||||
}
|
||||
memcpy(patt, ptr, length);
|
||||
patt[length] = '\0';
|
||||
memcpy(patt, ptr, len.uns);
|
||||
patt[len.uns] = '\0';
|
||||
|
||||
if(STATE_OUTSIDE == state) {
|
||||
/* outermost element (<testcase>) */
|
||||
|
Loading…
Reference in New Issue
Block a user