From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 07/10] ipvs: Use min3() in ip_vs_dbg_callid()
Date: Thu, 25 Apr 2013 02:22:18 +0200 [thread overview]
Message-ID: <1366849341-10466-8-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1366849341-10466-1-git-send-email-pablo@netfilter.org>
From: Simon Horman <horms@verge.net.au>
There are two motivations for this:
1. It improves readability to my eyes
2. Using nested min() calls results in a shadowed _min1 variable,
which is a bit untidy. Sparse complained about this.
I have also replaced (size_t)64 with a variable of type size_t and value 64.
This also improves readability to my eyes.
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
net/netfilter/ipvs/ip_vs_pe_sip.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c b/net/netfilter/ipvs/ip_vs_pe_sip.c
index 00cc024..9a8f421 100644
--- a/net/netfilter/ipvs/ip_vs_pe_sip.c
+++ b/net/netfilter/ipvs/ip_vs_pe_sip.c
@@ -13,7 +13,8 @@ static const char *ip_vs_dbg_callid(char *buf, size_t buf_len,
const char *callid, size_t callid_len,
int *idx)
{
- size_t len = min(min(callid_len, (size_t)64), buf_len - *idx - 1);
+ size_t max_len = 64;
+ size_t len = min3(max_len, callid_len, buf_len - *idx - 1);
memcpy(buf + *idx, callid, len);
buf[*idx+len] = '\0';
*idx += len + 1;
--
1.7.10.4
next prev parent reply other threads:[~2013-04-25 0:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-25 0:22 [PATCH 00/10] netfilter fixes for net-next Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 01/10] ipvs: properly dereference dest_dst in ip_vs_forget_dev Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 02/10] ipvs: fix sparse warnings for ip_vs_conn listing Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 03/10] ipvs: fix the remaining sparse warnings in ip_vs_ctl.c Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 04/10] ipvs: fix sparse warnings in lblc and lblcr Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 05/10] ipvs: fix sparse warnings for some parameters Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 06/10] ipvs: Avoid shadowing net variable in ip_vs_leave() Pablo Neira Ayuso
2013-04-25 0:22 ` Pablo Neira Ayuso [this message]
2013-04-25 0:22 ` [PATCH 08/10] ipvs: off by one in set_sctp_state() Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 09/10] ipvs: Use network byte order for sync message size Pablo Neira Ayuso
2013-04-25 0:22 ` [PATCH 10/10] netfilter: nf_nat: missing condition in nf_xfrm_me_harder() Pablo Neira Ayuso
2013-04-25 4:54 ` [PATCH 00/10] netfilter fixes for net-next David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366849341-10466-8-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).