From 704d5652b2eeb451fffbd1bb1129046e377c9cf3 Mon Sep 17 00:00:00 2001 From: Jiewen Yao Date: Tue, 20 Aug 2024 10:13:31 +0800 Subject: [PATCH] remove redundant retry count check found by coverity Signed-off-by: Jiewen Yao --- library/spdm_requester_lib/libspdm_req_challenge.c | 6 +++--- library/spdm_requester_lib/libspdm_req_end_session.c | 2 +- library/spdm_requester_lib/libspdm_req_finish.c | 2 +- library/spdm_requester_lib/libspdm_req_get_capabilities.c | 2 +- library/spdm_requester_lib/libspdm_req_get_certificate.c | 4 ++-- library/spdm_requester_lib/libspdm_req_get_csr.c | 4 ++-- library/spdm_requester_lib/libspdm_req_get_digests.c | 2 +- library/spdm_requester_lib/libspdm_req_get_event_types.c | 2 +- .../libspdm_req_get_measurement_extension_log.c | 2 +- library/spdm_requester_lib/libspdm_req_get_measurements.c | 6 +++--- library/spdm_requester_lib/libspdm_req_get_version.c | 2 +- library/spdm_requester_lib/libspdm_req_heartbeat.c | 2 +- library/spdm_requester_lib/libspdm_req_key_exchange.c | 4 ++-- library/spdm_requester_lib/libspdm_req_key_update.c | 2 +- .../spdm_requester_lib/libspdm_req_negotiate_algorithms.c | 2 +- library/spdm_requester_lib/libspdm_req_psk_exchange.c | 4 ++-- library/spdm_requester_lib/libspdm_req_psk_finish.c | 2 +- library/spdm_requester_lib/libspdm_req_set_certificate.c | 4 ++-- library/spdm_requester_lib/libspdm_req_vendor_request.c | 2 +- 19 files changed, 28 insertions(+), 28 deletions(-) diff --git a/library/spdm_requester_lib/libspdm_req_challenge.c b/library/spdm_requester_lib/libspdm_req_challenge.c index b1d7da08e5a..05ded03e1c9 100644 --- a/library/spdm_requester_lib/libspdm_req_challenge.c +++ b/library/spdm_requester_lib/libspdm_req_challenge.c @@ -420,7 +420,7 @@ libspdm_return_t libspdm_challenge(void *spdm_context, void *reserved, measurement_hash_type, measurement_hash, slot_mask, NULL, NULL, NULL, NULL, NULL); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -459,7 +459,7 @@ libspdm_return_t libspdm_challenge_ex(void *spdm_context, void *reserved, requester_nonce, responder_nonce, opaque_data, opaque_data_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -499,7 +499,7 @@ libspdm_return_t libspdm_challenge_ex2(void *spdm_context, void *reserved, requester_nonce, responder_nonce, opaque_data, opaque_data_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_end_session.c b/library/spdm_requester_lib/libspdm_req_end_session.c index 6e7fd82e9f8..b7fc75a243c 100644 --- a/library/spdm_requester_lib/libspdm_req_end_session.c +++ b/library/spdm_requester_lib/libspdm_req_end_session.c @@ -169,7 +169,7 @@ libspdm_return_t libspdm_send_receive_end_session(libspdm_context_t *spdm_contex do { status = libspdm_try_send_receive_end_session( spdm_context, session_id, end_session_attributes); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_finish.c b/library/spdm_requester_lib/libspdm_req_finish.c index f3cf371aba5..5856d86fbe9 100644 --- a/library/spdm_requester_lib/libspdm_req_finish.c +++ b/library/spdm_requester_lib/libspdm_req_finish.c @@ -627,7 +627,7 @@ libspdm_return_t libspdm_send_receive_finish(libspdm_context_t *spdm_context, do { status = libspdm_try_send_receive_finish(spdm_context, session_id, req_slot_id_param); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_capabilities.c b/library/spdm_requester_lib/libspdm_req_get_capabilities.c index 131a123a47d..8893e54ff6c 100644 --- a/library/spdm_requester_lib/libspdm_req_get_capabilities.c +++ b/library/spdm_requester_lib/libspdm_req_get_capabilities.c @@ -394,7 +394,7 @@ libspdm_return_t libspdm_get_capabilities(libspdm_context_t *spdm_context) retry_delay_time = spdm_context->retry_delay_time; do { status = libspdm_try_get_capabilities(spdm_context); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_certificate.c b/library/spdm_requester_lib/libspdm_req_get_certificate.c index d276411505f..1c267ccb8fa 100644 --- a/library/spdm_requester_lib/libspdm_req_get_certificate.c +++ b/library/spdm_requester_lib/libspdm_req_get_certificate.c @@ -458,7 +458,7 @@ libspdm_return_t libspdm_get_certificate_choose_length(void *spdm_context, do { status = libspdm_try_get_certificate(context, session_id, slot_id, length, cert_chain_size, cert_chain, NULL, NULL); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -490,7 +490,7 @@ libspdm_return_t libspdm_get_certificate_choose_length_ex(void *spdm_context, status = libspdm_try_get_certificate(context, session_id, slot_id, length, cert_chain_size, cert_chain, trust_anchor, trust_anchor_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_csr.c b/library/spdm_requester_lib/libspdm_req_get_csr.c index 718ae4c8ea1..aeee1d72df0 100644 --- a/library/spdm_requester_lib/libspdm_req_get_csr.c +++ b/library/spdm_requester_lib/libspdm_req_get_csr.c @@ -259,7 +259,7 @@ libspdm_return_t libspdm_get_csr(void * spdm_context, opaque_data, opaque_data_length, csr, csr_len, 0, 0, NULL); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -296,7 +296,7 @@ libspdm_return_t libspdm_get_csr_ex(void * spdm_context, csr, csr_len, request_attribute, key_pair_id, available_csr_tracking_tag); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_digests.c b/library/spdm_requester_lib/libspdm_req_get_digests.c index dc289f59941..ea9511a7cff 100644 --- a/library/spdm_requester_lib/libspdm_req_get_digests.c +++ b/library/spdm_requester_lib/libspdm_req_get_digests.c @@ -347,7 +347,7 @@ libspdm_return_t libspdm_get_digest(void *spdm_context, const uint32_t *session_ retry_delay_time = context->retry_delay_time; do { status = libspdm_try_get_digest(context, session_id, slot_mask, total_digest_buffer); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_event_types.c b/library/spdm_requester_lib/libspdm_req_get_event_types.c index 2b887dc2ac8..2b2a81d1639 100644 --- a/library/spdm_requester_lib/libspdm_req_get_event_types.c +++ b/library/spdm_requester_lib/libspdm_req_get_event_types.c @@ -168,7 +168,7 @@ libspdm_return_t libspdm_get_event_types(void *spdm_context, event_group_count, supported_event_groups_list_len, supported_event_groups_list); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_measurement_extension_log.c b/library/spdm_requester_lib/libspdm_req_get_measurement_extension_log.c index 86c3b5f4e6d..08aa71d1793 100644 --- a/library/spdm_requester_lib/libspdm_req_get_measurement_extension_log.c +++ b/library/spdm_requester_lib/libspdm_req_get_measurement_extension_log.c @@ -284,7 +284,7 @@ libspdm_return_t libspdm_get_measurement_extension_log_choose_length(void *spdm_ status = libspdm_try_get_measurement_extension_log(context, session_id, length, mel_size, measure_exten_log); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_measurements.c b/library/spdm_requester_lib/libspdm_req_get_measurements.c index e7e85f57f4d..93117d0c623 100644 --- a/library/spdm_requester_lib/libspdm_req_get_measurements.c +++ b/library/spdm_requester_lib/libspdm_req_get_measurements.c @@ -740,7 +740,7 @@ libspdm_return_t libspdm_get_measurement(void *spdm_context, const uint32_t *ses measurement_operation, slot_id_param, NULL, content_changed, number_of_blocks, measurement_record_length, measurement_record, NULL, NULL, NULL, NULL, NULL); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -781,7 +781,7 @@ libspdm_return_t libspdm_get_measurement_ex(void *spdm_context, const uint32_t * requester_nonce_in, requester_nonce, responder_nonce, opaque_data, opaque_data_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -824,7 +824,7 @@ libspdm_return_t libspdm_get_measurement_ex2(void *spdm_context, const uint32_t requester_nonce_in, requester_nonce, responder_nonce, opaque_data, opaque_data_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_get_version.c b/library/spdm_requester_lib/libspdm_req_get_version.c index be8a014bf95..00c177aa299 100644 --- a/library/spdm_requester_lib/libspdm_req_get_version.c +++ b/library/spdm_requester_lib/libspdm_req_get_version.c @@ -224,7 +224,7 @@ libspdm_return_t libspdm_get_version(libspdm_context_t *spdm_context, do { status = libspdm_try_get_version(spdm_context, version_number_entry_count, version_number_entry); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_heartbeat.c b/library/spdm_requester_lib/libspdm_req_heartbeat.c index 2844006b55c..68fe888c41b 100644 --- a/library/spdm_requester_lib/libspdm_req_heartbeat.c +++ b/library/spdm_requester_lib/libspdm_req_heartbeat.c @@ -159,7 +159,7 @@ libspdm_return_t libspdm_heartbeat(void *spdm_context, uint32_t session_id) retry_delay_time = context->retry_delay_time; do { status = libspdm_try_heartbeat(context, session_id); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_key_exchange.c b/library/spdm_requester_lib/libspdm_req_key_exchange.c index 95bfc637fe6..d5ec36bed7c 100644 --- a/library/spdm_requester_lib/libspdm_req_key_exchange.c +++ b/library/spdm_requester_lib/libspdm_req_key_exchange.c @@ -835,7 +835,7 @@ libspdm_return_t libspdm_send_receive_key_exchange( session_id, heartbeat_period, req_slot_id_param, measurement_hash, NULL, NULL, NULL, NULL, 0, NULL, NULL); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -872,7 +872,7 @@ libspdm_return_t libspdm_send_receive_key_exchange_ex( requester_random, responder_random, requester_opaque_data, requester_opaque_data_size, responder_opaque_data, responder_opaque_data_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_key_update.c b/library/spdm_requester_lib/libspdm_req_key_update.c index 48f35bb6e78..c060054e012 100644 --- a/library/spdm_requester_lib/libspdm_req_key_update.c +++ b/library/spdm_requester_lib/libspdm_req_key_update.c @@ -340,7 +340,7 @@ libspdm_return_t libspdm_key_update(void *spdm_context, uint32_t session_id, do { status = libspdm_try_key_update(spdm_context, session_id, single_direction, &key_updated); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_negotiate_algorithms.c b/library/spdm_requester_lib/libspdm_req_negotiate_algorithms.c index 5a8ab9c0ba0..6a8fcc8d252 100644 --- a/library/spdm_requester_lib/libspdm_req_negotiate_algorithms.c +++ b/library/spdm_requester_lib/libspdm_req_negotiate_algorithms.c @@ -655,7 +655,7 @@ libspdm_return_t libspdm_negotiate_algorithms(libspdm_context_t *spdm_context) retry_delay_time = spdm_context->retry_delay_time; do { status = libspdm_try_negotiate_algorithms(spdm_context); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_psk_exchange.c b/library/spdm_requester_lib/libspdm_req_psk_exchange.c index 83038cce1f8..7c4cd5565f8 100644 --- a/library/spdm_requester_lib/libspdm_req_psk_exchange.c +++ b/library/spdm_requester_lib/libspdm_req_psk_exchange.c @@ -590,7 +590,7 @@ libspdm_return_t libspdm_send_receive_psk_exchange(libspdm_context_t *spdm_conte measurement_hash_type, session_policy, session_id, heartbeat_period, measurement_hash, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -636,7 +636,7 @@ libspdm_return_t libspdm_send_receive_psk_exchange_ex(libspdm_context_t *spdm_co responder_context, responder_context_size, requester_opaque_data, requester_opaque_data_size, responder_opaque_data, responder_opaque_data_size); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_psk_finish.c b/library/spdm_requester_lib/libspdm_req_psk_finish.c index 4204df7d987..f22f9d8873a 100644 --- a/library/spdm_requester_lib/libspdm_req_psk_finish.c +++ b/library/spdm_requester_lib/libspdm_req_psk_finish.c @@ -302,7 +302,7 @@ libspdm_return_t libspdm_send_receive_psk_finish(libspdm_context_t *spdm_context do { status = libspdm_try_send_receive_psk_finish(spdm_context, session_id); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_set_certificate.c b/library/spdm_requester_lib/libspdm_req_set_certificate.c index ddee01f425e..2dbfa7cb809 100644 --- a/library/spdm_requester_lib/libspdm_req_set_certificate.c +++ b/library/spdm_requester_lib/libspdm_req_set_certificate.c @@ -234,7 +234,7 @@ libspdm_return_t libspdm_set_certificate(void *spdm_context, do { status = libspdm_try_set_certificate(context, session_id, slot_id, cert_chain, cert_chain_size, 0, 0); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } @@ -263,7 +263,7 @@ libspdm_return_t libspdm_set_certificate_ex(void *spdm_context, status = libspdm_try_set_certificate(context, session_id, slot_id, cert_chain, cert_chain_size, request_attribute, key_pair_id); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; } diff --git a/library/spdm_requester_lib/libspdm_req_vendor_request.c b/library/spdm_requester_lib/libspdm_req_vendor_request.c index e9df4d21ab4..d92c8e1e9c8 100644 --- a/library/spdm_requester_lib/libspdm_req_vendor_request.c +++ b/library/spdm_requester_lib/libspdm_req_vendor_request.c @@ -259,7 +259,7 @@ libspdm_return_t libspdm_vendor_send_request_receive_response( resp_vendor_id, resp_size, resp_data); - if ((status != LIBSPDM_STATUS_BUSY_PEER) || (retry == 0)) { + if (status != LIBSPDM_STATUS_BUSY_PEER) { return status; }