Bug 71079 - warning: cast from 'guchar *' (aka 'unsigned char *') to 'guint32 *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
Summary: warning: cast from 'guchar *' (aka 'unsigned char *') to 'guint32 *' (aka 'un...
Status: RESOLVED FIXED
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-31 08:08 UTC by Paul Menzel
Modified: 2014-11-18 18:49 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
hidpp-device: avoid unaligned memory access (1.21 KB, patch)
2014-11-18 01:37 UTC, Peter Wu
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Menzel 2013-10-31 08:08:44 UTC
Building UPower from branch `master` with Clang 3.4, the following two warnings are generated.

        $ git describe
        UPOWER_0_99_0-1-ge96f534
        $ clang --version
        Debian clang version 3.4-1 (trunk) (based on LLVM 3.4)
        Target: i386-pc-linux-gnu
        Thread model: posix
        $ $ CC=clang ./autogen.sh
        […]
        config.status: executing po/stamp-it commands

                         UPower 0.99.1
                     =========================

                prefix:                     /usr/local
                libdir:                     ${exec_prefix}/lib
                libexecdir:                 ${exec_prefix}/libexec
                bindir:                     ${exec_prefix}/bin
                sbindir:                    ${exec_prefix}/sbin
                datadir:                    ${datarootdir}
                sysconfdir:                 ${prefix}/etc
                localstatedir:              ${prefix}/var
                docdir:                     ${datarootdir}/doc/${PACKAGE_TARNAME}

                compiler:                   clang
                cflags:                     -g -O2
                cppflags:                    -DG_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE -DGSEAL_ENABLE
                xsltproc:                   /usr/bin/xsltproc

                Enable deprecated stuff:    no
                Backend:                    linux
                libimobiledevice support:   yes
                Maintainer mode:            yes
                Building api docs:          no
                Building man pages:         yes
                Building unit tests:        yes
        $ make
        […]
          CC       libupshared_la-hidpp-device.lo
        hidpp-device.c:837:13: warning: cast from 'guchar *' (aka 'unsigned char *') to 'guint32 *' (aka 'unsigned int *') increases required alignment from 1
              to 4 [-Wcast-align]
                        serialp = (guint32 *) &msg.l.params[1];
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
        1 warning generated.
          CC       libupshared_la-sysfs-utils.lo
          CC       libupshared_la-up-device-idevice.lo
          CCLD     libupshared.la
          CC       hidpp_test-hidpp-device.o
        hidpp-device.c:837:13: warning: cast from 'guchar *' (aka 'unsigned char *') to 'guint32 *' (aka 'unsigned int *') increases required alignment from 1
              to 4 [-Wcast-align]
                        serialp = (guint32 *) &msg.l.params[1];
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
        1 warning generated.
        […]
Comment 1 Peter Wu 2014-11-18 01:37:05 UTC
Created attachment 109651 [details] [review]
hidpp-device: avoid unaligned memory access

This warning popped up here too, the attached patch fixes it.
Comment 2 Bastien Nocera 2014-11-18 18:49:31 UTC
commit b3e5143f5a56beee63529fd25b44522ae282e226
Author: Peter Wu <peter@lekensteyn.nl>
Date:   Mon Nov 17 22:33:32 2014 +0100

    hidpp-device: avoid unaligned memory access
    
    Fixes a -Wcast-align warning and a -fsanitize=undefined error.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=71079


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.