diff options
author | Sylvestre Ledru <sylvestre@debian.org> | 2017-03-10 14:28:37 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2017-03-13 23:11:45 +0100 |
commit | 66de563482c0fd4324e1eae19809d2499e3c4fa8 (patch) | |
tree | bf3178878ebe2461388e8fec01e321173ffe30f8 /src | |
parent | db87bcfcf21f8c3b8188d0c5ab82faf804ffd5ea (diff) | |
download | curl-66de563482c0fd4324e1eae19809d2499e3c4fa8.tar.gz |
Improve code readbility
... by removing the else branch after a return, break or continue.
Closes #1310
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_cb_hdr.c | 3 | ||||
-rw-r--r-- | src/tool_getparam.c | 47 | ||||
-rw-r--r-- | src/tool_getpass.c | 14 | ||||
-rw-r--r-- | src/tool_util.c | 3 |
4 files changed, 30 insertions, 37 deletions
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 3891b073b..bedc7b385 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -128,8 +128,7 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata) hdrcbdata->honor_cd_filename = FALSE; break; } - else - return failure; + return failure; } } diff --git a/src/tool_getparam.c b/src/tool_getparam.c index e7ac35476..c8c53fad1 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -783,11 +783,10 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ if(!url) return PARAM_NO_MEM; - else { - /* fill in the URL */ - GetStr(&url->url, nextarg); - url->flags |= GETOUT_URL; - } + + /* fill in the URL */ + GetStr(&url->url, nextarg); + url->flags |= GETOUT_URL; } } break; @@ -878,7 +877,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ &config->localportrange); if(!rc) return PARAM_BAD_USE; - else if(rc == 1) + if(rc == 1) config->localportrange = 1; /* default number of ports to try */ else { config->localportrange -= config->localport; @@ -1728,21 +1727,20 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ if(!url) return PARAM_NO_MEM; + + /* fill in the outfile */ + if('o' == letter) { + GetStr(&url->outfile, nextarg); + url->flags &= ~GETOUT_USEREMOTE; /* switch off */ + } else { - /* fill in the outfile */ - if('o' == letter) { - GetStr(&url->outfile, nextarg); + url->outfile = NULL; /* leave it */ + if(toggle) + url->flags |= GETOUT_USEREMOTE; /* switch on */ + else url->flags &= ~GETOUT_USEREMOTE; /* switch off */ - } - else { - url->outfile = NULL; /* leave it */ - if(toggle) - url->flags |= GETOUT_USEREMOTE; /* switch on */ - else - url->flags &= ~GETOUT_USEREMOTE; /* switch off */ - } - url->flags |= GETOUT_OUTFILE; } + url->flags |= GETOUT_OUTFILE; } break; case 'P': @@ -1867,14 +1865,13 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ if(!url) return PARAM_NO_MEM; + + url->flags |= GETOUT_UPLOAD; /* mark -T used */ + if(!*nextarg) + url->flags |= GETOUT_NOUPLOAD; else { - url->flags |= GETOUT_UPLOAD; /* mark -T used */ - if(!*nextarg) - url->flags |= GETOUT_NOUPLOAD; - else { - /* "-" equals stdin, but keep the string around for now */ - GetStr(&url->infile, nextarg); - } + /* "-" equals stdin, but keep the string around for now */ + GetStr(&url->infile, nextarg); } } break; diff --git a/src/tool_getpass.c b/src/tool_getpass.c index 8e3e5fa86..e5e2d6dc1 100644 --- a/src/tool_getpass.c +++ b/src/tool_getpass.c @@ -207,18 +207,16 @@ static bool ttyecho(bool enable, int fd) #endif return TRUE; /* disabled */ } - else { - /* re-enable echo, assumes we disabled it before (and set the structs we - now use to reset the terminal status) */ + /* re-enable echo, assumes we disabled it before (and set the structs we + now use to reset the terminal status) */ #ifdef HAVE_TERMIOS_H - tcsetattr(fd, TCSAFLUSH, &withecho); + tcsetattr(fd, TCSAFLUSH, &withecho); #elif defined(HAVE_TERMIO_H) - ioctl(fd, TCSETA, &withecho); + ioctl(fd, TCSETA, &withecho); #else - return FALSE; /* not enabled */ + return FALSE; /* not enabled */ #endif - return TRUE; /* enabled */ - } + return TRUE; /* enabled */ } char *getpass_r(const char *prompt, /* prompt to display */ diff --git a/src/tool_util.c b/src/tool_util.c index 8af15ff0c..15b91d303 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -135,8 +135,7 @@ double tool_tvdiff_secs(struct timeval newer, struct timeval older) if(newer.tv_sec != older.tv_sec) return (double)(newer.tv_sec-older.tv_sec)+ (double)(newer.tv_usec-older.tv_usec)/1000000.0; - else - return (double)(newer.tv_usec-older.tv_usec)/1000000.0; + return (double)(newer.tv_usec-older.tv_usec)/1000000.0; } /* return the number of seconds in the given input timeval struct */ |