lkml.org 
[lkml]   [2009]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] byteorder: add load/store_{endian} API
From
Date
On Mon, 2009-03-02 at 16:15 -0800, Linus Torvalds wrote:
>
> On Mon, 2 Mar 2009, Harvey Harrison wrote:
> >
> > store_le16 is a new API and is added to be symmetric with the unaligned
> > functions.
>
> This seems to be expressly designed to be unsafe, in that it casts the
> thing to the right type, making it impossible for sparse to warn about
> bad byteorder use.
>

Unfortunately yes, hopefully you have a solution for the problem I ran
into with this part:

This was added to be symmetric with the unaligned store API, and replace
code doing

*(__le16 *)ptr = cpu_to_le16(val);

So existing code is casting already in most of the places this could be
used. And although this could be made a static inline and get the sparse
checking, we lose one of the big advantages of the open-coding - constants
are byteswapped at compile time. Although gcc (4.4) grew support for __builtin_constant_p
in static inlines, older gcc's don't, so we would lose that with essentially
all current compilers.

So the option was to make it a static inline and get the sparse checking, or
add the cast in the macro and lose sparse checking but preserve the compile-time
swapping...maybe I chose poorly.

Thoughts?

Harvey



\
 
 \ /
  Last update: 2009-03-03 01:29    [W:0.041 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site