Re: [Qemu-devel] [PATCH v2] net: pcnet: fix source formatting and indentation

2016-10-19 Thread Jason Wang



On 2016年09月30日 14:49, P J P wrote:

From: Prasad J Pandit

Fix indentations and source format at few places. Add braces
around 'if' and 'while' statements.

Signed-off-by: Prasad J Pandit
---
  hw/net/pcnet.c | 130 +
  1 file changed, 67 insertions(+), 63 deletions(-)

Update per:
   ->https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg07944.html


Applied, thanks.



[Qemu-devel] [PATCH v2] net: pcnet: fix source formatting and indentation

2016-09-29 Thread P J P
From: Prasad J Pandit 

Fix indentations and source format at few places. Add braces
around 'if' and 'while' statements.

Signed-off-by: Prasad J Pandit 
---
 hw/net/pcnet.c | 130 +
 1 file changed, 67 insertions(+), 63 deletions(-)

Update per:
  -> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg07944.html

diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 3078de8..6544553 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -302,7 +302,7 @@ static inline void pcnet_tmd_load(PCNetState *s, struct 
pcnet_TMD *tmd,
 uint32_t tbadr;
 int16_t length;
 int16_t status;
-   } xda;
+} xda;
 s->phys_mem_read(s->dma_opaque, addr, (void *)&xda, sizeof(xda), 0);
 tmd->tbadr = le32_to_cpu(xda.tbadr) & 0xff;
 tmd->length = le16_to_cpu(xda.length);
@@ -664,7 +664,9 @@ static inline int ladr_match(PCNetState *s, const uint8_t 
*buf, int size)
 
 static inline hwaddr pcnet_rdra_addr(PCNetState *s, int idx)
 {
-while (idx < 1) idx += CSR_RCVRL(s);
+while (idx < 1) {
+idx += CSR_RCVRL(s);
+}
 return s->rdra + ((CSR_RCVRL(s) - idx) * (BCR_SWSTYLE(s) ? 16 : 8));
 }
 
@@ -672,8 +674,10 @@ static inline int64_t pcnet_get_next_poll_time(PCNetState 
*s, int64_t current_ti
 {
 int64_t next_time = current_time +
 (65536 - (CSR_SPND(s) ? 0 : CSR_POLL(s))) * 30;
-if (next_time <= current_time)
+
+if (next_time <= current_time) {
 next_time = current_time + 1;
+}
 return next_time;
 }
 
@@ -795,13 +799,13 @@ static void pcnet_init(PCNetState *s)
 mode = le16_to_cpu(initblk.mode);
 rlen = initblk.rlen >> 4;
 tlen = initblk.tlen >> 4;
-   ladrf[0] = le16_to_cpu(initblk.ladrf[0]);
-   ladrf[1] = le16_to_cpu(initblk.ladrf[1]);
-   ladrf[2] = le16_to_cpu(initblk.ladrf[2]);
-   ladrf[3] = le16_to_cpu(initblk.ladrf[3]);
-   padr[0] = le16_to_cpu(initblk.padr[0]);
-   padr[1] = le16_to_cpu(initblk.padr[1]);
-   padr[2] = le16_to_cpu(initblk.padr[2]);
+ladrf[0] = le16_to_cpu(initblk.ladrf[0]);
+ladrf[1] = le16_to_cpu(initblk.ladrf[1]);
+ladrf[2] = le16_to_cpu(initblk.ladrf[2]);
+ladrf[3] = le16_to_cpu(initblk.ladrf[3]);
+padr[0] = le16_to_cpu(initblk.padr[0]);
+padr[1] = le16_to_cpu(initblk.padr[1]);
+padr[2] = le16_to_cpu(initblk.padr[2]);
 rdra = le32_to_cpu(initblk.rdra);
 tdra = le32_to_cpu(initblk.tdra);
 } else {
@@ -809,13 +813,13 @@ static void pcnet_init(PCNetState *s)
 s->phys_mem_read(s->dma_opaque, PHYSADDR(s,CSR_IADR(s)),
 (uint8_t *)&initblk, sizeof(initblk), 0);
 mode = le16_to_cpu(initblk.mode);
-   ladrf[0] = le16_to_cpu(initblk.ladrf[0]);
-   ladrf[1] = le16_to_cpu(initblk.ladrf[1]);
-   ladrf[2] = le16_to_cpu(initblk.ladrf[2]);
-   ladrf[3] = le16_to_cpu(initblk.ladrf[3]);
-   padr[0] = le16_to_cpu(initblk.padr[0]);
-   padr[1] = le16_to_cpu(initblk.padr[1]);
-   padr[2] = le16_to_cpu(initblk.padr[2]);
+ladrf[0] = le16_to_cpu(initblk.ladrf[0]);
+ladrf[1] = le16_to_cpu(initblk.ladrf[1]);
+ladrf[2] = le16_to_cpu(initblk.ladrf[2]);
+ladrf[3] = le16_to_cpu(initblk.ladrf[3]);
+padr[0] = le16_to_cpu(initblk.padr[0]);
+padr[1] = le16_to_cpu(initblk.padr[1]);
+padr[2] = le16_to_cpu(initblk.padr[2]);
 rdra = le32_to_cpu(initblk.rdra);
 tdra = le32_to_cpu(initblk.tdra);
 rlen = rdra >> 29;
@@ -858,12 +862,12 @@ static void pcnet_start(PCNetState *s)
 printf("pcnet_start\n");
 #endif
 
-if (!CSR_DTX(s))
+if (!CSR_DTX(s)) {
 s->csr[0] |= 0x0010;/* set TXON */
-
-if (!CSR_DRX(s))
+}
+if (!CSR_DRX(s)) {
 s->csr[0] |= 0x0020;/* set RXON */
-
+}
 s->csr[0] &= ~0x0004;   /* clear STOP bit */
 s->csr[0] |= 0x0002;
 pcnet_poll_timer(s);
@@ -925,8 +929,7 @@ static void pcnet_rdte_poll(PCNetState *s)
crda);
 }
 } else {
-printf("pcnet: BAD RMD RDA=0x" TARGET_FMT_plx "\n",
-   crda);
+printf("pcnet: BAD RMD RDA=0x" TARGET_FMT_plx "\n", crda);
 #endif
 }
 }
@@ -1168,10 +1171,11 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t 
*buf, size_t size_)
 #endif
 
 while (pktcount--) {
-if (CSR_RCVRC(s) <= 1)
+if (CSR_RCVRC(s) <= 1) {
 CSR_RCVRC(s) = CSR_RCVRL(s);
-else
+} else {
 CSR_RCVRC(s)--;
+}
 }
 
 pcnet_rdte_poll(s);
@@ -1207,7 +1211,7 @@ static void pcnet_transmit(PCNetState *s)
 
 s->tx_busy = 1;
 
-txagain:
+txagain:
 if (pcnet_tdte_poll(s)) {
 struct pcnet_TMD tmd;
 
@@ -1251,7 +1255,7 @@ static void pcnet_transmit(PCNetSta