[ovs-dev] [PATCH] ovsdb-idlc: Use ALIGNED_CAST to avoid spurious warnings for index rows.

Han Zhou zhouhan at gmail.com
Wed Sep 12 06:32:25 UTC 2018


On Mon, Sep 10, 2018 at 1:01 PM Ben Pfaff <blp at ovn.org> wrote:
>
> The *_index_init_row() function casts a generic ovsdb_idl_row pointer to
> a specific type of row pointer.  This can cause an increase in required
> alignment with some kinds of data on some architectures.  GCC complains,
> e.g.:
>
>     lib/vswitch-idl.c: In function
'ovsrec_flow_sample_collector_set_index_init_row'
>     lib/vswitch-idl.c:9277:12: warning: cast increases required alignment
of target

Hi Ben, could you share on which compiler/version you see this warning?
>
> However, rows are always allocated with malloc(), which returns member
> suitable for any type, so this is a false positive warning and this commit
> suppresses it.
>
> Signed-off-by: Ben Pfaff <blp at ovn.org>
> ---
>  ovsdb/ovsdb-idlc.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
> index 1c9483cbe393..40fef39edff7 100755
> --- a/ovsdb/ovsdb-idlc.in
> +++ b/ovsdb/ovsdb-idlc.in
> @@ -1217,7 +1217,7 @@ struct %(s)s *
>  %(s)s_index_init_row(struct ovsdb_idl_index *index)
>  {
>      ovs_assert(index->table->class_ == &%(p)stable_%(tl)s);
> -    return (struct %(s)s *) ovsdb_idl_index_init_row(index);
> +    return ALIGNED_CAST(struct %(s)s *, ovsdb_idl_index_init_row(index));
>  }
>
>  struct %(s)s *
> --
> 2.16.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev


More information about the dev mailing list