Commit 79954a1b authored by Yang Tse's avatar Yang Tse
Browse files

avoid mixing of enumerated type with another type

parent b33074d8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2943,7 +2943,7 @@ ConnectionExists(struct SessionHandle *data,
  struct connectdata *chosen = 0;
  bool canPipeline = IsPipeliningPossible(data, needle);
  bool wantNTLM = (data->state.authhost.want==CURLAUTH_NTLM) ||
                  (data->state.authhost.want==CURLAUTH_NTLM_WB);
                  (data->state.authhost.want==CURLAUTH_NTLM_WB) ? TRUE : FALSE;

  for(i=0; i< data->state.connc->num; i++) {
    bool match = FALSE;
+36 −36
Original line number Diff line number Diff line
@@ -398,9 +398,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
        GetStr(&config->egd_file, nextarg);
        break;
      case 'c': /* connect-timeout */
        rc=str2unum(&config->connecttimeout, nextarg);
        if(rc)
          return rc;
        err = str2unum(&config->connecttimeout, nextarg);
        if(err)
          return err;
        break;
      case 'd': /* ciphers */
        GetStr(&config->cipher_list, nextarg);
@@ -545,9 +545,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
      case 's': /* --max-redirs */
        /* specified max no of redirects (http(s)), this accepts -1 as a
           special condition */
        rc = str2num(&config->maxredirs, nextarg);
        if(rc)
          return rc;
        err = str2num(&config->maxredirs, nextarg);
        if(err)
          return err;
        if(config->maxredirs < -1)
          return PARAM_BAD_NUMERIC;
        break;
@@ -592,9 +592,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
          return PARAM_LIBCURL_DOESNT_SUPPORT;
        break;
      case 'y': /* --max-filesize */
        rc = str2offset(&config->max_filesize, nextarg);
        if(rc)
          return rc;
        err = str2offset(&config->max_filesize, nextarg);
        if(err)
          return err;
        break;
      case 'z': /* --disable-eprt */
        config->disable_eprt = toggle;
@@ -670,19 +670,19 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
        config->proxybasic = toggle;
        break;
      case 'g': /* --retry */
        rc = str2unum(&config->req_retry, nextarg);
        if(rc)
          return rc;
        err = str2unum(&config->req_retry, nextarg);
        if(err)
          return err;
        break;
      case 'h': /* --retry-delay */
        rc = str2unum(&config->retry_delay, nextarg);
        if(rc)
          return rc;
        err = str2unum(&config->retry_delay, nextarg);
        if(err)
          return err;
        break;
      case 'i': /* --retry-max-time */
        rc = str2unum(&config->retry_maxtime, nextarg);
        if(rc)
          return rc;
        err = str2unum(&config->retry_maxtime, nextarg);
        if(err)
          return err;
        break;

      case 'k': /* --proxy-negotiate */
@@ -769,9 +769,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
        config->nokeepalive = (!toggle)?TRUE:FALSE;
        break;
      case '3': /* --keepalive-time */
        rc = str2unum(&config->alivetime, nextarg);
        if(rc)
          return rc;
        err = str2unum(&config->alivetime, nextarg);
        if(err)
          return err;
        break;
      case '4': /* --post302 */
        config->post302 = toggle;
@@ -797,9 +797,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
        config->proxyver = CURLPROXY_HTTP_1_0;
        break;
      case '9': /* --tftp-blksize */
        rc = str2unum(&config->tftp_blksize, nextarg);
        if(rc)
          return rc;
        err = str2unum(&config->tftp_blksize, nextarg);
        if(err)
          return err;
        break;
      case 'A': /* --mail-from */
        GetStr(&config->mail_from, nextarg);
@@ -924,9 +924,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
    case 'C':
      /* This makes us continue an ftp transfer at given position */
      if(!curlx_strequal(nextarg, "-")) {
        rc = str2offset(&config->resume_from, nextarg);
        if(rc)
          return rc;
        err = str2offset(&config->resume_from, nextarg);
        if(err)
          return err;
        config->resume_from_current = FALSE;
      }
      else {
@@ -1317,9 +1317,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
      break;
    case 'm':
      /* specified max time */
      rc = str2unum(&config->timeout, nextarg);
      if(rc)
        return rc;
      err = str2unum(&config->timeout, nextarg);
      if(err)
        return err;
      break;
    case 'M': /* M for manual, huge help */
      if(toggle) { /* --no-manual shows no manual... */
@@ -1633,17 +1633,17 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
      break;
    case 'y':
      /* low speed time */
      rc = str2unum(&config->low_speed_time, nextarg);
      if(rc)
        return rc;
      err = str2unum(&config->low_speed_time, nextarg);
      if(err)
        return err;
      if(!config->low_speed_limit)
        config->low_speed_limit = 1;
      break;
    case 'Y':
      /* low speed limit */
      rc = str2unum(&config->low_speed_limit, nextarg);
      if(rc)
        return rc;
      err = str2unum(&config->low_speed_limit, nextarg);
      if(err)
        return err;
      if(!config->low_speed_time)
        config->low_speed_time = 30;
      break;
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
#include "tool_setup.h"

typedef enum {
  PARAM_OK,
  PARAM_OK = 0,
  PARAM_OPTION_AMBIGUOUS,
  PARAM_OPTION_UNKNOWN,
  PARAM_REQUIRES_PARAMETER,
+9 −9
Original line number Diff line number Diff line
@@ -146,15 +146,15 @@ void cleanarg(char *str)
}

/*
 * Parse the string and write the long in the given address. Return non-zero
 * on failure, zero on success.
 * Parse the string and write the long in the given address. Return PARAM_OK
 * on success, otherwise a parameter specific error enum.
 *
 * Since this function gets called with the 'nextarg' pointer from within the
 * getparameter a lot, we must check it for NULL before accessing the str
 * data.
 */

int str2num(long *val, const char *str)
ParameterError str2num(long *val, const char *str)
{
  if(str) {
    char *endptr;
@@ -168,15 +168,15 @@ int str2num(long *val, const char *str)
}

/*
 * Parse the string and write the long in the given address. Return non-zero
 * on failure, zero on success. ONLY ACCEPTS POSITIVE NUMBERS!
 * Parse the string and write the long in the given address. Return PARAM_OK
 * on success, otherwise a parameter error enum. ONLY ACCEPTS POSITIVE NUMBERS!
 *
 * Since this function gets called with the 'nextarg' pointer from within the
 * getparameter a lot, we must check it for NULL before accessing the str
 * data.
 */

int str2unum(long *val, const char *str)
ParameterError str2unum(long *val, const char *str)
{
  if(str[0]=='-')
    return PARAM_NEGATIVE_NUMERIC; /* badness */
@@ -295,9 +295,9 @@ long proto2num(struct Configurable *config, long *val, const char *str)
 *
 * @param val  the offset to populate
 * @param str  the buffer containing the offset
 * @return zero if successful, non-zero if failure.
 * @return PARAM_OK if successful, a parameter specific error enum if failure.
 */
int str2offset(curl_off_t *val, const char *str)
ParameterError str2offset(curl_off_t *val, const char *str)
{
  char *endptr;
  if(str[0] == '-')
@@ -314,7 +314,7 @@ int str2offset(curl_off_t *val, const char *str)
    return PARAM_BAD_NUMERIC;
#endif
  if((endptr != str) && (endptr == str + strlen(str)))
    return 0;  /* Ok */
    return PARAM_OK;

  return PARAM_BAD_NUMERIC;
}
+3 −3
Original line number Diff line number Diff line
@@ -31,12 +31,12 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file);

void cleanarg(char *str);

int str2num(long *val, const char *str);
int str2unum(long *val, const char *str); /* for unsigned input numbers */
ParameterError str2num(long *val, const char *str);
ParameterError str2unum(long *val, const char *str);

long proto2num(struct Configurable *config, long *val, const char *str);

int str2offset(curl_off_t *val, const char *str);
ParameterError str2offset(curl_off_t *val, const char *str);

ParameterError checkpasswd(const char *kind, char **userpwd);

Loading