mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
fix compiler warning: conversion may lose significant bits
This commit is contained in:
parent
5d47bf3776
commit
7e3f0bffe5
@ -379,7 +379,7 @@ static int ftp_endofresp(struct pingpong *pp,
|
|||||||
size_t len = pp->nread_resp;
|
size_t len = pp->nread_resp;
|
||||||
|
|
||||||
if((len > 3) && LASTLINE(line)) {
|
if((len > 3) && LASTLINE(line)) {
|
||||||
*code = strtol(line, NULL, 10);
|
*code = curlx_sltosi(strtol(line, NULL, 10));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
#include "strerror.h"
|
#include "strerror.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
#include "inet_ntop.h"
|
#include "inet_ntop.h"
|
||||||
|
#include "warnless.h"
|
||||||
|
|
||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
@ -597,7 +598,7 @@ int Curl_resolv_timeout(struct connectdata *conn,
|
|||||||
|
|
||||||
/* alarm() makes a signal get sent when the timeout fires off, and that
|
/* alarm() makes a signal get sent when the timeout fires off, and that
|
||||||
will abort system calls */
|
will abort system calls */
|
||||||
prev_alarm = alarm((unsigned int) (timeout/1000L));
|
prev_alarm = alarm(curlx_sltoui(timeout/1000L));
|
||||||
|
|
||||||
/* This allows us to time-out from the name resolver, as the timeout
|
/* This allows us to time-out from the name resolver, as the timeout
|
||||||
will generate a signal and we will siglongjmp() from that here.
|
will generate a signal and we will siglongjmp() from that here.
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "rawstr.h"
|
#include "rawstr.h"
|
||||||
|
#include "warnless.h"
|
||||||
#include "parsedate.h"
|
#include "parsedate.h"
|
||||||
|
|
||||||
const char * const Curl_wkday[] =
|
const char * const Curl_wkday[] =
|
||||||
@ -378,7 +379,7 @@ int Curl_parsedate(const char *date, time_t *output)
|
|||||||
secnum = 0;
|
secnum = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val = (int)strtol(date, &end, 10);
|
val = curlx_sltosi(strtol(date, &end, 10));
|
||||||
|
|
||||||
if((tzoff == -1) &&
|
if((tzoff == -1) &&
|
||||||
((end - date) == 4) &&
|
((end - date) == 4) &&
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
#include "curl_md5.h"
|
#include "curl_md5.h"
|
||||||
#include "curl_hmac.h"
|
#include "curl_hmac.h"
|
||||||
#include "curl_gethostname.h"
|
#include "curl_gethostname.h"
|
||||||
|
#include "warnless.h"
|
||||||
|
|
||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
@ -226,7 +227,7 @@ static int smtp_endofresp(struct pingpong *pp, int *resp)
|
|||||||
return FALSE; /* Nothing for us. */
|
return FALSE; /* Nothing for us. */
|
||||||
|
|
||||||
if((result = line[3] == ' '))
|
if((result = line[3] == ' '))
|
||||||
*resp = strtol(line, NULL, 10);
|
*resp = curlx_sltosi(strtol(line, NULL, 10));
|
||||||
|
|
||||||
line += 4;
|
line += 4;
|
||||||
len -= 4;
|
len -= 4;
|
||||||
|
22
lib/url.c
22
lib/url.c
@ -1006,7 +1006,21 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||||||
* An FTP option that modifies an upload to create missing directories on
|
* An FTP option that modifies an upload to create missing directories on
|
||||||
* the server.
|
* the server.
|
||||||
*/
|
*/
|
||||||
data->set.ftp_create_missing_dirs = (int)va_arg(param, long);
|
switch(va_arg(param, long)) {
|
||||||
|
case 0:
|
||||||
|
data->set.ftp_create_missing_dirs = 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
data->set.ftp_create_missing_dirs = 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
data->set.ftp_create_missing_dirs = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* reserve other values for future use */
|
||||||
|
result = CURLE_FAILED_INIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CURLOPT_SERVER_RESPONSE_TIMEOUT:
|
case CURLOPT_SERVER_RESPONSE_TIMEOUT:
|
||||||
/*
|
/*
|
||||||
@ -2001,13 +2015,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||||||
/*
|
/*
|
||||||
* Set what local port to bind the socket to when performing an operation.
|
* Set what local port to bind the socket to when performing an operation.
|
||||||
*/
|
*/
|
||||||
data->set.localport = (unsigned short) va_arg(param, long);
|
data->set.localport = curlx_sltous(va_arg(param, long));
|
||||||
break;
|
break;
|
||||||
case CURLOPT_LOCALPORTRANGE:
|
case CURLOPT_LOCALPORTRANGE:
|
||||||
/*
|
/*
|
||||||
* Set number of local ports to try, starting with CURLOPT_LOCALPORT.
|
* Set number of local ports to try, starting with CURLOPT_LOCALPORT.
|
||||||
*/
|
*/
|
||||||
data->set.localportrange = (int) va_arg(param, long);
|
data->set.localportrange = curlx_sltosi(va_arg(param, long));
|
||||||
break;
|
break;
|
||||||
case CURLOPT_KRBLEVEL:
|
case CURLOPT_KRBLEVEL:
|
||||||
/*
|
/*
|
||||||
@ -2356,7 +2370,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||||||
* know that an unsigned int will always hold the value so we blindly
|
* know that an unsigned int will always hold the value so we blindly
|
||||||
* typecast to this type
|
* typecast to this type
|
||||||
*/
|
*/
|
||||||
data->set.scope = (unsigned int) va_arg(param, long);
|
data->set.scope = curlx_sltoui(va_arg(param, long));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLOPT_PROTOCOLS:
|
case CURLOPT_PROTOCOLS:
|
||||||
|
@ -125,3 +125,57 @@ int curlx_uztosi(size_t uznum)
|
|||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** signed long to signed int
|
||||||
|
*/
|
||||||
|
|
||||||
|
int curlx_sltosi(long slnum)
|
||||||
|
{
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (int)(slnum & (long) CURL_MASK_SINT);
|
||||||
|
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** signed long to unsigned int
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned int curlx_sltoui(long slnum)
|
||||||
|
{
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (unsigned int)(slnum & (long) CURL_MASK_UINT);
|
||||||
|
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** signed long to unsigned short
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned short curlx_sltous(long slnum)
|
||||||
|
{
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (unsigned short)(slnum & (long) CURL_MASK_USHORT);
|
||||||
|
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -28,4 +28,10 @@ unsigned char curlx_ultouc(unsigned long ulnum);
|
|||||||
|
|
||||||
int curlx_uztosi(size_t uznum);
|
int curlx_uztosi(size_t uznum);
|
||||||
|
|
||||||
|
int curlx_sltosi(long slnum);
|
||||||
|
|
||||||
|
unsigned int curlx_sltoui(long slnum);
|
||||||
|
|
||||||
|
unsigned short curlx_sltous(long slnum);
|
||||||
|
|
||||||
#endif /* HEADER_CURL_WARNLESS_H */
|
#endif /* HEADER_CURL_WARNLESS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user