Re: [Qemu-devel] [PATCH v1] slirp, disas: Replace min/max with MIN/MAX macros

2016-11-29 Thread no-reply
Hi,

Your series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH v1] slirp, disas: Replace min/max with MIN/MAX 
macros
Type: series
Message-id: 1480324926-24761-1-git-send-email-yuval.sh...@oracle.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
6daf49a slirp, disas: Replace min/max with MIN/MAX macros

=== OUTPUT BEGIN ===
Checking PATCH 1/1: slirp, disas: Replace min/max with MIN/MAX macros...
ERROR: code indent should never use tabs
#29: FILE: disas/m68k.c:4732:
+^I  mant_bits = MIN(mant_bits_left, 32);$

ERROR: code indent should never use tabs
#104: FILE: slirp/tcp_input.c:599:
+^I  tp->rcv_wnd = MAX(win, (int)(tp->rcv_adv - tp->rcv_nxt));$

ERROR: code indent should never use tabs
#113: FILE: slirp/tcp_input.c:1068:
+^I^I^I^I^IMIN(tp->snd_wnd, tp->snd_cwnd) / 2 /$

ERROR: code indent should never use tabs
#122: FILE: slirp/tcp_input.c:1141:
+^I^I  tp->snd_cwnd = MIN(cw + incr, TCP_MAXWIN<snd_scale);$

ERROR: spaces required around that '<<' (ctx:VxV)
#122: FILE: slirp/tcp_input.c:1141:
+ tp->snd_cwnd = MIN(cw + incr, TCP_MAXWIN<snd_scale);
  ^

ERROR: code indent should never use tabs
#131: FILE: slirp/tcp_input.c:1589:
+^Imss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr)$

ERROR: code indent should never use tabs
#136: FILE: slirp/tcp_input.c:1593:
+^Imss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr)$

ERROR: code indent should never use tabs
#146: FILE: slirp/tcp_input.c:1601:
+^I^Imss = MIN(mss, offer);$

ERROR: code indent should never use tabs
#147: FILE: slirp/tcp_input.c:1602:
+^Imss = MAX(mss, 32);$

ERROR: code indent should never use tabs
#160: FILE: slirp/tcp_output.c:91:
+^Iwin = MIN(tp->snd_wnd, tp->snd_cwnd);$

ERROR: code indent should never use tabs
#169: FILE: slirp/tcp_output.c:130:
+^Ilen = MIN(so->so_snd.sb_cc, win) - off;$

ERROR: code indent should never use tabs
#178: FILE: slirp/tcp_output.c:196:
+^I^Ilong adv = MIN(win, (long)TCP_MAXWIN << tp->rcv_scale) -$

