From patchwork Mon Nov 28 09:22:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9449211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3845D600CB for ; Mon, 28 Nov 2016 09:22:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19F1D204BA for ; Mon, 28 Nov 2016 09:22:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CBFD24B5B; Mon, 28 Nov 2016 09:22:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D97D204BA for ; Mon, 28 Nov 2016 09:22:56 +0000 (UTC) Received: from localhost ([::1]:57473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBI9F-0000H5-UJ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Nov 2016 04:22:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBI8i-0000Bb-55 for qemu-devel@nongnu.org; Mon, 28 Nov 2016 04:22:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBI8e-0004XH-Uc for qemu-devel@nongnu.org; Mon, 28 Nov 2016 04:22:20 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:32374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBI8e-0004Wy-Nj for qemu-devel@nongnu.org; Mon, 28 Nov 2016 04:22:16 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uAS9MCKM025938 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Nov 2016 09:22:12 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uAS9MBfa009099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Nov 2016 09:22:12 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uAS9MAHf004058; Mon, 28 Nov 2016 09:22:10 GMT Received: from yuval-lap.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 28 Nov 2016 01:22:10 -0800 From: Yuval Shaia To: laurent@vivier.eu, samuel.thibault@ens-lyon.org, jan.kiszka@siemens.com Date: Mon, 28 Nov 2016 11:22:06 +0200 Message-Id: <1480324926-24761-1-git-send-email-yuval.shaia@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Source-IP: userv0022.oracle.com [156.151.31.74] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 Subject: [Qemu-devel] [PATCH v1] slirp, disas: Replace min/max with MIN/MAX macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, yuval.shaia@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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->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 + incr, TCP_MAXWIN<snd_scale); + tp->snd_cwnd = MIN(cw + incr, TCP_MAXWIN<snd_scale); } if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; @@ -1586,11 +1586,11 @@ tcp_mss(struct tcpcb *tp, u_int offer) switch (so->so_ffamily) { case AF_INET: - mss = min(IF_MTU, IF_MRU) - sizeof(struct tcphdr) + mss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr) + sizeof(struct ip); break; case AF_INET6: - mss = min(IF_MTU, IF_MRU) - sizeof(struct tcphdr) + mss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr) + sizeof(struct ip6); break; default: @@ -1598,8 +1598,8 @@ tcp_mss(struct tcpcb *tp, u_int offer) } if (offer) - mss = min(mss, offer); - mss = max(mss, 32); + mss = MIN(mss, offer); + mss = MAX(mss, 32); if (mss < tp->t_maxseg || offer != 0) tp->t_maxseg = mss; diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c index 819db27..263af82 100644 --- a/slirp/tcp_output.c +++ b/slirp/tcp_output.c @@ -88,7 +88,7 @@ tcp_output(struct tcpcb *tp) again: sendalot = 0; off = tp->snd_nxt - tp->snd_una; - win = min(tp->snd_wnd, tp->snd_cwnd); + win = MIN(tp->snd_wnd, tp->snd_cwnd); flags = tcp_outflags[tp->t_state]; @@ -127,7 +127,7 @@ again: } } - len = min(so->so_snd.sb_cc, win) - off; + len = MIN(so->so_snd.sb_cc, win) - off; if (len < 0) { /* @@ -193,7 +193,7 @@ again: * taking into account that we are limited by * TCP_MAXWIN << tp->rcv_scale. */ - long adv = min(win, (long)TCP_MAXWIN << tp->rcv_scale) - + long adv = MIN(win, (long)TCP_MAXWIN << tp->rcv_scale) - (tp->rcv_adv - tp->rcv_nxt); if (adv >= (long) (2 * tp->t_maxseg)) diff --git a/slirp/tcp_timer.c b/slirp/tcp_timer.c index f9060c7..6a091b8 100644 --- a/slirp/tcp_timer.c +++ b/slirp/tcp_timer.c @@ -233,7 +233,7 @@ tcp_timers(register struct tcpcb *tp, int timer) * to go below this.) */ { - u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; + u_int win = MIN(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; if (win < 2) win = 2; tp->snd_cwnd = tp->t_maxseg; diff --git a/slirp/tcpip.h b/slirp/tcpip.h index 7bdb971..07dbf2c 100644 --- a/slirp/tcpip.h +++ b/slirp/tcpip.h @@ -85,7 +85,7 @@ struct tcpiphdr { /* This is the difference between the size of a tcpiphdr structure, and the * size of actual ip+tcp headers, rounded up since we need to align data. */ #define TCPIPHDR_DELTA\ - (max(0,\ + (MAX(0,\ (sizeof(struct tcpiphdr)\ - sizeof(struct ip) - sizeof(struct tcphdr) + 3) & ~3))