Skip to content

Commit a35732f

Browse files
committed
Removed the null check
Signed-off-by: Rashmi <[email protected]>
1 parent 0f7be0e commit a35732f

File tree

5 files changed

+0
-92
lines changed

5 files changed

+0
-92
lines changed

lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,13 @@ void delete_pending_procedures(
5555
pgw_ni_cbr_proc_t* pgw_create_procedure_create_bearer(
5656
sgw_eps_bearer_context_information_t* ctx_p) {
5757
pgw_ni_cbr_proc_t* s11_proc_create_bearer = new pgw_ni_cbr_proc_t();
58-
if (!s11_proc_create_bearer) {
59-
OAILOG_ERROR(LOG_SPGW_APP,
60-
"Failed to allocate memory for structure, pgw_ni_cbr_proc_t");
61-
return nullptr;
62-
}
6358
s11_proc_create_bearer->proc.type =
6459
PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST;
6560
pgw_base_proc_t* base_proc = (pgw_base_proc_t*)s11_proc_create_bearer;
6661

6762
if (!ctx_p->pending_procedures) {
6863
ctx_p->pending_procedures =
6964
new sgw_eps_bearer_context_information_s::pending_procedures_s();
70-
if (!ctx_p->pending_procedures) {
71-
OAILOG_ERROR(LOG_SPGW_APP,
72-
"Failed to allocate memory for pending_procedures");
73-
free_cpp_wrapper(reinterpret_cast<void**>(&s11_proc_create_bearer));
74-
return nullptr;
75-
}
76-
if (!(ctx_p->pending_procedures)) {
77-
return nullptr;
78-
}
7965
LIST_INIT(ctx_p->pending_procedures);
8066
}
8167
LIST_INSERT_HEAD((ctx_p->pending_procedures), base_proc, entries);

lte/gateway/c/core/oai/tasks/sgw/sgw_context_manager.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ mme_sgw_tunnel_t* sgw_cm_create_s11_tunnel(teid_t remote_teid,
119119
mme_sgw_tunnel_t* new_tunnel = nullptr;
120120

121121
new_tunnel = new mme_sgw_tunnel_t();
122-
if (new_tunnel == nullptr) {
123-
// failed to allocate memory, may be ENOMEM error
124-
OAILOG_ERROR(LOG_SPGW_APP,
125-
"Failed to create tunnel for remote_teid " TEID_FMT "\n",
126-
remote_teid);
127-
return nullptr;
128-
}
129-
130122
new_tunnel->remote_teid = remote_teid;
131123
new_tunnel->local_teid = local_teid;
132124

@@ -141,16 +133,6 @@ sgw_cm_create_bearer_context_information_in_collection(teid_t teid) {
141133
new_bearer_context_information =
142134
new s_plus_p_gw_eps_bearer_context_information_t();
143135

144-
if (new_bearer_context_information == nullptr) {
145-
// Memory allocation failed, may be ENOMEM error
146-
OAILOG_ERROR(
147-
LOG_SPGW_APP,
148-
"Failed to create new bearer context information object for S11 "
149-
"remote_teid " TEID_FMT "\n",
150-
teid);
151-
return nullptr;
152-
}
153-
154136
/*
155137
* Trying to insert the new tunnel into the map.
156138
* * * * If collision_p is not NULL (0), it means tunnel is already present.
@@ -228,16 +210,6 @@ sgw_eps_bearer_ctxt_t* sgw_cm_create_eps_bearer_ctxt_in_collection(
228210
->sgw_eps_bearers_array[EBI_TO_INDEX(eps_bearer_idP)]) {
229211
new_eps_bearer_entry = new sgw_eps_bearer_ctxt_t();
230212

231-
if (new_eps_bearer_entry == nullptr) {
232-
/*
233-
* Malloc failed, may be ENOMEM error
234-
*/
235-
OAILOG_ERROR(LOG_SPGW_APP,
236-
"Failed to create EPS bearer entry for EPS bearer id %u \n",
237-
eps_bearer_idP);
238-
return nullptr;
239-
}
240-
241213
new_eps_bearer_entry->eps_bearer_id = eps_bearer_idP;
242214
sgw_pdn_connection->sgw_eps_bearers_array[EBI_TO_INDEX(eps_bearer_idP)] =
243215
new_eps_bearer_entry;

lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,6 @@ void SpgwStateConverter::insert_proc_into_sgw_pending_procedures(
937937
sgw_eps_bearer_context_information_t::pending_procedures_s*
938938
pending_procedures) {
939939
pgw_ni_cbr_proc_t* s11_proc_create_bearer = new pgw_ni_cbr_proc_t();
940-
if (!s11_proc_create_bearer) {
941-
OAILOG_ERROR(LOG_SPGW_APP,
942-
"Failed to allocate memory for structure, pgw_ni_cbr_proc_t");
943-
OAILOG_FUNC_OUT(LOG_SPGW_APP);
944-
}
945940
s11_proc_create_bearer->teid = proto.teid();
946941
s11_proc_create_bearer->sdf_id = (sdf_id_t)proto.sdf_id();
947942
pgw_base_proc_t* base_proc = (pgw_base_proc_t*)s11_proc_create_bearer;
@@ -950,42 +945,18 @@ void SpgwStateConverter::insert_proc_into_sgw_pending_procedures(
950945

951946
s11_proc_create_bearer->pending_eps_bearers =
952947
new pgw_ni_cbr_proc_s::pending_eps_bearers_s();
953-
if (!(s11_proc_create_bearer->pending_eps_bearers)) {
954-
OAILOG_ERROR(LOG_SPGW_APP,
955-
"Failed to allocate memory for pending_eps_bearers ");
956-
delete s11_proc_create_bearer;
957-
OAILOG_FUNC_OUT(LOG_SPGW_APP);
958-
}
959-
960948
LIST_INIT(s11_proc_create_bearer->pending_eps_bearers);
961-
bool failed_to_allocate = false;
962949
for (auto& eps_bearer_proto : proto.pending_eps_bearers()) {
963950
sgw_eps_bearer_ctxt_t* eps_bearer = new sgw_eps_bearer_ctxt_t();
964-
if (!eps_bearer) {
965-
OAILOG_ERROR(LOG_SPGW_APP, "Failed to allocate memory for eps_bearer");
966-
failed_to_allocate = true;
967-
break;
968-
}
969951

970952
proto_to_sgw_eps_bearer(eps_bearer_proto, eps_bearer);
971953

972954
sgw_eps_bearer_entry_wrapper_t* sgw_eps_bearer_entry_wrapper =
973955
new sgw_eps_bearer_entry_wrapper_t();
974-
if (!sgw_eps_bearer_entry_wrapper) {
975-
OAILOG_ERROR(
976-
LOG_SPGW_APP,
977-
"Failed to allocate memory for sgw_eps_bearer_entry_wrapper");
978-
failed_to_allocate = true;
979-
break;
980-
}
981956
sgw_eps_bearer_entry_wrapper->sgw_eps_bearer_entry = eps_bearer;
982957
LIST_INSERT_HEAD((s11_proc_create_bearer->pending_eps_bearers),
983958
sgw_eps_bearer_entry_wrapper, entries);
984959
}
985-
if (failed_to_allocate) {
986-
pgw_free_procedure_create_bearer(
987-
(pgw_ni_cbr_proc_t**)&s11_proc_create_bearer);
988-
}
989960
}
990961

991962
void SpgwStateConverter::ue_to_proto(const spgw_ue_context_t* ue_state,
@@ -1043,11 +1014,6 @@ void SpgwStateConverter::proto_to_ue(const oai::SpgwUeContext& ue_proto,
10431014
oai::S11BearerContext S11BearerContext = ue_proto.s11_bearer_context(idx);
10441015
s_plus_p_gw_eps_bearer_context_information_t* spgw_context_p =
10451016
new s_plus_p_gw_eps_bearer_context_information_t();
1046-
if (!spgw_context_p) {
1047-
OAILOG_ERROR(LOG_SPGW_APP,
1048-
"Failed to allocate memory for SPGW context \n");
1049-
OAILOG_FUNC_OUT(LOG_SPGW_APP);
1050-
}
10511017

10521018
proto_to_spgw_bearer_context(S11BearerContext, spgw_context_p);
10531019
if ((state_teid_map->insert(

lte/gateway/c/core/oai/tasks/sgw/spgw_state_manager.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,10 @@ void SpgwStateManager::create_state() {
5151

5252
state_teid_map.map = new google::protobuf::Map<
5353
uint32_t, struct s_plus_p_gw_eps_bearer_context_information_s*>();
54-
if (!(state_teid_map.map)) {
55-
OAILOG_ERROR(LOG_S1AP, "Failed to allocate memory for state_teid_map ");
56-
return;
57-
}
5854
state_teid_map.set_name(S11_BEARER_CONTEXT_INFO_HT_NAME);
5955
state_teid_map.bind_callback(spgw_free_s11_bearer_context_information);
6056

6157
state_ue_map.map = new google::protobuf::Map<uint64_t, spgw_ue_context_s*>();
62-
if (!(state_ue_map.map)) {
63-
OAILOG_ERROR(LOG_S1AP, "Failed to allocate memory for state_ue_map ");
64-
return;
65-
}
6658
state_ue_map.set_name(SPGW_STATE_UE_MAP);
6759
state_ue_map.bind_callback(sgw_free_ue_context);
6860

@@ -115,10 +107,6 @@ status_code_e SpgwStateManager::read_ue_state_from_db() {
115107
}
116108
OAILOG_DEBUG(log_task, "Reading UE state from db for key %s", key.c_str());
117109
spgw_ue_context_t* ue_context_p = new spgw_ue_context_t();
118-
if (!ue_context_p) {
119-
OAILOG_ERROR(log_task, "Failed to allocate memory for ue_context_p");
120-
return RETURNok;
121-
}
122110
SpgwStateConverter::proto_to_ue(ue_proto, ue_context_p);
123111
}
124112
return RETURNok;

lte/gateway/c/core/oai/test/spgw_task/mock_spgw_op.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ status_code_e mock_read_spgw_ue_state_db(
5656
}
5757

5858
spgw_ue_context_t* ue_context_p = new spgw_ue_context_t();
59-
if (!ue_context_p) {
60-
std::cerr << "Failed to allocate memory for ue_context_p" << std::endl;
61-
OAILOG_FUNC_RETURN(LOG_SGW_S8, RETURNerror);
62-
}
6359
SpgwStateConverter::proto_to_ue(ue_proto, ue_context_p);
6460
}
6561
return RETURNok;

0 commit comments

Comments
 (0)