1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 07:38:49 -05:00

Dan Fandrich's cleanup patch to make pedantic compiler options cause less

warnings. Minor edits by me.
This commit is contained in:
Daniel Stenberg 2004-01-29 13:56:45 +00:00
parent 0d6236f7e1
commit 4d17d6876e
29 changed files with 103 additions and 85 deletions

View File

@ -76,6 +76,7 @@
#include "urldata.h"
#include "sendf.h"
#include "if2ip.h"
#include "connect.h"
/* The last #include file should be: */
#ifdef CURLDEBUG

View File

@ -32,6 +32,7 @@
#include <curl/curl.h>
#include <curl/types.h>
#include "sendf.h"
#include "content_encoding.h"
#define DSIZ 0x10000 /* buffer size for decompressed data */

View File

@ -211,7 +211,7 @@ Curl_cookie_add(struct SessionHandle *data,
/* note that this name may or may not have a preceeding dot, but
we don't care about that, we treat the names the same anyway */
char *ptr=whatptr;
const char *domptr=whatptr;
int dotcount=1;
unsigned int i;
@ -224,15 +224,15 @@ Curl_cookie_add(struct SessionHandle *data,
if('.' == whatptr[0])
/* don't count the initial dot, assume it */
ptr++;
domptr++;
do {
ptr = strchr(ptr, '.');
if(ptr) {
ptr++;
domptr = strchr(domptr, '.');
if(domptr) {
domptr++;
dotcount++;
}
} while(ptr);
} while(domptr);
for(i=0;
i<sizeof(seventhree)/sizeof(seventhree[0]); i++) {
@ -259,10 +259,10 @@ Curl_cookie_add(struct SessionHandle *data,
or the given domain is not valid and thus cannot be set. */
if(!domain || tailmatch(whatptr, domain)) {
char *ptr=whatptr;
if(ptr[0] == '.')
ptr++;
co->domain=strdup(ptr); /* dont prefix with dots internally */
const char *tailptr=whatptr;
if(tailptr[0] == '.')
tailptr++;
co->domain=strdup(tailptr); /* don't prefix w/dots internally */
co->tailmatch=TRUE; /* we always do that if the domain name was
given */
}

View File

@ -74,6 +74,7 @@
#include "progress.h"
#include "strequal.h"
#include "dict.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>

View File

@ -44,7 +44,7 @@ char *curl_escape(const char *string, int length)
char *testing_ptr = NULL;
unsigned char in;
int newlen = alloc;
int index=0;
int strindex=0;
length = alloc-1;
while(length--) {
@ -65,17 +65,17 @@ char *curl_escape(const char *string, int length)
ns = testing_ptr;
}
}
sprintf(&ns[index], "%%%02X", in);
sprintf(&ns[strindex], "%%%02X", in);
index+=3;
strindex+=3;
}
else {
/* just copy this */
ns[index++]=in;
ns[strindex++]=in;
}
string++;
}
ns[index]=0; /* terminate it */
ns[strindex]=0; /* terminate it */
return ns;
}
@ -88,7 +88,7 @@ char *curl_unescape(const char *string, int length)
int alloc = (length?length:(int)strlen(string))+1;
char *ns = malloc(alloc);
unsigned char in;
int index=0;
int strindex=0;
unsigned int hex;
if( !ns ) {
@ -112,10 +112,10 @@ char *curl_unescape(const char *string, int length)
alloc-=2;
}
ns[index++] = in;
ns[strindex++] = in;
string++;
}
ns[index]=0; /* terminate it */
ns[strindex]=0; /* terminate it */
return ns;
}

View File

@ -81,6 +81,7 @@
#include "progress.h"
#include "sendf.h"
#include "escape.h"
#include "file.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>

View File

@ -118,6 +118,9 @@ Content-Disposition: form-data; name="FILECONTENT"
#include <time.h>
#ifndef CURL_OLDSTYLE
#define CURL_OLDSTYLE 1 /* enable deprecated prototype for curl_formparse */
#endif
#include <curl/curl.h>
#include "formdata.h"

View File

@ -2388,7 +2388,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
bytes_written=0;
write_len = strlen(s);
do {
while(1) {
res = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len,
&bytes_written);
@ -2404,7 +2404,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
}
else
break;
} while(1);
}
return res;
}

View File

