Changeset 831aa466 in mainline for uspace/lib/usb/include


Ignore:
Timestamp:
2018-06-26T23:16:12Z (7 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2fc9bfd
Parents:
70fae4e
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-26 23:06:11)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-26 23:16:12)
Message:

Fix cases of undefined behavior found by ubsan.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/request.h

    r70fae4e r831aa466  
    7575#define USB_SETUP_PACKET_SIZE 8
    7676
    77 /** Device request setup packet.
    78  * The setup packet describes the request.
    79  */
    80 typedef struct {
    81         /** Request type.
    82          * The type combines transfer direction, request type and
    83          * intended recipient.
    84          */
    85         uint8_t request_type;
    8677#define SETUP_REQUEST_TYPE_DEVICE_TO_HOST (1 << 7)
    8778#define SETUP_REQUEST_TYPE_HOST_TO_DEVICE (0 << 7)
     
    9485    (uint8_t)(((type & 0x3) << 5) | (recipient & 0x1f))
    9586
    96         /** Request identification. */
    97         uint8_t request;
    98         /** Main parameter to the request. */
    99         union __attribute__((packed)) {
    100                 uint16_t value;
    101                 /* FIXME: add #ifdefs according to host endianness */
    102                 struct __attribute__((packed)) {
    103                         uint8_t value_low;
    104                         uint8_t value_high;
     87/** Device request setup packet.
     88 * The setup packet describes the request.
     89 */
     90typedef union {
     91        struct __attribute__((packed)) {
     92                /** Request type.
     93                 * The type combines transfer direction, request type and
     94                 * intended recipient.
     95                 */
     96                uint8_t request_type;
     97
     98                /** Request identification. */
     99                uint8_t request;
     100                /** Main parameter to the request. */
     101                union __attribute__((packed)) {
     102                        uint16_t value;
     103                        /* FIXME: add #ifdefs according to host endianness */
     104                        struct __attribute__((packed)) {
     105                                uint8_t value_low;
     106                                uint8_t value_high;
     107                        };
    105108                };
     109                /** Auxiliary parameter to the request.
     110                 * Typically, it is offset to something.
     111                 */
     112                uint16_t index;
     113                /** Length of extra data. */
     114                uint16_t length;
    106115        };
    107         /** Auxiliary parameter to the request.
    108          * Typically, it is offset to something.
    109          */
    110         uint16_t index;
    111         /** Length of extra data. */
    112         uint16_t length;
     116        uint64_t raw;
    113117} __attribute__((packed)) usb_device_request_setup_packet_t;
    114118
Note: See TracChangeset for help on using the changeset viewer.