rtl8139: do not assume TxStatus[] and TxAddr[] are adjacent
commit3e48dd4a2d48aabafe22ce3611d65544d0234a69
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Wed, 11 Apr 2012 11:01:44 +0000 (11 12:01 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 11 Apr 2012 17:30:01 +0000 (11 12:30 -0500)
tree39ec6d5fcdea3a437c8b8ebf18c4d558980c5282
parentc1958aea51a14199d05d392edce932a956e1674d
rtl8139: do not assume TxStatus[] and TxAddr[] are adjacent

Commit afe0a595356192d5f79703cf6462fcc112df007c ("rtl8139: support byte
read to TxStatus registers") reused rtl8139_TxStatus_read() for reading
TxAddr registers.  It relies on the fact that TxStatus[] and TxAddr[]
are adjacent.

This causes a gcc warning because the compiler can detect that array
access is out-of-bounds:

  hw/rtl8139.c:2501:27: error: array subscript is above array bounds [-Werror=array-bounds]

This patch refactors the function so that we don't rely on out-of-bounds
accesses.

Cc: Jason Wang <jasonwang@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/rtl8139.c