Re: [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 6, 2021 at 11:40 AM James Carter <jwcart2@xxxxxxxxx> wrote:
>
> On Sat, Jul 3, 2021 at 10:32 AM Nicolas Iooss <nicolas.iooss@xxxxxxx> wrote:
> >
> > On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
> > (which is not the default build configuration), the compiler reports:
> >
> >   ../cil/src/cil_binary.c:4293:22: error: empty expression statement
> >   has no effect; remove unnecessary ';' to silence this warning
> >   [-Werror,-Wextra-semi-stmt]
> >           mix(k->target_class);
> >                               ^
> >   ../cil/src/cil_binary.c:4294:21: error: empty expression statement
> >   has no effect; remove unnecessary ';' to silence this warning
> >   [-Werror,-Wextra-semi-stmt]
> >           mix(k->target_type);
> >                              ^
> >   ../cil/src/cil_binary.c:4295:21: error: empty expression statement
> >   has no effect; remove unnecessary ';' to silence this warning
> >   [-Werror,-Wextra-semi-stmt]
> >           mix(k->source_type);
> >                              ^
> >   ../cil/src/cil_binary.c:4296:19: error: empty expression statement
> >   has no effect; remove unnecessary ';' to silence this warning
> >   [-Werror,-Wextra-semi-stmt]
> >           mix(k->specified);
> >                            ^
> >
> > Use a do { ... } while (0) construction to silence this warning.
> >
> > Moreover the same warning appears when using two semicolons to end a
> > statement. Remove such occurrences, like what was already done in commit
> > 811185648af2 ("libsepol: drop repeated semicolons").
> >
> > Signed-off-by: Nicolas Iooss <nicolas.iooss@xxxxxxx>
>
> For all six patches:
> Acked-by: James Carter <jwcart2@xxxxxxxxx>
>

All six patches have been merged.
Thanks,
Jim

> > ---
> >  libsepol/cil/src/cil_binary.c      |  4 ++--
> >  libsepol/cil/src/cil_resolve_ast.c |  2 +-
> >  libsepol/src/avtab.c               |  4 ++--
> >  libsepol/tests/libsepol-tests.c    | 18 +++++++++++-------
> >  4 files changed, 16 insertions(+), 12 deletions(-)
> >
> > diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> > index 54d13f2f3945..41105c122bc3 100644
> > --- a/libsepol/cil/src/cil_binary.c
> > +++ b/libsepol/cil/src/cil_binary.c
> > @@ -4277,7 +4277,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
> >
> >         uint32_t hash = 0;
> >
> > -#define mix(input) { \
> > +#define mix(input) do { \
> >         uint32_t v = input; \
> >         v *= c1; \
> >         v = (v << r1) | (v >> (32 - r1)); \
> > @@ -4285,7 +4285,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
> >         hash ^= v; \
> >         hash = (hash << r2) | (hash >> (32 - r2)); \
> >         hash = hash * m + n; \
> > -}
> > +} while (0)
> >
> >         mix(k->target_class);
> >         mix(k->target_type);
> > diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
> > index 32ea64e39b21..9a02e3867659 100644
> > --- a/libsepol/cil/src/cil_resolve_ast.c
> > +++ b/libsepol/cil/src/cil_resolve_ast.c
> > @@ -2825,7 +2825,7 @@ static int cil_build_call_args(struct cil_tree_node *call_node, struct cil_call
> >                         return SEPOL_OK;
> >                 } else {
> >                         cil_tree_log(call_node, CIL_ERR, "Unexpected arguments");
> > -                       return SEPOL_ERR;;
> > +                       return SEPOL_ERR;
> >                 }
> >         }
> >         if (call->args_tree == NULL) {
> > diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
> > index 88e9d510f981..5e16a0e9899e 100644
> > --- a/libsepol/src/avtab.c
> > +++ b/libsepol/src/avtab.c
> > @@ -63,7 +63,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
> >
> >         uint32_t hash = 0;
> >
> > -#define mix(input) { \
> > +#define mix(input) do { \
> >         uint32_t v = input; \
> >         v *= c1; \
> >         v = (v << r1) | (v >> (32 - r1)); \
> > @@ -71,7 +71,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
> >         hash ^= v; \
> >         hash = (hash << r2) | (hash >> (32 - r2)); \
> >         hash = hash * m + n; \
> > -}
> > +} while (0)
> >
> >         mix(keyp->target_class);
> >         mix(keyp->target_type);
> > diff --git a/libsepol/tests/libsepol-tests.c b/libsepol/tests/libsepol-tests.c
> > index 544c792d2ab5..dc8fd5ce5f6c 100644
> > --- a/libsepol/tests/libsepol-tests.c
> > +++ b/libsepol/tests/libsepol-tests.c
> > @@ -36,13 +36,17 @@
> >  int mls;
> >
> >  #define DECLARE_SUITE(name) \
> > -       suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
> > -       if (NULL == suite) { \
> > -               CU_cleanup_registry(); \
> > -               return CU_get_error(); } \
> > -       if (name##_add_tests(suite)) { \
> > -               CU_cleanup_registry(); \
> > -               return CU_get_error(); }
> > +       do { \
> > +               suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
> > +               if (NULL == suite) { \
> > +                       CU_cleanup_registry(); \
> > +                       return CU_get_error(); \
> > +               } \
> > +               if (name##_add_tests(suite)) { \
> > +                       CU_cleanup_registry(); \
> > +                       return CU_get_error(); \
> > +               } \
> > +       } while (0)
> >
> >  static void usage(char *progname)
> >  {
> > --
> > 2.32.0
> >



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux