diff mbox

[kvm-unit-tests,v2,02/17] libcflat: introduce is_power_of_2()

Message ID 1478704224-20472-3-git-send-email-peterx@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Xu Nov. 9, 2016, 3:10 p.m. UTC
Suggested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 lib/libcflat.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Andrew Jones Nov. 10, 2016, 6:20 p.m. UTC | #1
On Wed, Nov 09, 2016 at 10:10:09AM -0500, Peter Xu wrote:
> Suggested-by: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  lib/libcflat.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index 72b1bf9..19bd0c6 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -103,4 +103,9 @@ do {									\
>  	}								\
>  } while (0)
>  
> +static inline bool is_power_of_2(unsigned long n)
> +{
> +	return (n && !(n & (n - 1)));

nit: outer () are unnecessary

> +}
> +
>  #endif

Reviewed-by: Andrew Jones <drjones@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Xu Nov. 14, 2016, 8:14 p.m. UTC | #2
On Thu, Nov 10, 2016 at 07:20:00PM +0100, Andrew Jones wrote:
> On Wed, Nov 09, 2016 at 10:10:09AM -0500, Peter Xu wrote:
> > Suggested-by: Andrew Jones <drjones@redhat.com>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  lib/libcflat.h | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/lib/libcflat.h b/lib/libcflat.h
> > index 72b1bf9..19bd0c6 100644
> > --- a/lib/libcflat.h
> > +++ b/lib/libcflat.h
> > @@ -103,4 +103,9 @@ do {									\
> >  	}								\
> >  } while (0)
> >  
> > +static inline bool is_power_of_2(unsigned long n)
> > +{
> > +	return (n && !(n & (n - 1)));
> 
> nit: outer () are unnecessary

Will fix.

> 
> > +}
> > +
> >  #endif
> 
> Reviewed-by: Andrew Jones <drjones@redhat.com>

Thanks,

-- peterx
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 72b1bf9..19bd0c6 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -103,4 +103,9 @@  do {									\
 	}								\
 } while (0)
 
+static inline bool is_power_of_2(unsigned long n)
+{
+	return (n && !(n & (n - 1)));
+}
+
 #endif