Skip to content
  • Vaishali Thakkar's avatar
    e4504a15
    Staging: rtl8188eu: Use put_unaligned_le16 · e4504a15
    Vaishali Thakkar authored
    
    
    Using byte ordering functions and then memcpy() is risky and
    prone to hide errors which are hard to track down. So, this
    patch introduces the use of function put_unaligned_le16 which
    makes the code clear. Here, use of variable tim_bitmap_le
    and variable itself is removed. Also, to be compatible with the
    changes header file is added too.
    
    Coccinelle is used to do this change and semantic patch used for
    this is as follows:
    
    @a@
    typedef __le16;
    __le16 e16;
    identifier tmp;
    expression ptr;
    expression y,e;
    type T;
    @@
    
    - tmp = cpu_to_le16(y);
    
    <+... when != tmp
    (
    - memcpy(ptr, (T)&tmp, \(2\|sizeof(__le16)\|sizeof(e16)\));
    + put_unaligned_le16(y,ptr);
    |
    - memcpy(ptr, (T)&tmp, ...);
    + put_unaligned_le16(y,ptr);
    )
    ...+>
    ? tmp = e
    
    @@ type T; identifier a.tmp; @@
    
    - T tmp;
    ...when != tmp
    
    Signed-off-by: default avatarVaishali Thakkar <vthakkar1994@gmail.com>
    Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
    Reviewed-by: default avatarPreeti U Murthy <preeti@linux.vnet.ibm.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    e4504a15
    Staging: rtl8188eu: Use put_unaligned_le16
    Vaishali Thakkar authored
    
    
    Using byte ordering functions and then memcpy() is risky and
    prone to hide errors which are hard to track down. So, this
    patch introduces the use of function put_unaligned_le16 which
    makes the code clear. Here, use of variable tim_bitmap_le
    and variable itself is removed. Also, to be compatible with the
    changes header file is added too.
    
    Coccinelle is used to do this change and semantic patch used for
    this is as follows:
    
    @a@
    typedef __le16;
    __le16 e16;
    identifier tmp;
    expression ptr;
    expression y,e;
    type T;
    @@
    
    - tmp = cpu_to_le16(y);
    
    <+... when != tmp
    (
    - memcpy(ptr, (T)&tmp, \(2\|sizeof(__le16)\|sizeof(e16)\));
    + put_unaligned_le16(y,ptr);
    |
    - memcpy(ptr, (T)&tmp, ...);
    + put_unaligned_le16(y,ptr);
    )
    ...+>
    ? tmp = e
    
    @@ type T; identifier a.tmp; @@
    
    - T tmp;
    ...when != tmp
    
    Signed-off-by: default avatarVaishali Thakkar <vthakkar1994@gmail.com>
    Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
    Reviewed-by: default avatarPreeti U Murthy <preeti@linux.vnet.ibm.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Loading