net/rocker: Remove the dead error handling

Memory allocation functions like world_alloc, desc_ring_alloc etc,
they are all wrappers around g_malloc, g_new etc. But g_malloc and
similar functions doesn't return null. Because they ignore the fact
that g_malloc() of 0 bytes returns null. So error checks for these
allocation failure are superfluous. Now, remove them entirely.

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
Mao Zhongyi 2017-08-14 11:33:07 +08:00 committed by Jason Wang
parent 6ce310b535
commit 107e4b352c
5 changed files with 6 additions and 87 deletions

View file

@ -368,9 +368,6 @@ static OfDpaFlow *of_dpa_flow_alloc(uint64_t cookie)
int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) / 1000;
flow = g_new0(OfDpaFlow, 1);
if (!flow) {
return NULL;
}
flow->cookie = cookie;
flow->mask.tbl_id = 0xffffffff;
@ -813,10 +810,6 @@ static OfDpaGroup *of_dpa_group_alloc(uint32_t id)
{
OfDpaGroup *group = g_new0(OfDpaGroup, 1);
if (!group) {
return NULL;
}
group->id = id;
return group;
@ -1867,9 +1860,6 @@ static int of_dpa_cmd_flow_add(OfDpa *of_dpa, uint64_t cookie,
}
flow = of_dpa_flow_alloc(cookie);
if (!flow) {
return -ROCKER_ENOMEM;
}
err = of_dpa_cmd_flow_add_mod(of_dpa, flow, flow_tlvs);
if (err) {
@ -2040,17 +2030,10 @@ static int of_dpa_cmd_add_l2_flood(OfDpa *of_dpa, OfDpaGroup *group,
rocker_tlv_get_le16(group_tlvs[ROCKER_TLV_OF_DPA_GROUP_COUNT]);
tlvs = g_new0(RockerTlv *, group->l2_flood.group_count + 1);
if (!tlvs) {
return -ROCKER_ENOMEM;
}
g_free(group->l2_flood.group_ids);
group->l2_flood.group_ids =
g_new0(uint32_t, group->l2_flood.group_count);
if (!group->l2_flood.group_ids) {
err = -ROCKER_ENOMEM;
goto err_out;
}
rocker_tlv_parse_nested(tlvs, group->l2_flood.group_count,
group_tlvs[ROCKER_TLV_OF_DPA_GROUP_IDS]);
@ -2157,9 +2140,6 @@ static int of_dpa_cmd_group_add(OfDpa *of_dpa, uint32_t group_id,
}
group = of_dpa_group_alloc(group_id);
if (!group) {
return -ROCKER_ENOMEM;
}
err = of_dpa_cmd_group_do(of_dpa, group_id, group, group_tlvs);
if (err) {