Permalink
Browse files

getinfo: use va_end and cut off Curl_ from static funcs

va_end() needs to be used after va_start() and we don't normally use
Curl_ prefixes for purely static functions.
  • Loading branch information...
1 parent 1a74e54 commit 771e91374b7e68c8c0d20af63821c29598964fa0 @bagder bagder committed Jul 13, 2012
Showing with 27 additions and 22 deletions.
  1. +27 −22 lib/getinfo.c
View
@@ -72,8 +72,8 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
return CURLE_OK;
}
-static CURLcode Curl_getinfo_char(struct SessionHandle *data, CURLINFO info,
- char **param_charp)
+static CURLcode getinfo_char(struct SessionHandle *data, CURLINFO info,
+ char **param_charp)
{
switch(info) {
case CURLINFO_EFFECTIVE_URL:
@@ -117,8 +117,8 @@ static CURLcode Curl_getinfo_char(struct SessionHandle *data, CURLINFO info,
return CURLE_OK;
}
-static CURLcode Curl_getinfo_long(struct SessionHandle *data, CURLINFO info,
- long *param_longp)
+static CURLcode getinfo_long(struct SessionHandle *data, CURLINFO info,
+ long *param_longp)
{
curl_socket_t sockfd;
@@ -203,8 +203,8 @@ static CURLcode Curl_getinfo_long(struct SessionHandle *data, CURLINFO info,
return CURLE_OK;
}
-static CURLcode Curl_getinfo_double(struct SessionHandle *data, CURLINFO info,
- double *param_doublep)
+static CURLcode getinfo_double(struct SessionHandle *data, CURLINFO info,
+ double *param_doublep)
{
switch(info) {
case CURLINFO_TOTAL_TIME:
@@ -255,8 +255,8 @@ static CURLcode Curl_getinfo_double(struct SessionHandle *data, CURLINFO info,
return CURLE_OK;
}
-static CURLcode Curl_getinfo_slist(struct SessionHandle *data, CURLINFO info,
- struct curl_slist **param_slistp)
+static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info,
+ struct curl_slist **param_slistp)
{
union {
struct curl_certinfo * to_certinfo;
@@ -291,35 +291,40 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
char **param_charp=NULL;
struct curl_slist **param_slistp=NULL;
int type;
+ /* default return code is to error out! */
+ CURLcode ret = CURLE_BAD_FUNCTION_ARGUMENT;
if(!data)
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ return ret;
va_start(arg, info);
type = CURLINFO_TYPEMASK & (int)info;
switch(type) {
case CURLINFO_STRING:
param_charp = va_arg(arg, char **);
- if(NULL == param_charp)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- return Curl_getinfo_char(data, info, param_charp);
+ if(NULL != param_charp)
+ ret = getinfo_char(data, info, param_charp);
+ break;
case CURLINFO_LONG:
param_longp = va_arg(arg, long *);
- if(NULL == param_longp)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- return Curl_getinfo_long(data, info, param_longp);
+ if(NULL != param_longp)
+ ret = getinfo_long(data, info, param_longp);
+ break;
case CURLINFO_DOUBLE:
param_doublep = va_arg(arg, double *);
- if(NULL == param_doublep)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- return Curl_getinfo_double(data, info, param_doublep);
+ if(NULL != param_doublep)
+ ret = getinfo_double(data, info, param_doublep);
+ break;
case CURLINFO_SLIST:
param_slistp = va_arg(arg, struct curl_slist **);
- if(NULL == param_slistp)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- return Curl_getinfo_slist(data, info, param_slistp);
+ if(NULL != param_slistp)
+ ret = getinfo_slist(data, info, param_slistp);
+ break;
default:
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ break;
}
+
+ va_end(arg);
+ return ret;
}

0 comments on commit 771e913

Please sign in to comment.