hw/net/npcm_gmac.c: Drop 'buf' local variable
We use the local variable 'buf' only when we call dma_memory_read(), and it is always set to &tx_send_buffer[prev_buf_size] immediately before both of those calls. So remove the variable and pass tx_send_buffer + prev_buf_size to dma_memory_read(). This fixes in passing a place where we set buf = tx_send_buffer but never used that value because we always updated buf to something else later before using it. Coverity: CID 1534027 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
e96a1aa676
commit
a6d6e37901
1 changed files with 4 additions and 8 deletions
|
|
@ -516,7 +516,6 @@ static void gmac_try_send_next_packet(NPCMGMACState *gmac)
|
|||
uint32_t desc_addr;
|
||||
struct NPCMGMACTxDesc tx_desc;
|
||||
uint32_t tx_buf_addr, tx_buf_len;
|
||||
uint8_t *buf = tx_send_buffer;
|
||||
uint32_t prev_buf_size = 0;
|
||||
int csum = 0;
|
||||
|
||||
|
|
@ -567,16 +566,15 @@ static void gmac_try_send_next_packet(NPCMGMACState *gmac)
|
|||
tx_buf_addr = tx_desc.tdes2;
|
||||
gmac->regs[R_NPCM_DMA_CUR_TX_BUF_ADDR] = tx_buf_addr;
|
||||
tx_buf_len = TX_DESC_TDES1_BFFR1_SZ_MASK(tx_desc.tdes1);
|
||||
buf = &tx_send_buffer[prev_buf_size];
|
||||
|
||||
if ((prev_buf_size + tx_buf_len) > tx_buffer_size) {
|
||||
tx_buffer_size = prev_buf_size + tx_buf_len;
|
||||
tx_send_buffer = g_realloc(tx_send_buffer, tx_buffer_size);
|
||||
buf = &tx_send_buffer[prev_buf_size];
|
||||
}
|
||||
|
||||
/* step 5 */
|
||||
if (dma_memory_read(&address_space_memory, tx_buf_addr, buf,
|
||||
if (dma_memory_read(&address_space_memory, tx_buf_addr,
|
||||
tx_send_buffer + prev_buf_size,
|
||||
tx_buf_len, MEMTXATTRS_UNSPECIFIED)) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read packet @ 0x%x\n",
|
||||
__func__, tx_buf_addr);
|
||||
|
|
@ -589,15 +587,14 @@ static void gmac_try_send_next_packet(NPCMGMACState *gmac)
|
|||
tx_buf_addr = tx_desc.tdes3;
|
||||
gmac->regs[R_NPCM_DMA_CUR_TX_BUF_ADDR] = tx_buf_addr;
|
||||
tx_buf_len = TX_DESC_TDES1_BFFR2_SZ_MASK(tx_desc.tdes1);
|
||||
buf = &tx_send_buffer[prev_buf_size];
|
||||
|
||||
if ((prev_buf_size + tx_buf_len) > tx_buffer_size) {
|
||||
tx_buffer_size = prev_buf_size + tx_buf_len;
|
||||
tx_send_buffer = g_realloc(tx_send_buffer, tx_buffer_size);
|
||||
buf = &tx_send_buffer[prev_buf_size];
|
||||
}
|
||||
|
||||
if (dma_memory_read(&address_space_memory, tx_buf_addr, buf,
|
||||
if (dma_memory_read(&address_space_memory, tx_buf_addr,
|
||||
tx_send_buffer + prev_buf_size,
|
||||
tx_buf_len, MEMTXATTRS_UNSPECIFIED)) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: Failed to read packet @ 0x%x\n",
|
||||
|
|
@ -615,7 +612,6 @@ static void gmac_try_send_next_packet(NPCMGMACState *gmac)
|
|||
net_checksum_calculate(tx_send_buffer, length, csum);
|
||||
qemu_send_packet(qemu_get_queue(gmac->nic), tx_send_buffer, length);
|
||||
trace_npcm_gmac_packet_sent(DEVICE(gmac)->canonical_path, length);
|
||||
buf = tx_send_buffer;
|
||||
prev_buf_size = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue