From 14045b9be6c8b16544c6ea3fa28d3d26f5eefa61 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Sun, 13 Sep 2020 17:19:32 +0200 Subject: build: remove dead assignments Signed-off-by: Daiki Ueno --- lib/auth/psk_passwd.c | 2 +- lib/auth/srp_passwd.c | 4 +-- lib/ext/pre_shared_key.c | 2 +- lib/x509/key_decode.c | 18 +++++------ lib/x509/output.c | 8 ++--- lib/x509/privkey.c | 77 ++++++++++++++++++++---------------------------- lib/x509/verify.c | 7 ++--- lib/x509_b64.c | 2 +- libdane/dane.c | 9 +++--- src/certtool-common.c | 2 +- src/srptool.c | 4 +-- 11 files changed, 57 insertions(+), 78 deletions(-) diff --git a/lib/auth/psk_passwd.c b/lib/auth/psk_passwd.c index 9a9d68c488..2953c2d8ad 100644 --- a/lib/auth/psk_passwd.c +++ b/lib/auth/psk_passwd.c @@ -105,7 +105,7 @@ static bool username_matches(const gnutls_datum_t *username, hexline.data = (void *) &line[1]; hexline.size = i - 1; - if ((retval = gnutls_hex_decode2(&hexline, &hex_username)) < 0) + if (gnutls_hex_decode2(&hexline, &hex_username) < 0) return gnutls_assert_val(0); if (hex_username.size == username->size) diff --git a/lib/auth/srp_passwd.c b/lib/auth/srp_passwd.c index 49039a66e7..e7d8d602e6 100644 --- a/lib/auth/srp_passwd.c +++ b/lib/auth/srp_passwd.c @@ -218,9 +218,7 @@ pwd_read_conf(const char *pconf_file, SRP_PWD_ENTRY * entry, int idx) } if (strncmp(indexstr, line, MAX(i, len)) == 0) { - if ((idx = - parse_tpasswd_conf_values(entry, - line)) >= 0) { + if (parse_tpasswd_conf_values(entry, line) >= 0) { ret = 0; goto cleanup; } else { diff --git a/lib/ext/pre_shared_key.c b/lib/ext/pre_shared_key.c index 7965ee760d..b5a86b7db1 100644 --- a/lib/ext/pre_shared_key.c +++ b/lib/ext/pre_shared_key.c @@ -575,7 +575,7 @@ static int server_recv_params(gnutls_session_t session, /* This will unpack the session ticket if it is well * formed and has the expected name */ if (!(session->internals.flags & GNUTLS_NO_TICKETS) && - (ret = _gnutls13_unpack_session_ticket(session, &psk.identity, &ticket_data)) == 0) { + _gnutls13_unpack_session_ticket(session, &psk.identity, &ticket_data) == 0) { prf = ticket_data.prf; session->internals.resumption_requested = 1; diff --git a/lib/x509/key_decode.c b/lib/x509/key_decode.c index c79f6eee37..00378af94d 100644 --- a/lib/x509/key_decode.c +++ b/lib/x509/key_decode.c @@ -76,16 +76,15 @@ _gnutls_x509_read_rsa_pubkey(uint8_t * der, int dersize, } - if ((result = - _gnutls_x509_read_int(spk, "modulus", - ¶ms->params[0])) < 0) { + if (_gnutls_x509_read_int(spk, "modulus", + ¶ms->params[0]) < 0) { gnutls_assert(); asn1_delete_structure(&spk); return GNUTLS_E_ASN1_GENERIC_ERROR; } - if ((result = _gnutls_x509_read_int(spk, "publicExponent", - ¶ms->params[1])) < 0) { + if (_gnutls_x509_read_int(spk, "publicExponent", + ¶ms->params[1]) < 0) { gnutls_assert(); _gnutls_mpi_release(¶ms->params[0]); asn1_delete_structure(&spk); @@ -200,8 +199,7 @@ _gnutls_x509_read_dsa_params(uint8_t * der, int dersize, /* Read p */ - if ((result = - _gnutls_x509_read_int(spk, "p", ¶ms->params[0])) < 0) { + if (_gnutls_x509_read_int(spk, "p", ¶ms->params[0]) < 0) { gnutls_assert(); asn1_delete_structure(&spk); return GNUTLS_E_ASN1_GENERIC_ERROR; @@ -209,8 +207,7 @@ _gnutls_x509_read_dsa_params(uint8_t * der, int dersize, /* Read q */ - if ((result = - _gnutls_x509_read_int(spk, "q", ¶ms->params[1])) < 0) { + if (_gnutls_x509_read_int(spk, "q", ¶ms->params[1]) < 0) { gnutls_assert(); asn1_delete_structure(&spk); _gnutls_mpi_release(¶ms->params[0]); @@ -219,8 +216,7 @@ _gnutls_x509_read_dsa_params(uint8_t * der, int dersize, /* Read g */ - if ((result = - _gnutls_x509_read_int(spk, "g", ¶ms->params[2])) < 0) { + if (_gnutls_x509_read_int(spk, "g", ¶ms->params[2]) < 0) { gnutls_assert(); asn1_delete_structure(&spk); _gnutls_mpi_release(¶ms->params[0]); diff --git a/lib/x509/output.c b/lib/x509/output.c index 705e8babfa..b669b86b22 100644 --- a/lib/x509/output.c +++ b/lib/x509/output.c @@ -897,18 +897,18 @@ static void print_subject_sign_tool(gnutls_buffer_st * str, const char *prefix, static void print_issuer_sign_tool(gnutls_buffer_st * str, const char *prefix, const gnutls_datum_t *der) { - int ret, result; + int ret; ASN1_TYPE tmpasn = ASN1_TYPE_EMPTY; char asn1_err[ASN1_MAX_ERROR_DESCRIPTION_SIZE] = ""; gnutls_datum_t tmp; - if ((result = asn1_create_element(_gnutls_get_gnutls_asn(), "GNUTLS.IssuerSignTool", - &tmpasn)) != ASN1_SUCCESS) { + if (asn1_create_element(_gnutls_get_gnutls_asn(), "GNUTLS.IssuerSignTool", + &tmpasn) != ASN1_SUCCESS) { gnutls_assert(); goto hexdump; } - if ((result = _asn1_strict_der_decode(&tmpasn, der->data, der->size, asn1_err)) != ASN1_SUCCESS) { + if (_asn1_strict_der_decode(&tmpasn, der->data, der->size, asn1_err) != ASN1_SUCCESS) { gnutls_assert(); _gnutls_debug_log("_asn1_strict_der_decode: %s\n", asn1_err); goto hexdump; diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c index 3852064648..f35575be9a 100644 --- a/lib/x509/privkey.c +++ b/lib/x509/privkey.c @@ -135,10 +135,9 @@ _gnutls_privkey_decode_pkcs1_rsa_key(const gnutls_datum_t * raw_key, gnutls_pk_params_init(&pkey->params); - if ((result = - asn1_create_element(_gnutls_get_gnutls_asn(), - "GNUTLS.RSAPrivateKey", - &pkey_asn)) != ASN1_SUCCESS) { + if (asn1_create_element(_gnutls_get_gnutls_asn(), + "GNUTLS.RSAPrivateKey", + &pkey_asn) != ASN1_SUCCESS) { gnutls_assert(); return NULL; } @@ -151,65 +150,58 @@ _gnutls_privkey_decode_pkcs1_rsa_key(const gnutls_datum_t * raw_key, goto error; } - if ((result = _gnutls_x509_read_int(pkey_asn, "modulus", - &pkey->params.params[0])) < 0) + if (_gnutls_x509_read_int(pkey_asn, "modulus", + &pkey->params.params[0]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = - _gnutls_x509_read_int(pkey_asn, "publicExponent", - &pkey->params.params[1])) < 0) { + if (_gnutls_x509_read_int(pkey_asn, "publicExponent", + &pkey->params.params[1]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = - _gnutls_x509_read_key_int(pkey_asn, "privateExponent", - &pkey->params.params[2])) < 0) { + if (_gnutls_x509_read_key_int(pkey_asn, "privateExponent", + &pkey->params.params[2]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = _gnutls_x509_read_key_int(pkey_asn, "prime1", - &pkey->params.params[3])) < 0) - { + if (_gnutls_x509_read_key_int(pkey_asn, "prime1", + &pkey->params.params[3]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = _gnutls_x509_read_key_int(pkey_asn, "prime2", - &pkey->params.params[4])) < 0) - { + if (_gnutls_x509_read_key_int(pkey_asn, "prime2", + &pkey->params.params[4]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = _gnutls_x509_read_key_int(pkey_asn, "coefficient", - &pkey->params.params[5])) < 0) - { + if (_gnutls_x509_read_key_int(pkey_asn, "coefficient", + &pkey->params.params[5]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = _gnutls_x509_read_key_int(pkey_asn, "exponent1", - &pkey->params.params[6])) < 0) - { + if (_gnutls_x509_read_key_int(pkey_asn, "exponent1", + &pkey->params.params[6]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = _gnutls_x509_read_key_int(pkey_asn, "exponent2", - &pkey->params.params[7])) < 0) - { + if (_gnutls_x509_read_key_int(pkey_asn, "exponent2", + &pkey->params.params[7]) < 0) { gnutls_assert(); goto error; } @@ -353,10 +345,9 @@ decode_dsa_key(const gnutls_datum_t * raw_key, gnutls_x509_privkey_t pkey) char oid[MAX_OID_SIZE]; int oid_size; - if ((result = - asn1_create_element(_gnutls_get_gnutls_asn(), - "GNUTLS.DSAPrivateKey", - &dsa_asn)) != ASN1_SUCCESS) { + if (asn1_create_element(_gnutls_get_gnutls_asn(), + "GNUTLS.DSAPrivateKey", + &dsa_asn) != ASN1_SUCCESS) { gnutls_assert(); return NULL; } @@ -372,40 +363,36 @@ decode_dsa_key(const gnutls_datum_t * raw_key, gnutls_x509_privkey_t pkey) goto error; } - if ((result = - _gnutls_x509_read_int(dsa_asn, "p", - &pkey->params.params[0])) < 0) { + if (_gnutls_x509_read_int(dsa_asn, "p", + &pkey->params.params[0]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = - _gnutls_x509_read_int(dsa_asn, "q", - &pkey->params.params[1])) < 0) { + if (_gnutls_x509_read_int(dsa_asn, "q", + &pkey->params.params[1]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = - _gnutls_x509_read_int(dsa_asn, "g", - &pkey->params.params[2])) < 0) { + if (_gnutls_x509_read_int(dsa_asn, "g", + &pkey->params.params[2]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = - _gnutls_x509_read_int(dsa_asn, "Y", - &pkey->params.params[3])) < 0) { + if (_gnutls_x509_read_int(dsa_asn, "Y", + &pkey->params.params[3]) < 0) { gnutls_assert(); goto error; } pkey->params.params_nr++; - if ((result = _gnutls_x509_read_key_int(dsa_asn, "priv", - &pkey->params.params[4])) < 0) + if (_gnutls_x509_read_key_int(dsa_asn, "priv", + &pkey->params.params[4]) < 0) { gnutls_assert(); goto error; diff --git a/lib/x509/verify.c b/lib/x509/verify.c index 4363e818b1..bab223ceca 100644 --- a/lib/x509/verify.c +++ b/lib/x509/verify.c @@ -1074,13 +1074,12 @@ _gnutls_verify_crt_status(gnutls_x509_trust_list_t tlist, flags |= GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT; } - if ((ret = - verify_crt(tlist, - certificate_list[i - 1], + if (!verify_crt(tlist, + certificate_list[i - 1], &certificate_list[i], 1, flags, &output, &vparams, - i==1?1:0)) != 1) { + i==1?1:0)) { gnutls_assert(); status |= output; status |= GNUTLS_CERT_INVALID; diff --git a/lib/x509_b64.c b/lib/x509_b64.c index fcace95a6f..668760a0b3 100644 --- a/lib/x509_b64.c +++ b/lib/x509_b64.c @@ -86,7 +86,7 @@ _gnutls_fbase64_encode(const char *msg, const uint8_t * data, return GNUTLS_E_MEMORY_ERROR; } - bytes = pos = 0; + bytes = 0; INCR(bytes, top_len, max); pos = top_len; diff --git a/libdane/dane.c b/libdane/dane.c index f05f3ce92c..a7236f9f7b 100644 --- a/libdane/dane.c +++ b/libdane/dane.c @@ -248,13 +248,13 @@ int dane_state_init(dane_state_t * s, unsigned int flags) ub_ctx_debugout(ctx, stderr); if (!(flags & DANE_F_IGNORE_LOCAL_RESOLVER)) { - if ((ret = ub_ctx_resolvconf(ctx, NULL)) != 0) { + if (ub_ctx_resolvconf(ctx, NULL) != 0) { gnutls_assert(); ret = DANE_E_INITIALIZATION_ERROR; goto cleanup; } - if ((ret = ub_ctx_hosts(ctx, NULL)) != 0) { + if (ub_ctx_hosts(ctx, NULL) != 0) { gnutls_assert(); ret = DANE_E_INITIALIZATION_ERROR; goto cleanup; @@ -263,9 +263,8 @@ int dane_state_init(dane_state_t * s, unsigned int flags) /* read public keys for DNSSEC verification */ if (!(flags & DANE_F_IGNORE_DNSSEC)) { - if ((ret = - ub_ctx_add_ta_file(ctx, - (char *) UNBOUND_ROOT_KEY_FILE)) != + if (ub_ctx_add_ta_file(ctx, + (char *) UNBOUND_ROOT_KEY_FILE) != 0) { gnutls_assert(); ret = DANE_E_INITIALIZATION_ERROR; diff --git a/src/certtool-common.c b/src/certtool-common.c index 3af2d08080..31e1c2619f 100644 --- a/src/certtool-common.c +++ b/src/certtool-common.c @@ -698,7 +698,7 @@ gnutls_pubkey_t load_public_key_or_import(int mand, app_exit(1); } - if (!privkey || (ret = gnutls_pubkey_import_privkey(pubkey, privkey, 0, 0)) < 0) { /* could not get (e.g. on PKCS #11 */ + if (!privkey || gnutls_pubkey_import_privkey(pubkey, privkey, 0, 0) < 0) { /* could not get (e.g. on PKCS #11) */ gnutls_pubkey_deinit(pubkey); pubkey = load_pubkey(0, info); if (pubkey == NULL && mand) { diff --git a/src/srptool.c b/src/srptool.c index 7939f6bfab..7da14afa6c 100644 --- a/src/srptool.c +++ b/src/srptool.c @@ -318,7 +318,7 @@ verify_passwd(const char *conffile, const char *tpasswd, fclose(fp); - if ((iindex = read_conf_values(&g, &n, line)) < 0) { + if (read_conf_values(&g, &n, line) < 0) { fprintf(stderr, "Cannot parse conf file '%s'\n", conffile); return -1; } @@ -528,7 +528,7 @@ crypt_int(const char *username, const char *passwd, int salt_size, do { /* find the specified uindex in file */ p = fgets(line, sizeof(line) - 1, fp); } - while (p != NULL && (iindex = atoi(p)) != uindex); + while (p != NULL && atoi(p) != uindex); if (p == NULL) { fprintf(stderr, "Cannot find entry in %s\n", tpasswd_conf); -- cgit v1.2.1