* [PATCH net-next] geneve: Get rid of is_all_zero(), streamline is_tnl_info_zero()
@ 2017-10-19 11:31 Stefano Brivio
2017-10-19 15:31 ` Stefano Brivio
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2017-10-19 11:31 UTC (permalink / raw)
To: David S . Miller, netdev; +Cc: pravin shelar
No need to re-invent memchr_inv() with !is_all_zero(). While at
it, replace conditional and return clauses with a single return
clause in is_tnl_info_zero().
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
drivers/net/geneve.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index f6404074b7b0..869726660b83 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1140,24 +1140,11 @@ static struct geneve_dev *geneve_find_dev(struct geneve_net *gn,
return t;
}
-static bool is_all_zero(const u8 *fp, size_t size)
-{
- int i;
-
- for (i = 0; i < size; i++)
- if (fp[i])
- return false;
- return true;
-}
-
static bool is_tnl_info_zero(const struct ip_tunnel_info *info)
{
- if (info->key.tun_id || info->key.tun_flags || info->key.tos ||
- info->key.ttl || info->key.label || info->key.tp_src ||
- !is_all_zero((const u8 *)&info->key.u, sizeof(info->key.u)))
- return false;
- else
- return true;
+ return !(info->key.tun_id || !info->key.tun_flags || !info->key.tos ||
+ info->key.ttl || !info->key.label || !info->key.tp_src ||
+ memchr_inv(&info->key.u, 0, sizeof(info->key.u)));
}
static bool geneve_dst_addr_equal(struct ip_tunnel_info *a,
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] geneve: Get rid of is_all_zero(), streamline is_tnl_info_zero()
2017-10-19 11:31 [PATCH net-next] geneve: Get rid of is_all_zero(), streamline is_tnl_info_zero() Stefano Brivio
@ 2017-10-19 15:31 ` Stefano Brivio
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2017-10-19 15:31 UTC (permalink / raw)
To: David S . Miller, netdev; +Cc: pravin shelar
On Thu, 19 Oct 2017 13:31:39 +0200
Stefano Brivio <sbrivio@redhat.com> wrote:
> No need to re-invent memchr_inv() with !is_all_zero(). While at
> it, replace conditional and return clauses with a single return
> clause in is_tnl_info_zero().
>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
> drivers/net/geneve.c | 19 +++----------------
> 1 file changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> index f6404074b7b0..869726660b83 100644
> --- a/drivers/net/geneve.c
> +++ b/drivers/net/geneve.c
> @@ -1140,24 +1140,11 @@ static struct geneve_dev *geneve_find_dev(struct geneve_net *gn,
> return t;
> }
>
> -static bool is_all_zero(const u8 *fp, size_t size)
> -{
> - int i;
> -
> - for (i = 0; i < size; i++)
> - if (fp[i])
> - return false;
> - return true;
> -}
> -
> static bool is_tnl_info_zero(const struct ip_tunnel_info *info)
> {
> - if (info->key.tun_id || info->key.tun_flags || info->key.tos ||
> - info->key.ttl || info->key.label || info->key.tp_src ||
> - !is_all_zero((const u8 *)&info->key.u, sizeof(info->key.u)))
> - return false;
> - else
> - return true;
> + return !(info->key.tun_id || !info->key.tun_flags || !info->key.tos ||
> + info->key.ttl || !info->key.label || !info->key.tp_src ||
> + memchr_inv(&info->key.u, 0, sizeof(info->key.u)));
NAK, I messed up the check entirely, I'll send a v2, sorry for the
noise.
--
Stefano
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-19 15:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-19 11:31 [PATCH net-next] geneve: Get rid of is_all_zero(), streamline is_tnl_info_zero() Stefano Brivio
2017-10-19 15:31 ` Stefano Brivio
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).