[systemd-devel] PATCH: fix sparse warnings
Josh Triplett
josh at joshtriplett.org
Wed Mar 14 11:36:30 PDT 2012
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
> (and also, emacs' recognizes this and highlights it differently ;-))
I just checked with "emacs -q", and at least on my system emacs seems to
correctly identify and highlight all six of those names as types by
default, in all the contexts I can think of where a type can appear.
Take a look at
https://www.gnu.org/software/emacs/manual/html_node/ccmode/Font-Locking-Preliminaries.html
; you may want to make sure you have your font-lock level set
sufficiently high.
> Thanks!
No problem; I look forward to seeing what endianness bugs you can squash
with this. :)
- Josh Triplett
More information about the systemd-devel
mailing list