build: fix Codacy warnings

Reduce variable scopes and remove redundant variable stores.

Closes https://github.com/curl/curl/pull/3975
This commit is contained in:
Marcel Raad 2019-05-25 10:06:08 +02:00
parent 04ac54e196
commit e23c52b329
No known key found for this signature in database
GPG key ID: FE4D8BC5EE1701DD
23 changed files with 80 additions and 123 deletions

View file

@ -620,12 +620,7 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...)
va_list arg;
void *paramp;
CURLcode ret;
unsigned int ccsid;
char * * cpp;
struct Curl_easy * data;
struct curl_slist * * slp;
struct curl_certinfo * cipf;
struct curl_certinfo * cipt;
/* WARNING: unlike curl_easy_getinfo(), the strings returned by this
procedure have to be free'ed. */
@ -635,7 +630,13 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...)
paramp = va_arg(arg, void *);
ret = Curl_getinfo(data, info, paramp);
if(ret == CURLE_OK)
if(ret == CURLE_OK) {
unsigned int ccsid;
char **cpp;
struct curl_slist **slp;
struct curl_certinfo *cipf;
struct curl_certinfo *cipt;
switch((int) info & CURLINFO_TYPEMASK) {
case CURLINFO_STRING:
@ -706,6 +707,7 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...)
break;
}
}
}
va_end(arg);
return ret;
@ -1355,13 +1357,12 @@ curl_pushheader_byname_ccsid(struct curl_pushheaders *h, const char *header,
{
char *d = (char *) NULL;
char *s;
if(header) {
header = dynconvert(ASCII_CCSID, header, -1, ccsidin);
if(header) {
s = curl_pushheader_byname(h, header);
char *s = curl_pushheader_byname(h, header);
free((char *) header);
if(s)

View file

@ -268,13 +268,9 @@ Curl_getnameinfo_a(const struct sockaddr * sa, curl_socklen_t salen,
int flags)
{
char * enodename;
char * eservname;
char *enodename = NULL;
char *eservname = NULL;
int status;
int i;
enodename = (char *) NULL;
eservname = (char *) NULL;
if(nodename && nodenamelen) {
enodename = malloc(nodenamelen);
@ -294,6 +290,7 @@ Curl_getnameinfo_a(const struct sockaddr * sa, curl_socklen_t salen,
eservname, servnamelen, flags);
if(!status) {
int i;
if(enodename) {
i = QadrtConvertE2A(nodename, enodename,
nodenamelen - 1, strlen(enodename));
@ -766,16 +763,13 @@ static int
Curl_gss_convert_in_place(OM_uint32 * minor_status, gss_buffer_t buf)
{
unsigned int i;
char * t;
unsigned int i = buf->length;
/* Convert `buf' in place, from EBCDIC to ASCII.
If error, release the buffer and return -1. Else return 0. */
i = buf->length;
if(i) {
t = malloc(i);
char *t = malloc(i);
if(!t) {
gss_release_buffer(minor_status, buf);
@ -865,7 +859,6 @@ Curl_gss_init_sec_context_a(OM_uint32 * minor_status,
{
int rc;
unsigned int i;
gss_buffer_desc in;
gss_buffer_t inp;
@ -874,7 +867,7 @@ Curl_gss_init_sec_context_a(OM_uint32 * minor_status,
if(inp) {
if(inp->length && inp->value) {
i = inp->length;
unsigned int i = inp->length;
in.value = malloc(i + 1);
if(!in.value) {