Changeset b7fd2a0 in mainline for uspace/lib/usbdev/src/pipes.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipes.c

    r36f0738 rb7fd2a0  
    7474 * @return Error code.
    7575 */
    76 int usb_pipe_control_read(usb_pipe_t *pipe,
     76errno_t usb_pipe_control_read(usb_pipe_t *pipe,
    7777    const void *setup_buffer, size_t setup_buffer_size,
    7878    void *buffer, size_t buffer_size, size_t *transfered_size)
     
    9898        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    9999        size_t act_size = 0;
    100         const int rc = usb_read(exch, pipe->endpoint_no, setup_packet, buffer,
     100        const errno_t rc = usb_read(exch, pipe->endpoint_no, setup_packet, buffer,
    101101            buffer_size, &act_size);
    102102        async_exchange_end(exch);
     
    124124 * @return Error code.
    125125 */
    126 int usb_pipe_control_write(usb_pipe_t *pipe,
     126errno_t usb_pipe_control_write(usb_pipe_t *pipe,
    127127    const void *setup_buffer, size_t setup_buffer_size,
    128128    const void *buffer, size_t buffer_size)
     
    151151
    152152        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    153         const int rc = usb_write(exch,
     153        const errno_t rc = usb_write(exch,
    154154            pipe->endpoint_no, setup_packet, buffer, buffer_size);
    155155        async_exchange_end(exch);
     
    170170 * @return Error code.
    171171 */
    172 int usb_pipe_read(usb_pipe_t *pipe,
     172errno_t usb_pipe_read(usb_pipe_t *pipe,
    173173    void *buffer, size_t size, size_t *size_transfered)
    174174{
     
    198198        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    199199        size_t act_size = 0;
    200         const int rc =
     200        const errno_t rc =
    201201            usb_read(exch, pipe->endpoint_no, 0, buffer, size, &act_size);
    202202        async_exchange_end(exch);
     
    216216 * @return Error code.
    217217 */
    218 int usb_pipe_write(usb_pipe_t *pipe, const void *buffer, size_t size)
     218errno_t usb_pipe_write(usb_pipe_t *pipe, const void *buffer, size_t size)
    219219{
    220220        assert(pipe);
     
    238238
    239239        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    240         const int rc = usb_write(exch, pipe->endpoint_no, 0, buffer, size);
     240        const errno_t rc = usb_write(exch, pipe->endpoint_no, 0, buffer, size);
    241241        async_exchange_end(exch);
    242242        return rc;
     
    252252 * @return Error code.
    253253 */
    254 int usb_pipe_initialize(usb_pipe_t *pipe, usb_endpoint_t endpoint_no,
     254errno_t usb_pipe_initialize(usb_pipe_t *pipe, usb_endpoint_t endpoint_no,
    255255    usb_transfer_type_t transfer_type, size_t max_packet_size,
    256256    usb_direction_t direction, unsigned packets, usb_dev_session_t *bus_session)
     
    274274 * @return Error code.
    275275 */
    276 int usb_pipe_initialize_default_control(usb_pipe_t *pipe,
     276errno_t usb_pipe_initialize_default_control(usb_pipe_t *pipe,
    277277    usb_dev_session_t *bus_session)
    278278{
    279279        assert(pipe);
    280280
    281         const int rc = usb_pipe_initialize(pipe, 0, USB_TRANSFER_CONTROL,
     281        const errno_t rc = usb_pipe_initialize(pipe, 0, USB_TRANSFER_CONTROL,
    282282            CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, 1, bus_session);
    283283
     
    293293 * @return Error code.
    294294 */
    295 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval)
     295errno_t usb_pipe_register(usb_pipe_t *pipe, unsigned interval)
    296296{
    297297        assert(pipe);
     
    300300        if (!exch)
    301301                return ENOMEM;
    302         const int ret = usb_register_endpoint(exch, pipe->endpoint_no,
     302        const errno_t ret = usb_register_endpoint(exch, pipe->endpoint_no,
    303303            pipe->transfer_type, pipe->direction, pipe->max_packet_size,
    304304            pipe->packets, interval);
     
    312312 * @return Error code.
    313313 */
    314 int usb_pipe_unregister(usb_pipe_t *pipe)
     314errno_t usb_pipe_unregister(usb_pipe_t *pipe)
    315315{
    316316        assert(pipe);
     
    319319        if (!exch)
    320320                return ENOMEM;
    321         const int ret = usb_unregister_endpoint(exch, pipe->endpoint_no,
     321        const errno_t ret = usb_unregister_endpoint(exch, pipe->endpoint_no,
    322322            pipe->direction);
    323323        async_exchange_end(exch);
Note: See TracChangeset for help on using the changeset viewer.