Alignment issue of iobuf functions

NIIBE Yutaka gniibe at fsij.org
Tue Jan 5 02:53:05 CET 2016


Hello,

I'm now using ARMv7 variant.

=========================
$ uname -a
Linux OrangePI 3.4.39 #1 SMP PREEMPT Mon Oct 12 12:02:29 CEST 2015
armv7l GNU/Linux
$ gcc --version
gcc (Debian 5.3.1-4) 5.3.1 20151219
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=========================

Then, I see compiler warnings like:
=========================
../../gnupg/common/iobuf.c: In function `file_filter':
../../gnupg/common/iobuf.c:581:8: warning: cast increases required
alignment of target type [-Wcast-align]
       *(char **) buf = "file_filter(fd)";
        ^
=========================

This is because of the argument BUF is declared as byte * and we cast
to (char **), where the alignment condition for (byte *) and the one
for (char **) could be different.  So, the warning is relevant.

I think that our usage of (byte *) here is actually (void *).  I'm not
sure if changing to (void *) is better or not.
-- 



More information about the Gnupg-devel mailing list