1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-12 04:25:08 -05:00

setstropt: const-correctness

Closes #565
This commit is contained in:
Anders Bakken 2015-12-14 13:21:32 -08:00 committed by Daniel Stenberg
parent 63a5a756a8
commit 8fbaf6749a

View File

@ -296,7 +296,7 @@ void Curl_freeset(struct SessionHandle *data)
data->change.url = NULL; data->change.url = NULL;
} }
static CURLcode setstropt(char **charp, char *s) static CURLcode setstropt(char **charp, const char *s)
{ {
/* Release the previous storage at `charp' and replace by a dynamic storage /* Release the previous storage at `charp' and replace by a dynamic storage
copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */ copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */
@ -304,12 +304,12 @@ static CURLcode setstropt(char **charp, char *s)
Curl_safefree(*charp); Curl_safefree(*charp);
if(s) { if(s) {
s = strdup(s); char *str = strdup(s);
if(!s) if(!str)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
*charp = s; *charp = str;
} }
return CURLE_OK; return CURLE_OK;
@ -572,31 +572,31 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
set->socks5_gssapi_nec = FALSE; set->socks5_gssapi_nec = FALSE;
/* set default GSS-API service name */ /* set default GSS-API service name */
result = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE], result = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE],
(char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE); CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE);
if(result) if(result)
return result; return result;
/* set default negotiate proxy service name */ /* set default negotiate proxy service name */
result = setstropt(&set->str[STRING_PROXY_SERVICE_NAME], result = setstropt(&set->str[STRING_PROXY_SERVICE_NAME],
(char *) CURL_DEFAULT_PROXY_SERVICE_NAME); CURL_DEFAULT_PROXY_SERVICE_NAME);
if(result) if(result)
return result; return result;
/* set default negotiate service name */ /* set default negotiate service name */
result = setstropt(&set->str[STRING_SERVICE_NAME], result = setstropt(&set->str[STRING_SERVICE_NAME],
(char *) CURL_DEFAULT_SERVICE_NAME); CURL_DEFAULT_SERVICE_NAME);
if(result) if(result)
return result; return result;
#endif #endif
/* This is our preferred CA cert bundle/path since install time */ /* This is our preferred CA cert bundle/path since install time */
#if defined(CURL_CA_BUNDLE) #if defined(CURL_CA_BUNDLE)
result = setstropt(&set->str[STRING_SSL_CAFILE], (char *) CURL_CA_BUNDLE); result = setstropt(&set->str[STRING_SSL_CAFILE], CURL_CA_BUNDLE);
if(result) if(result)
return result; return result;
#endif #endif
#if defined(CURL_CA_PATH) #if defined(CURL_CA_PATH)
result = setstropt(&set->str[STRING_SSL_CAPATH], (char *) CURL_CA_PATH); result = setstropt(&set->str[STRING_SSL_CAPATH], CURL_CA_PATH);
if(result) if(result)
return result; return result;
#endif #endif
@ -936,7 +936,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
argptr = va_arg(param, char *); argptr = va_arg(param, char *);
result = setstropt(&data->set.str[STRING_ENCODING], result = setstropt(&data->set.str[STRING_ENCODING],
(argptr && !*argptr)? (argptr && !*argptr)?
(char *) ALL_CONTENT_ENCODINGS: argptr); ALL_CONTENT_ENCODINGS: argptr);
break; break;
case CURLOPT_TRANSFER_ENCODING: case CURLOPT_TRANSFER_ENCODING: