aboutsummaryrefslogtreecommitdiff
path: root/hw/net/rocker/rocker.c
diff options
context:
space:
mode:
authorMao Zhongyi <maozy.fnst@cn.fujitsu.com>2017-08-14 11:33:07 +0800
committerJason Wang <jasowang@redhat.com>2017-09-08 08:17:37 +0800
commit107e4b352cc309f9bd7588ef1a44549200620078 (patch)
tree50a7dc360ddd299a00f4a694bd56b9c27792e81e /hw/net/rocker/rocker.c
parent6ce310b5356abb7edc3aa8b8b097d0b8cc76f83f (diff)
downloadqemu-107e4b352cc309f9bd7588ef1a44549200620078.zip
qemu-107e4b352cc309f9bd7588ef1a44549200620078.tar.gz
qemu-107e4b352cc309f9bd7588ef1a44549200620078.tar.bz2
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>
Diffstat (limited to 'hw/net/rocker/rocker.c')
-rw-r--r--hw/net/rocker/rocker.c47
1 files changed, 1 insertions, 46 deletions
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 4f0f6d7..7496752 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -239,10 +239,6 @@ static int tx_consume(Rocker *r, DescInfo *info)
}
iov[iovcnt].iov_len = frag_len;
iov[iovcnt].iov_base = g_malloc(frag_len);
- if (!iov[iovcnt].iov_base) {
- err = -ROCKER_ENOMEM;
- goto err_no_mem;
- }
pci_dma_read(dev, frag_addr, iov[iovcnt].iov_base,
iov[iovcnt].iov_len);
@@ -259,7 +255,6 @@ static int tx_consume(Rocker *r, DescInfo *info)
err = fp_port_eg(r->fp_port[port], iov, iovcnt);
err_too_many_frags:
-err_no_mem:
err_bad_attr:
for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
g_free(iov[i].iov_base);
@@ -671,10 +666,7 @@ int rx_produce(World *world, uint32_t pport,
*/
data = g_malloc(data_size);
- if (!data) {
- err = -ROCKER_ENOMEM;
- goto out;
- }
+
iov_to_buf(iov, iovcnt, 0, data, data_size);
pci_dma_write(dev, frag_addr, data, data_size);
g_free(data);
@@ -719,11 +711,6 @@ static void rocker_test_dma_ctrl(Rocker *r, uint32_t val)
buf = g_malloc(r->test_dma_size);
- if (!buf) {
- DPRINTF("test dma buffer alloc failed");
- return;
- }
-
switch (val) {
case ROCKER_TEST_DMA_CTRL_CLEAR:
memset(buf, 0, r->test_dma_size);
@@ -1310,13 +1297,6 @@ static int pci_rocker_init(PCIDevice *dev)
r->worlds[ROCKER_WORLD_TYPE_OF_DPA] = of_dpa_world_alloc(r);
- for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
- if (!r->worlds[i]) {
- err = -ENOMEM;
- goto err_world_alloc;
- }
- }
-
if (!r->world_name) {
r->world_name = g_strdup(world_name(r->worlds[ROCKER_WORLD_TYPE_OF_DPA]));
}
@@ -1393,9 +1373,6 @@ static int pci_rocker_init(PCIDevice *dev)
}
r->rings = g_new(DescRing *, rocker_pci_ring_count(r));
- if (!r->rings) {
- goto err_rings_alloc;
- }
/* Rings are ordered like this:
* - command ring
@@ -1407,14 +1384,9 @@ static int pci_rocker_init(PCIDevice *dev)
* .....
*/
- err = -ENOMEM;
for (i = 0; i < rocker_pci_ring_count(r); i++) {
DescRing *ring = desc_ring_alloc(r, i);
- if (!ring) {
- goto err_ring_alloc;
- }
-
if (i == ROCKER_RING_CMD) {
desc_ring_set_consume(ring, cmd_consume, ROCKER_MSIX_VEC_CMD);
} else if (i == ROCKER_RING_EVENT) {
@@ -1434,10 +1406,6 @@ static int pci_rocker_init(PCIDevice *dev)
fp_port_alloc(r, r->name, &r->fp_start_macaddr,
i, &r->fp_ports_peers[i]);
- if (!port) {
- goto err_port_alloc;
- }
-
r->fp_port[i] = port;
fp_port_set_world(port, r->world_dflt);
}
@@ -1446,25 +1414,12 @@ static int pci_rocker_init(PCIDevice *dev)
return 0;
-err_port_alloc:
- for (--i; i >= 0; i--) {
- FpPort *port = r->fp_port[i];
- fp_port_free(port);
- }
- i = rocker_pci_ring_count(r);
-err_ring_alloc:
- for (--i; i >= 0; i--) {
- desc_ring_free(r->rings[i]);
- }
- g_free(r->rings);
-err_rings_alloc:
err_duplicate:
rocker_msix_uninit(r);
err_msix_init:
object_unparent(OBJECT(&r->msix_bar));
object_unparent(OBJECT(&r->mmio));
err_world_type_by_name:
-err_world_alloc:
for (i = 0; i < ROCKER_WORLD_TYPE_MAX; i++) {
if (r->worlds[i]) {
world_free(r->worlds[i]);