Fixed Defects reported by Coverity Scan

This commit is contained in:
Sukchan Lee 2022-08-13 23:49:55 +09:00
parent dbb52592d8
commit c835556623
4 changed files with 17 additions and 15 deletions

View File

@ -196,8 +196,8 @@ static ogs_inline ogs_uint24_t ogs_htobe24(ogs_uint24_t x)
__switch_p__; \
__switch_p__ = 0, __switch_next__ = 1) { {
#define CASE(X) } if (!__switch_next__ || \
!(__switch_next__ = \
strcmp(__switch_p__, X))) {
(__switch_next__ = \
strcmp(__switch_p__, X)) == 0) {
#define DEFAULT } {
#define END }}}
#endif

View File

@ -693,12 +693,7 @@ int ogs_sbi_context_parse_config(
ogs_yaml_iter_key(&discovery_iter);
ogs_assert(discovery_key);
if (!strcmp(discovery_key, "delegated")) {
yaml_node_t *discovery_node =
yaml_document_get_node(document,
discovery_iter.pair->value);
ogs_assert(discovery_node->type ==
YAML_SCALAR_NODE);
const char* delegated =
const char *delegated =
ogs_yaml_iter_value(&discovery_iter);
if (!strcmp(delegated, "auto"))
self.discovery_config.delegated =
@ -713,8 +708,7 @@ int ogs_sbi_context_parse_config(
ogs_warn("unknown 'delegated' value `%s`",
delegated);
} else
ogs_warn("unknown key `%s`",
discovery_key);
ogs_warn("unknown key `%s`", discovery_key);
}
}
}
@ -732,7 +726,8 @@ void ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_e nf_type)
ogs_assert(nf_type);
if (self.num_of_to_be_notified_nf_type < OGS_SBI_MAX_NUM_OF_NF_TYPE) {
self.to_be_notified_nf_type[self.num_of_to_be_notified_nf_type] = nf_type;
self.to_be_notified_nf_type[self.num_of_to_be_notified_nf_type] =
nf_type;
self.num_of_to_be_notified_nf_type++;
}
}

View File

@ -722,7 +722,7 @@ int ogs_sbi_parse_header(ogs_sbi_message_t *message, ogs_sbi_header_t *header)
ogs_assert(message);
ogs_assert(header);
memset(message, 0, sizeof(*message));
memset(message, 0, sizeof(ogs_sbi_message_t));
message->h.method = header->method;
message->h.uri = header->uri;

View File

@ -371,7 +371,12 @@ static bool server_send_rspmem_persistent(
hi; hi = ogs_hash_next(hi)) {
const char *key = ogs_hash_this_key(hi);
char *val = ogs_hash_this_val(hi);
MHD_add_response_header(mhd_response, key, val);
ret = MHD_add_response_header(mhd_response, key, val);
if (ret != MHD_YES) {
ogs_error("MHD_add_response_header failed [%d]", ret);
MHD_destroy_response(mhd_response);
return false;
}
}
status = response->status;
@ -386,7 +391,9 @@ static bool server_send_rspmem_persistent(
ret = MHD_queue_response(connection, status, mhd_response);
if (ret != MHD_YES) {
ogs_error("MHD_queue_response_error [%d]", ret);
ogs_error("MHD_queue_response failed [%d]", ret);
MHD_destroy_response(mhd_response);
ogs_pollset_remove(request->poll.write);
return false;
}
MHD_destroy_response(mhd_response);
@ -562,7 +569,7 @@ suspend:
ogs_assert(server->cb);
if (server->cb(request, sbi_sess) != OGS_OK) {
ogs_error("server callback error");
ogs_warn("server callback error");
ogs_assert(true ==
ogs_sbi_server_send_error((ogs_sbi_stream_t *)sbi_sess,
OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,