[PATCH] Address some -O3 issues on Ubuntu 10.04
Michael Adam
obnox at samba.org
Thu Jun 2 22:38:08 UTC 2016
On 2016-06-03 at 10:28 +1200, Andrew Bartlett wrote:
> G'Day,
Hi Andrew!
Thanks for these... I meant to look into the -O3 errors
on 10.04, but failed to find the time so far... Comments
below
> These two patches address just some of the issues flagged by -O3 and
> -Werror on Ubuntu 10.04. There are still many others, and I think we
> should either remove the -Werror or samba-o3 build from our autobuild
> on that platform, as otherwise we are not seeing any of the other
> failures.
>
> There are still many, many other issues, which are all probably red
> herrings flagged by an older compiler however.
>
> Andrew Bartlett
> From 4c6091cf2094d409a032b1125b49d7fe6e0f7d0b Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 3 Jun 2016 09:23:12 +1200
> Subject: [PATCH 1/2] build: Try to work around strict aliasing rules on Ubuntu
> 10.04
>
> We get cc1: warnings being treated as errors
> ../lib/util/util_net.c: In function get_socket_port:
> ../lib/util/util_net.c:921: error: dereferencing pointer sa.106 does break strict-aliasing rules
> ../lib/util/util_net.c:921: note: initialized from here
> ../lib/util/util_net.c:925: error: dereferencing pointer sa.107 does break strict-aliasing rules
> ../lib/util/util_net.c:925: note: initialized from here
>
> Signed-off-by: Andrew Bartlett <abartlet at samba.org>
> ---
> lib/util/util_net.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/util/util_net.c b/lib/util/util_net.c
> index e5b33aa..e6a8c92 100644
> --- a/lib/util/util_net.c
> +++ b/lib/util/util_net.c
> @@ -918,11 +918,13 @@ int get_socket_port(int fd)
>
> #if defined(HAVE_IPV6)
> if (sa.ss_family == AF_INET6) {
> - return ntohs(((struct sockaddr_in6 *)&sa)->sin6_port);
> + struct sockaddr_in6 *sa_in6 = &sa;
> + return ntohs(sa_in6->sin6_port);
> }
> #endif
> if (sa.ss_family == AF_INET) {
> - return ntohs(((struct sockaddr_in *)&sa)->sin_port);
> + struct sockaddr_in *sa_in = &sa;
> + return ntohs(sa_in->sin_port);
> }
> return -1;
> }
> --
> 2.8.0.rc3
Reviewed-by: Michael Adam <obnox at samba.org>
> From 72143ce3dae35b90a2cbb9f5ec5d7f32f25a5edc Mon Sep 17 00:00:00 2001
> From: Andrew Bartlett <abartlet at samba.org>
> Date: Fri, 3 Jun 2016 09:53:29 +1200
> Subject: [PATCH 2/2] build: Address may be used uninitialized in this function
> on Ubuntu 10.04
>
> This is not found by modern compilers, but prevents the -Werror -O3 build on Ubuntu 10.04
>
> Signed-off-by: Andrew Bartlett <abartlet at samba.org>
> ---
> lib/dbwrap/dbwrap_rbt.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/dbwrap/dbwrap_rbt.c b/lib/dbwrap/dbwrap_rbt.c
> index 3b5e589..0402ab7 100644
> --- a/lib/dbwrap/dbwrap_rbt.c
> +++ b/lib/dbwrap/dbwrap_rbt.c
> @@ -277,7 +277,10 @@ static bool db_rbt_search_internal(struct db_context *db, TDB_DATA key,
> struct rb_node *n;
> bool found = false;
> struct db_rbt_node *r = NULL;
> - TDB_DATA search_key, search_val;
> + TDB_DATA search_key = { .dsize = NULL,
> + .dptr = NULL };
> + TDB_DATA search_val = { .dsize = NULL,
> + .dptr = NULL };
What about search_key = { 0 };
Or even search_key = {};
We discussed to prefer one of those, some time ago,
but I currently can't remember which ... :-)
Cheers - Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160603/976b1359/signature.sig>
More information about the samba-technical
mailing list