[Qemu-devel] [PATCH 12/31] slirp: use DIV_ROUND_UP

Marc-André Lureau posted 31 patches 8 years, 4 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 12/31] slirp: use DIV_ROUND_UP
Posted by Marc-André Lureau 8 years, 4 months ago
I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 slirp/ip6.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/slirp/ip6.h b/slirp/ip6.h
index 0908855f0f..b1bea43b3c 100644
--- a/slirp/ip6.h
+++ b/slirp/ip6.h
@@ -57,9 +57,9 @@ static inline bool in6_equal_mach(const struct in6_addr *a,
                                   const struct in6_addr *b,
                                   int prefix_len)
 {
-    if (memcmp(&(a->s6_addr[(prefix_len + 7) / 8]),
-               &(b->s6_addr[(prefix_len + 7) / 8]),
-               16 - (prefix_len + 7) / 8) != 0) {
+    if (memcmp(&(a->s6_addr[DIV_ROUND_UP(prefix_len, 8)]),
+               &(b->s6_addr[DIV_ROUND_UP(prefix_len, 8)]),
+               16 - DIV_ROUND_UP(prefix_len, 8)) != 0) {
         return 0;
     }
 
-- 
2.13.1.395.gf7b71de06


Re: [Qemu-devel] [PATCH 12/31] slirp: use DIV_ROUND_UP
Posted by Samuel Thibault 8 years, 4 months ago
Marc-André Lureau, on jeu. 22 juin 2017 14:41:45 +0200, wrote:
> I used the clang-tidy qemu-round check to generate the fix:
> https://github.com/elmarco/clang-tools-extra
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Applied to my tree, thanks!

> ---
>  slirp/ip6.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/slirp/ip6.h b/slirp/ip6.h
> index 0908855f0f..b1bea43b3c 100644
> --- a/slirp/ip6.h
> +++ b/slirp/ip6.h
> @@ -57,9 +57,9 @@ static inline bool in6_equal_mach(const struct in6_addr *a,
>                                    const struct in6_addr *b,
>                                    int prefix_len)
>  {
> -    if (memcmp(&(a->s6_addr[(prefix_len + 7) / 8]),
> -               &(b->s6_addr[(prefix_len + 7) / 8]),
> -               16 - (prefix_len + 7) / 8) != 0) {
> +    if (memcmp(&(a->s6_addr[DIV_ROUND_UP(prefix_len, 8)]),
> +               &(b->s6_addr[DIV_ROUND_UP(prefix_len, 8)]),
> +               16 - DIV_ROUND_UP(prefix_len, 8)) != 0) {
>          return 0;
>      }
>  
> -- 
> 2.13.1.395.gf7b71de06
> 

-- 
Samuel
<D> N: j'aime bien Cut d'un truc enorme... ca montre de quel cote de l'ecran sont les gonades :)))
 -+- #ens-mim et la peufeupeu -+-