[ovs-dev] [PATCHv2] lib/util.h: Disable ovs_assert when build with NDEBUG
Ben Pfaff
blp at nicira.com
Fri Dec 13 18:36:05 UTC 2013
On Fri, Dec 13, 2013 at 10:30:56AM -0800, Ben Pfaff wrote:
> On Fri, Dec 13, 2013 at 06:54:27PM +0100, Helmut Schaa wrote:
> > Reduces binary size. Use a static inline function instead of
> > a macro to not get "unused variable" warnings everywhere.
> >
> > Making ovs_assert an empty inline in the header file effectively
> > optimizes out all calls to ovs_assert.
> >
> > Signed-off-by: Helmut Schaa <helmut.schaa at googlemail.com>
> > ---
> > lib/util.h | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/util.h b/lib/util.h
> > index 975d1a9..cc70f0e 100644
> > --- a/lib/util.h
> > +++ b/lib/util.h
> > @@ -68,11 +68,16 @@
> > *
> > * - Writes the failure message to the log.
> > *
> > - * - Not affected by NDEBUG. */
> > + * - Gets optimized out by NDEBUG. */
>
> This list is supposed to be *differences* from assert() ;-)
>
> I changed the list item to
> - NDEBUG only affects the first time util.h is included.
>
> and I'll apply this soon.
Oh, except that when I actually build with -DNDEBUG, I get
../tests/test-byte-order.c: In function 'main':
../tests/test-byte-order.c:29:20: error: unused variable 'll' [-Werror=unused-variable]
../tests/test-byte-order.c:28:20: error: unused variable 'l' [-Werror=unused-variable]
../tests/test-byte-order.c:27:20: error: unused variable 's' [-Werror=unused-variable]
which isn't the fault of this patch but we should fix it, but worse, it
makes the ovs_assert test fail, as follows. I'd like to get that fixed
before applying it.
# -*- compilation -*-
44. library.at:166: testing ovs_assert ...
../../tests/library.at:168: test-util -voff -vfile:info '-vPATTERN:file:%c|%p|%m' --log-file assert || kill -l $?
stderr:
--- - 2013-12-13 10:34:08.509418178 -0800
+++ /home/blp/nicira/ovs/_build/tests/testsuite.dir/at-groups/44/stdout 2013-12-13 10:34:08.000000000 -0800
@@ -1,2 +1 @@
-ABRT
44. library.at:166: 44. ovs_assert (library.at:166): FAILED (library.at:168)
More information about the dev
mailing list