[apparmor] [patch 18/26] Convert to htoleXX fns instead of ifdef on endian
Tyler Hicks
tyhicks at canonical.com
Sat Mar 29 23:17:58 UTC 2014
On 2014-03-29 02:26:34, John Johansen wrote:
> On 03/28/2014 08:52 AM, Tyler Hicks wrote:
> > On 2014-03-27 08:45:31, john.johansen at canonical.com wrote:
> >> This patch makes use of the htoleXX() functions (see endian(3))
> >> defined as part of endian.h (already included in parser_interface.c),
> >> instead of defining a function differently based on the detection of
> >> endian related macros.
> >>
> >> This fixes a build failure experienced on powerpc with John's patch
> >> set applied. This patch has been updated with John's feedback to use
> >> letoh16() in the le16_to_cpu() macro.
> >>
> >>
> >> Signed-off-by: Steve Beattie <steve at nxnw.org>
> >> Acked-by: John Johansen <john.johansen at canonical.com>
> >> ---
> >> parser/parser.h | 15 ++++++---------
> >> parser/parser_interface.c | 3 ---
> >> parser/parser_main.c | 6 +-----
> >> 3 files changed, 7 insertions(+), 17 deletions(-)
> >>
> >> --- 2.9-test.orig/parser/parser.h
> >> +++ 2.9-test/parser/parser.h
> >> @@ -23,9 +23,11 @@
> >> #define __AA_PARSER_H
> >>
> >>
> >> +#include <endian.h>
> >> #include <string.h>
> >> #include <netinet/in.h>
> >> #include <sys/resource.h>
> >> +
> >> #include "immunix.h"
> >> #include "libapparmor_re/apparmor_re.h"
> >> #include "libapparmor_re/aare_rules.h"
> >> @@ -258,15 +260,10 @@
> >> #define u16 uint16_t
> >> #define u32 uint32_t
> >> #define u64 uint64_t
> >> -#if __BYTE_ORDER == __BIG_ENDIAN
> >> -# define cpu_to_le16(x) ((u16)(bswap_16 ((u16) x)))
> >> -# define cpu_to_le32(x) ((u32)(bswap_32 ((u32) x)))
> >> -# define cpu_to_le64(x) ((u64)(bswap_64 ((u64) x)))
> >> -#else
> >> -# define cpu_to_le16(x) ((u16)(x))
> >> -# define cpu_to_le32(x) ((u32)(x))
> >> -# define cpu_to_le64(x) ((u64)(x))
> >> -#endif
> >> +
> >> +#define cpu_to_le16(x) ((u16)(htole16 ((u16) x)))
> >> +#define cpu_to_le32(x) ((u32)(htole32 ((u32) x)))
> >> +#define cpu_to_le64(x) ((u64)(htole64 ((u64) x)))
> >>
> >> /* The encoding for kernal abi > 5 is
> >> * 28-31: reserved
> >> --- 2.9-test.orig/parser/parser_interface.c
> >> +++ 2.9-test/parser/parser_interface.c
> >> @@ -37,9 +37,6 @@
> >> #include <unistd.h>
> >> #include <linux/unistd.h>
> >>
> >> -/* only for x86 at the moment */
> >> -#include <endian.h>
> >> -#include <byteswap.h>
> >> #include <libintl.h>
> >> #define _(s) gettext(s)
> >>
> >> --- 2.9-test.orig/parser/parser_main.c
> >> +++ 2.9-test/parser/parser_main.c
> >> @@ -946,11 +946,7 @@
> >> return rc;
> >> }
> >>
> >> -#if __BYTE_ORDER == __BIG_ENDIAN
> >> -# define le16_to_cpu(x) ((uint16_t)(bswap_16 (*(uint16_t *) x)))
> >> -#else
> >> -# define le16_to_cpu(x) (*(uint16_t *)(x))
> >> -#endif
> >> +#define le16_to_cpu(x) ((uint16_t)(letoh16 (*(uint16_t *) x)))
> >
> > You didn't pick up your feedback from the original thread. This should
> > be le16toh().
> >
> err? it is.
>
> Quadruple checked in my queue and then here. Steve's patch used to use
> htole16
Ah, sorry for the confusion. Now I see what happened...
You *did* change it from Steve's patch that used htole16(), but the new
function name isn't right. It is letoh16() in your patch and it should
be le16toh().
>
> > https://lists.ubuntu.com/archives/apparmor/2014-March/005411.html
> >
> > On a related note, we need to start getting some of this patch set acked
> > and committed upstream or this is going to happen more often.
> >
> yes, I have pushed any of the earlier ones that have been acked up, but
> I haven't tried bubbling up the later ones that have been acked, even
> though several of them probably could be.
>
> The big problem is that first patch in the queue is a bear (or so I hear,
> /me wonders what is going to happen when the real bears hit), and people
> are going to need some time to tackle it.
Heh... After sending out this email, I set out to solve this problem and
then realized how big patch 1 is. :)
Tyler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140329/4ecf162b/attachment.pgp>
More information about the AppArmor
mailing list