[systemd-devel] PATCH: fix sparse warnings

Lennart Poettering lennart at poettering.net
Wed Mar 21 17:21:47 PDT 2012


On Fri, 16.03.12 14:32, Frederic Crozat (fcrozat at suse.com) wrote:

> Le mercredi 14 mars 2012 à 11:36 -0700, Josh Triplett a écrit :
> > On Wed, Mar 14, 2012 at 06:58:32PM +0100, Lennart Poettering wrote:
> > > On Wed, 07.03.12 06:34, Josh Triplett (josh at joshtriplett.org) wrote:
> > > > I've attached a header file which should provide all the endianness
> > > > checking you need.  Just include it in place of endian.h everywhere you
> > > > currently include endian.h.  I stuck an all-permissive MIT license on
> > > > it, for maximum possible reuse.
> > > 
> > > This looks really cool! Thanks a lot for this. One comment, before we
> > > stick this into systemd:
> > > 
> > > > #ifndef SPARSE_ENDIAN_H
> > > > #define SPARSE_ENDIAN_H
> > > > 
> > > > #include <endian.h>
> > > > #include <stdint.h>
> > > > 
> > > > #ifdef __CHECKER__
> > > > #define __bitwise __attribute__((bitwise))
> > > > #define __force __attribute__((force))
> > > > #else
> > > > #define __bitwise
> > > > #define __force
> > > > #endif
> > > > 
> > > > typedef uint16_t __bitwise le16;
> > > > typedef uint16_t __bitwise be16;
> > > > typedef uint32_t __bitwise le32;
> > > > typedef uint32_t __bitwise be32;
> > > > typedef uint64_t __bitwise le64;
> > > > typedef uint64_t __bitwise be64;
> > > 
> > > Can we add a suffix _t here? I much prefer le16_t over le16, since this
> > > is a type.
> > 
> > Sure, feel free.  I used the unsuffixed names to match the kernel's type
> > names and the names used in the conversion functions, but the endianness
> > checking will obviously work with whatever names you prefer. :)
> > 
> > The following sed line will give you the names you want:
> > 
> > sed -i 's/\<[bl]e\(16\|32\|64\)\>/&_t/g' sparse-endian.h
> 
> Here is a patch integrating your header (modified as wanted by Lennart)
> and the changes in various locations of journal to use le64_t.
> 
> It also fixes some potential endianness errors, please review it
> carefully.

Looks good to me. Applied!

Now, one more question, since I actually never used sparse myself:
what's the best way to make use of this? If I run autogen and build this
with CC=cgcc some things look really borked (like generation of the dbus
introspection files goes to stdout). Any suggestions?

Thanks for your work, much appreciated

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list