Skip to content

Commit e21fe8f

Browse files
pm215philmd
authored andcommitted
hw/net/smc91c111: Use MAX_PACKET_SIZE instead of magic numbers
Now we have a constant for the maximum packet size, we can use it to replace various hardcoded 2048 values. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent aad6f26 commit e21fe8f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hw/net/smc91c111.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct smc91c111_state {
5858
int tx_fifo_done_len;
5959
int tx_fifo_done[NUM_PACKETS];
6060
/* Packet buffer memory. */
61-
uint8_t data[NUM_PACKETS][2048];
61+
uint8_t data[NUM_PACKETS][MAX_PACKET_SIZE];
6262
uint8_t int_level;
6363
uint8_t int_mask;
6464
MemoryRegion mmio;
@@ -86,7 +86,8 @@ static const VMStateDescription vmstate_smc91c111 = {
8686
VMSTATE_INT32_ARRAY(rx_fifo, smc91c111_state, NUM_PACKETS),
8787
VMSTATE_INT32(tx_fifo_done_len, smc91c111_state),
8888
VMSTATE_INT32_ARRAY(tx_fifo_done, smc91c111_state, NUM_PACKETS),
89-
VMSTATE_BUFFER_UNSAFE(data, smc91c111_state, 0, NUM_PACKETS * 2048),
89+
VMSTATE_BUFFER_UNSAFE(data, smc91c111_state, 0,
90+
NUM_PACKETS * MAX_PACKET_SIZE),
9091
VMSTATE_UINT8(int_level, smc91c111_state),
9192
VMSTATE_UINT8(int_mask, smc91c111_state),
9293
VMSTATE_END_OF_LIST()
@@ -773,8 +774,9 @@ static ssize_t smc91c111_receive(NetClientState *nc, const uint8_t *buf, size_t
773774
if (crc)
774775
packetsize += 4;
775776
/* TODO: Flag overrun and receive errors. */
776-
if (packetsize > 2048)
777+
if (packetsize > MAX_PACKET_SIZE) {
777778
return -1;
779+
}
778780
packetnum = smc91c111_allocate_packet(s);
779781
if (packetnum == 0x80)
780782
return -1;

0 commit comments

Comments
 (0)