lkml.org 
[lkml]   [2023]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] iov_iter: Use __bitwise with the extraction_flags
    On Thu, Jan 26, 2023 at 10:33:50AM +0000, David Howells wrote:
    > X-Mailer: MH-E 8.6+git; nmh 1.7.1; GNU Emacs 28.2
    > --------
    > David Hildenbrand <david@redhat.com> wrote:
    >
    > > >> Just a note that the usage of new __bitwise types instead of "unsigned" is
    > > >> encouraged for flags.
    >
    > Something like the attached?
    >
    > > $ git grep "typedef int" | grep __bitwise | wc -l
    > > 27
    > > $ git grep "typedef unsigned" | grep __bitwise | wc -l
    > > 23
    >
    > git grep __bitwise | grep typedef | grep __u | wc -l
    > 62
    >
    > *shrug*
    >
    > Interestingly, things like __be32 are __bitwise. I wonder if that actually
    > makes sense or if it was just convenient so stop people doing arithmetic on
    > them. I guess doing AND/OR/XOR on them isn't a problem provided both
    > arguments are appropriately byte-swapped.

    Forget the words "byte-swapped". There are several data types.
    With different memory representations. Bitwise operations are
    valid between the values of the same type and yield the result
    of that same type.

    The fact that mapping between those representations happens to
    be an involution is an accident; keeping track of the number of
    times you've done a byteswap to the value currently in this
    variable is asking for trouble. It's really easy to fuck up.

    "Am I trying to store the value of type X in variable of type Y
    (presumably having forgotten that I need to use X_to_Y(...)
    to convert)" is much easier to keep track of.

    \
     
     \ /
      Last update: 2023-03-26 23:57    [W:2.555 / U:0.580 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site