ERROR: code indent should never use tabs
#191: FILE: slirp/tcp_timer.c:236:
+^I^Iu_int win = MIN(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;$

total: 13 errors, 0 warnings, 146 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@freelists.org

[Qemu-devel] [PATCH v1] slirp, disas: Replace min/max with MIN/MAX macros

2016-11-28 Thread Yuval Shaia
Signed-off-by: Yuval Shaia 
---
v0 -> v1:
* Remove unndeeded "include" as suggested by Fam Zheng
* Change commit message's prefix as suggested by Markus Armbruster
* Utilize MIN macro in two extra places in file disas/m68k.c
---
 disas/m68k.c   |  8 ++--
 slirp/dhcpv6.c |  2 +-
 slirp/ip6_icmp.c   |  2 +-
 slirp/slirp.c  |  2 +-
 slirp/slirp.h  |  5 -
 slirp/tcp_input.c  | 14 +++---
 slirp/tcp_output.c |  6 +++---
 slirp/tcp_timer.c  |  2 +-
 slirp/tcpip.h  |  2 +-
 9 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/disas/m68k.c b/disas/m68k.c
index 8e7c3f7..81e0fb4 100644
--- a/disas/m68k.c
+++ b/disas/m68k.c
@@ -4698,10 +4698,6 @@ get_field (const unsigned char *data, enum 
floatformat_byteorders order,
   return result;
 }
 
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
 /* Convert from FMT to a double.
FROM is the address of the extended float.
Store the double in *TO.  */
@@ -4733,7 +4729,7 @@ floatformat_to_double (const struct floatformat *fmt,
   nan = 0;
   while (mant_bits_left > 0)
{
- mant_bits = min (mant_bits_left, 32);
+ mant_bits = MIN(mant_bits_left, 32);
 
  if (get_field (ufrom, fmt->byteorder, fmt->totalsize,
 mant_off, mant_bits) != 0)
@@ -4793,7 +4789,7 @@ floatformat_to_double (const struct floatformat *fmt,
 
   while (mant_bits_left > 0)
 {
-  mant_bits = min (mant_bits_left, 32);
+  mant_bits = MIN(mant_bits_left, 32);
 
   mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
 mant_off, mant_bits);
diff --git a/slirp/dhcpv6.c b/slirp/dhcpv6.c
index 02c51c7..d266611 100644
--- a/slirp/dhcpv6.c
+++ b/slirp/dhcpv6.c
@@ -168,7 +168,7 @@ static void dhcpv6_info_request(Slirp *slirp, struct 
sockaddr_in6 *srcsas,
 sa[0], sa[1], sa[2], sa[3], sa[4], sa[5], sa[6], sa[7],
 sa[8], sa[9], sa[10], sa[11], sa[12], sa[13], sa[14],
 sa[15], slirp->bootp_filename);
-slen = min(slen, smaxlen);
+slen = MIN(slen, smaxlen);
 *resp++ = slen >> 8;/* option-len high byte */
 *resp++ = slen; /* option-len low byte */
 resp += slen;
diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c
index 6d18e28..298a48d 100644
--- a/slirp/ip6_icmp.c
+++ b/slirp/ip6_icmp.c
@@ -95,7 +95,7 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8_t 
code)
 #endif
 
 rip->ip_nh = IPPROTO_ICMPV6;
-const int error_data_len = min(m->m_len,
+const int error_data_len = MIN(m->m_len,
 IF_MTU - (sizeof(struct ip6) + ICMP6_ERROR_MINLEN));
 rip->ip_pl = htons(ICMP6_ERROR_MINLEN + error_data_len);
 t->m_len = sizeof(struct ip6) + ntohs(rip->ip_pl);
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 6e2b4e5..60539de 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -774,7 +774,7 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error)
 static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
 {
 struct slirp_arphdr *ah = (struct slirp_arphdr *)(pkt + ETH_HLEN);
-uint8_t arp_reply[max(ETH_HLEN + sizeof(struct slirp_arphdr), 64)];
+uint8_t arp_reply[MAX(ETH_HLEN + sizeof(struct slirp_arphdr), 64)];
 struct ethhdr *reh = (struct ethhdr *)arp_reply;
 struct slirp_arphdr *rah = (struct slirp_arphdr *)(arp_reply + ETH_HLEN);
 int ar_op;
diff --git a/slirp/slirp.h b/slirp/slirp.h
index a1f3139..3877f66 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -292,9 +292,4 @@ int tcp_emu(struct socket *, struct mbuf *);
 int tcp_ctl(struct socket *);
 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
 
-#ifndef _WIN32
-#define min(x,y) ((x) < (y) ? (x) : (y))
-#define max(x,y) ((x) > (y) ? (x) : (y))
-#endif
-
 #endif
diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c
index c5063a9..42c7f2f 100644
--- a/slirp/tcp_input.c
+++ b/slirp/tcp_input.c
@@ -596,7 +596,7 @@ findso:
   win = sbspace(>so_rcv);
  if (win < 0)
win = 0;
- tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt));
+ tp->rcv_wnd = MAX(win, (int)(tp->rcv_adv - tp->rcv_nxt));
}
 
switch (tp->t_state) {
@@ -1065,7 +1065,7 @@ trimthenstep6:
else if (++tp->t_dupacks == TCPREXMTTHRESH) {
tcp_seq onxt = tp->snd_nxt;
u_int win =
-   min(tp->snd_wnd, tp->snd_cwnd) / 2 /
+   MIN(tp->snd_wnd, tp->snd_cwnd) / 2 /
tp->t_maxseg;
 
if (win < 2)
@@ -1138,7 +1138,7 @@ trimthenstep6:
 
  if (cw > tp->snd_ssthresh)
incr = incr * incr / cw;
- tp->snd_cwnd = min(cw