@ -152,9 +152,6 @@
#define yytable Curl_gd_yytable
#define yycheck Curl_gd_yycheck
static int yylex ();
static int yyerror ();
#define EPOCH 1970
#define HOUR(x) ((x) * 60)
@ -224,6 +221,11 @@ typedef struct _CURL_CONTEXT {
enum _MERIDIAN Meridian;
}
%{
static int yylex (YYSTYPE *yylval, void *cookie);
static int yyerror (const char *s);
%}
%token tAGO tDAY tDAY_UNIT tDAYZONE tDST tHOUR_UNIT tID
%token tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
%token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
@ -495,9 +497,9 @@ o_merid : /* NULL */
#include "getdate.h"
#ifndef WIN32 /* the windows dudes don't need these, does anyone really? */
extern struct tm *gmtime ();
extern struct tm *localtime ();
extern time_t mktime ();
extern struct tm *gmtime (const time_t *);
extern struct tm *localtime (const time_t *);
extern time_t mktime (struct tm *);
#endif
/* Month and day table. */
@ -689,16 +691,13 @@ static TABLE const MilitaryTable[] = {
/* ARGSUSED */
static int
yyerror (s)
char *s ATTRIBUTE_UNUSED;
yyerror (const char *s ATTRIBUTE_UNUSED)
{
return 0;
}
static int
ToHour (Hours, Meridian)
int Hours;
MERIDIAN Meridian;
ToHour (int Hours, MERIDIAN Meridian)
{
switch (Meridian)
{
@ -725,8 +724,7 @@ ToHour (Hours, Meridian)
}
static int
ToYear (Year)
int Year;
ToYear (int Year)
{
if (Year < 0)
Year = -Year;
@ -742,9 +740,7 @@ ToYear (Year)
}
static int
LookupWord (yylval, buff)
YYSTYPE *yylval;
char *buff;
LookupWord (YYSTYPE *yylval, char *buff)
{
register char *p;
register char *q;
@ -864,9 +860,7 @@ LookupWord (yylval, buff)
}
static int
yylex (yylval, cookie)
YYSTYPE *yylval;
void *cookie;
yylex (YYSTYPE *yylval, void *cookie)
{
register unsigned char c;
register char *p;
@ -1085,9 +1079,7 @@ curl_getdate (const char *p, const time_t *now)
/* ARGSUSED */
int
main (ac, av)
int ac;
char *av[];
main (int ac, char *av[])
{
char buff[MAX_BUFF_LEN + 1];
time_t d;

View File

@ -35,6 +35,8 @@
#include <unixlib.h>
#endif
#include <curl/curl.h>
#ifdef CURLDEBUG
#include "memdebug.h"
#endif

View File

@ -26,6 +26,7 @@
#include <curl/curl.h>
#include "urldata.h"
#include "getinfo.h"
#include <stdio.h>
#include <string.h>

View File

@ -193,11 +193,11 @@ void Curl_http_auth_act(struct connectdata *conn)
* authentication method.
*/
CURLcode http_auth_headers(struct connectdata *conn,
static CURLcode http_auth_headers(struct connectdata *conn,
char *request,
char *path,
bool *ready) /* set TRUE when the auth phase is
done and ready to do the *actual*
bool *ready) /* set TRUE when the auth phase
is done and ready to do the *actual*
request */
{
CURLcode result = CURLE_OK;

View File

@ -34,6 +34,7 @@
#include "sendf.h" /* for the client write stuff */
#include "content_encoding.h" /* 08/29/02 jhrg */
#include "http.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@ -99,8 +100,8 @@ void Curl_httpchunk_init(struct connectdata *conn)
*/
CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
char *datap,
size_t length,
size_t *wrote)
ssize_t length,
ssize_t *wrote)
{
CURLcode result=CURLE_OK;
struct Curl_chunker *ch = &conn->proto.http->chunk;

View File

@ -81,8 +81,8 @@ struct Curl_chunker {
char hexbuffer[ MAXNUM_SIZE + 1];
int hexindex;
ChunkyState state;
size_t datasize;
size_t dataleft; /* untouched data amount at the end of the last buffer */
ssize_t datasize;
ssize_t dataleft; /* untouched data amount at the end of the last buffer */
};
#endif

View File

@ -72,6 +72,8 @@
#include <inet.h>
#endif
#include "if2ip.h"
/* The last #include file should be: */
#ifdef CURLDEBUG
#include "memdebug.h"

View File

@ -38,6 +38,8 @@
#include <string.h>
#include <errno.h>
#include "inet_pton.h"
#define IN6ADDRSZ 16
#define INADDRSZ 4
#define INT16SZ 2
@ -68,10 +70,7 @@ static int inet_pton6(const char *src, unsigned char *dst);
* Paul Vixie, 1996.
*/
int
Curl_inet_pton(af, src, dst)
int af;
const char *src;
void *dst;
Curl_inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
@ -101,9 +100,7 @@ Curl_inet_pton(af, src, dst)
* Paul Vixie, 1996.
*/
static int
inet_pton4(src, dst)
const char *src;
unsigned char *dst;
inet_pton4(const char *src, unsigned char *dst)
{
static const char digits[] = "0123456789";
int saw_digit, octets, ch;
@ -156,9 +153,7 @@ inet_pton4(src, dst)
* Paul Vixie, 1996.
*/
static int
inet_pton6(src, dst)
const char *src;
unsigned char *dst;
inet_pton6(const char *src, unsigned char *dst)
{
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";

View File

@ -49,6 +49,7 @@
#include "sendf.h"
#include "escape.h"
#include "transfer.h"
#include "ldap.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>

View File

@ -159,10 +159,10 @@ struct md5_ctx *context; /* context */
unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, index, partLen;
unsigned int i, bufindex, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
@ -170,23 +170,23 @@ unsigned int inputLen; /* length of input block */
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - index;
partLen = 64 - bufindex;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
MD5_memcpy((void *)&context->buffer[index], (void *)input, partLen);
MD5_memcpy((void *)&context->buffer[bufindex], (void *)input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
index = 0;
bufindex = 0;
}
else
i = 0;
/* Buffer remaining input */
MD5_memcpy((void *)&context->buffer[index], (void *)&input[i],
MD5_memcpy((void *)&context->buffer[bufindex], (void *)&input[i],
inputLen-i);
}
@ -198,14 +198,14 @@ unsigned char digest[16]; /* message digest */
struct md5_ctx *context; /* context */
{
unsigned char bits[8];
unsigned int index, padLen;
unsigned int count, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64. */
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
count = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (count < 56) ? (56 - count) : (120 - count);
MD5_Update (context, PADDING, padLen);
/* Append length (before padding) */
@ -345,6 +345,7 @@ static void Decode (UINT4 *output,
#include <string.h>
#endif
#include "md5.h"
void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */
unsigned char *input)

View File

@ -41,7 +41,8 @@
#include <unistd.h>
#endif
/* DONT include memdebug.h here! */
#define MEMDEBUG_NODEFINES /* don't redefine the standard functions */
#include "memdebug.h"
struct memdebug {
int size;
@ -194,7 +195,8 @@ void curl_dofree(void *ptr, int line, const char *source)
fprintf(logfile, "MEM %s:%d free(%p)\n", source, line, ptr);
}
int curl_socket(int domain, int type, int protocol, int line, char *source)
int curl_socket(int domain, int type, int protocol, int line,
const char *source)
{
int sockfd=(socket)(domain, type, protocol);
if(logfile && (sockfd!=-1))
@ -214,7 +216,7 @@ int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
}
/* this is our own defined way to close sockets on *ALL* platforms */
int curl_sclose(int sockfd, int line, char *source)
int curl_sclose(int sockfd, int line, const char *source)
{
int res=sclose(sockfd);
if(logfile)

View File

@ -49,7 +49,7 @@ void curl_memdebug(const char *logname);
void curl_memlimit(long limit);
/* file descriptor manipulators */
int curl_socket(int domain, int type, int protocol, int, const char *);
int curl_socket(int domain, int type, int protocol, int line , const char *);
int curl_sclose(int sockfd, int, const char *source);
int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
int line, const char *source);
@ -59,6 +59,8 @@ FILE *curl_fopen(const char *file, const char *mode, int line,
const char *source);
int curl_fclose(FILE *file, int line, const char *source);
#ifndef MEMDEBUG_NODEFINES
/* Set this symbol on the command-line, recompile all lib-sources */
#undef strdup
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
@ -84,4 +86,6 @@ int curl_fclose(FILE *file, int line, const char *source);
#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
#define fclose(file) curl_fclose(file,__LINE__,__FILE__)
#endif /* MEMDEBUG_NODEFINES */
#endif

View File

@ -40,6 +40,8 @@
#include <curl/curl.h> /* for the curl_off_t type */
#include <curl/mprintf.h>
#ifndef SIZEOF_LONG_DOUBLE
#define SIZEOF_LONG_DOUBLE 0
#endif

View File

@ -41,6 +41,7 @@
#endif
#include <curl/curl.h>
#include "netrc.h"
#include "strequal.h"
#include "strtok.h"

View File

@ -333,13 +333,15 @@ int Curl_pgrsUpdate(struct connectdata *conn)
}
/* Figure out the estimated time of arrival for the upload */
if((data->progress.flags & PGRS_UL_SIZE_KNOWN) && data->progress.ulspeed){
if((data->progress.flags & PGRS_UL_SIZE_KNOWN) &&
(data->progress.ulspeed > 0)) {
ulestimate = data->progress.size_ul / data->progress.ulspeed;
ulpercen = (data->progress.uploaded / data->progress.size_ul)*100;
}
/* ... and the download */
if((data->progress.flags & PGRS_DL_SIZE_KNOWN) && data->progress.dlspeed) {
if((data->progress.flags & PGRS_DL_SIZE_KNOWN) &&
(data->progress.dlspeed > 0)) {
dlestimate = data->progress.size_dl / data->progress.dlspeed;
dlpercen = (data->progress.downloaded / data->progress.size_dl)*100;
}
@ -351,7 +353,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
/* If we have a total estimate, we can display that and the expected
time left */
if(total_estimate) {
if(total_estimate > 0) {
time2str(time_left, (int)(total_estimate - data->progress.timespent));
time2str(time_total, (int)total_estimate);
}
@ -374,7 +376,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
total_transfer = data->progress.downloaded + data->progress.uploaded;
/* Get the percentage of data transfered so far */
if(total_expected_transfer)
if(total_expected_transfer > 0)
total_percen=(double)(total_transfer/total_expected_transfer)*100;
fprintf(data->set.err,

View File

@ -189,7 +189,7 @@ CURLcode Curl_sendf(int sockfd, struct connectdata *conn,
write_len = strlen(s);
sptr = s;
do {
while (1) {
/* Write the buffer to the socket */
res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
@ -207,8 +207,7 @@ CURLcode Curl_sendf(int sockfd, struct connectdata *conn,
}
else
break;
} while(1);
}
free(s); /* free the output string */

View File

@ -178,7 +178,7 @@ curl_share_cleanup(CURLSH *sh)
CURLSHcode
Curl_share_lock(struct SessionHandle *data, curl_lock_data type,
curl_lock_access access)
curl_lock_access accesstype)
{
struct Curl_share *share = data->share;
@ -186,7 +186,7 @@ Curl_share_lock(struct SessionHandle *data, curl_lock_data type,
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {
share->lockfunc(data, type, access, share->clientdata);
share->lockfunc(data, type, accesstype, share->clientdata);
}
/* else if we don't share this, pretend successful lock */

View File

@ -43,6 +43,7 @@
#include "formdata.h" /* for the boundary function */
#include "url.h" /* for the ssl config check function */
#include "inet_pton.h"
#include "ssluse.h"
#ifdef USE_SSLEAY
#include <openssl/rand.h>
@ -1057,7 +1058,7 @@ Curl_SSLConnect(struct connectdata *conn,
/* pass the raw socket into the SSL layers */
SSL_set_fd(connssl->handle, sockfd);
do {
while(1) {
fd_set writefd;
fd_set readfd;
struct timeval interval;
@ -1167,7 +1168,7 @@ Curl_SSLConnect(struct connectdata *conn,
}
else
break; /* get out of loop */
} while(1);
} /* loop */
/* Informational message */
infof (data, "SSL connection using %s\n",

View File

@ -26,6 +26,8 @@
#include <string.h>
#include <ctype.h>
#include "strequal.h"
#ifdef HAVE_STRCASECMP
/* this is for "-ansi -Wall -pedantic" to stop complaining! */
extern int (strcasecmp)(const char *s1, const char *s2);

View File

@ -27,6 +27,8 @@
#include <stddef.h>
#include <string.h>
#include "strtok.h"
char *
Curl_strtok_r(char *ptr, const char *sep, char **end)
{

View File

@ -72,6 +72,7 @@
#include <curl/curl.h>
#include "transfer.h"
#include "sendf.h"
#include "telnet.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>