Unverified Commit e23c52b3 authored by Marcel Raad's avatar Marcel Raad
Browse files

build: fix Codacy warnings

Reduce variable scopes and remove redundant variable stores.

Closes https://github.com/curl/curl/pull/3975
parent 04ac54e1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ int main(void)
#if   defined(HAVE_GETHOSTBYADDR_R_5) || \
      defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT)
  rc = gethostbyaddr_r(address, length, type, &h, &hdata);
  (void)rc;
#elif defined(HAVE_GETHOSTBYADDR_R_7) || \
      defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT)
  hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop);
@@ -132,6 +133,7 @@ int main(void)
#elif defined(HAVE_GETHOSTBYADDR_R_8) || \
      defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT)
  rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop);
  (void)rc;
#endif

#if   defined(HAVE_GETHOSTBYNAME_R_3) || \
+1 −3
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ static size_t write_it(char *buff, size_t size, size_t nmemb,

int main(int argc, char **argv)
{
  int rc = CURLE_OK;

  /* curl easy handle */
  CURL *handle;

@@ -50,7 +48,7 @@ int main(int argc, char **argv)
  struct callback_data data = { 0 };

  /* global initialization */
  rc = curl_global_init(CURL_GLOBAL_ALL);
  int rc = curl_global_init(CURL_GLOBAL_ALL);
  if(rc)
    return rc;

+5 −4
Original line number Diff line number Diff line
@@ -137,7 +137,6 @@ size_t SyncTime_CURL_WriteOutput(void *ptr, size_t size, size_t nmemb,
size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
                                 void *stream)
{
  int   i, RetVal;
  char  TmpStr1[26], TmpStr2[26];

  (void)stream;
@@ -156,11 +155,13 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
                                         TmpStr1 & 2? */
        AutoSyncTime = 0;
      else {
        RetVal = sscanf((char *)(ptr), "Date: %s %hu %s %hu %hu:%hu:%hu",
        int RetVal = sscanf((char *)(ptr), "Date: %s %hu %s %hu %hu:%hu:%hu",
                            TmpStr1, &SYSTime.wDay, TmpStr2, &SYSTime.wYear,
                        &SYSTime.wHour, &SYSTime.wMinute, &SYSTime.wSecond);
                            &SYSTime.wHour, &SYSTime.wMinute,
                            &SYSTime.wSecond);

        if(RetVal == 7) {
          int i;
          SYSTime.wMilliseconds = 500;    /* adjust to midpoint, 0.5 sec */
          for(i = 0; i<12; i++) {
            if(strcmp(MthStr[i], TmpStr2) == 0) {
+1 −2
Original line number Diff line number Diff line
@@ -218,7 +218,6 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out,
                        const unsigned char *key_56)
{
  const CK_MECHANISM_TYPE mech = CKM_DES_ECB; /* DES cipher in ECB mode */
  PK11SlotInfo *slot = NULL;
  char key[8];                                /* expanded 64 bit key */
  SECItem key_item;
  PK11SymKey *symkey = NULL;
@@ -228,7 +227,7 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out,
  bool rv = FALSE;

  /* use internal slot for DES encryption (requires NSS to be initialized) */
  slot = PK11_GetInternalKeySlot();
  PK11SlotInfo *slot = PK11_GetInternalKeySlot();
  if(!slot)
    return FALSE;

+3 −15
Original line number Diff line number Diff line
@@ -565,10 +565,8 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
#ifdef HAVE_GSSAPI
  char * const buf = data->state.buffer;
#endif
  CURLcode result = CURLE_OK;
  int code;

  result = Curl_pp_readresp(sockfd, pp, &code, size);
  CURLcode result = Curl_pp_readresp(sockfd, pp, &code, size);

#if defined(HAVE_GSSAPI)
  /* handle the security-oriented responses 6xx ***/
@@ -1499,24 +1497,14 @@ static CURLcode ftp_state_list(struct connectdata *conn)

static CURLcode ftp_state_retr_prequote(struct connectdata *conn)
{
  CURLcode result = CURLE_OK;

  /* We've sent the TYPE, now we must send the list of prequote strings */

  result = ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE);

  return result;
  return ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE);
}

static CURLcode ftp_state_stor_prequote(struct connectdata *conn)
{
  CURLcode result = CURLE_OK;

  /* We've sent the TYPE, now we must send the list of prequote strings */

  result = ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE);

  return result;
  return ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE);
}

static CURLcode ftp_state_type(struct connectdata *conn)
Loading