Changeset b7fd2a0 in mainline for uspace/lib/usbdev/src/devdrv.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/devdrv.c

    r36f0738 rb7fd2a0  
    131131 * @return Error code.
    132132 */
    133 int usb_device_select_interface(usb_device_t *usb_dev,
     133errno_t usb_device_select_interface(usb_device_t *usb_dev,
    134134    uint8_t alternate_setting, const usb_endpoint_description_t **endpoints)
    135135{
     
    141141
    142142        /* Change the interface itself. */
    143         int rc = usb_request_set_interface(&usb_dev->ctrl_pipe,
     143        errno_t rc = usb_request_set_interface(&usb_dev->ctrl_pipe,
    144144            usb_dev->interface_no, alternate_setting);
    145145        if (rc != EOK) {
     
    165165 * @return Error code.
    166166 */
    167 static int usb_device_retrieve_descriptors(usb_device_t *usb_dev)
     167static errno_t usb_device_retrieve_descriptors(usb_device_t *usb_dev)
    168168{
    169169        assert(usb_dev);
     
    171171
    172172        /* Get the device descriptor. */
    173         int rc = usb_request_get_device_descriptor(&usb_dev->ctrl_pipe,
     173        errno_t rc = usb_request_get_device_descriptor(&usb_dev->ctrl_pipe,
    174174            &usb_dev->descriptors.device);
    175175        if (rc != EOK) {
     
    217217 * @return Error code.
    218218 */
    219 int usb_device_create_pipes(usb_device_t *usb_dev,
     219errno_t usb_device_create_pipes(usb_device_t *usb_dev,
    220220    const usb_endpoint_description_t **endpoints)
    221221{
     
    245245
    246246        /* Find the mapping from configuration descriptor. */
    247         int rc = usb_pipe_initialize_from_configuration(pipes, pipe_count,
     247        errno_t rc = usb_pipe_initialize_from_configuration(pipes, pipe_count,
    248248            usb_dev->descriptors.full_config,
    249249            usb_dev->descriptors.full_config_size,
     
    393393 * @return Error code.
    394394 */
    395 static int usb_device_init(usb_device_t *usb_dev, ddf_dev_t *ddf_dev,
     395static errno_t usb_device_init(usb_device_t *usb_dev, ddf_dev_t *ddf_dev,
    396396    const usb_endpoint_description_t **endpoints, const char **errstr_ptr,
    397397    devman_handle_t handle, int interface_no)
     
    420420        /* This pipe was registered by the hub driver,
    421421         * during device initialization. */
    422         int rc = usb_pipe_initialize_default_control(
     422        errno_t rc = usb_pipe_initialize_default_control(
    423423            &usb_dev->ctrl_pipe, usb_dev->bus_session);
    424424        if (rc != EOK) {
     
    457457}
    458458
    459 static int usb_device_get_info(async_sess_t *sess, devman_handle_t *handle,
     459static errno_t usb_device_get_info(async_sess_t *sess, devman_handle_t *handle,
    460460        int *iface_no)
    461461{
     
    467467                return EPARTY;
    468468       
    469         int ret = usb_get_my_device_handle(exch, handle);
     469        errno_t ret = usb_get_my_device_handle(exch, handle);
    470470        if (ret == EOK) {
    471471                ret = usb_get_my_interface(exch, iface_no);
     
    480480}
    481481
    482 int usb_device_create_ddf(ddf_dev_t *ddf_dev,
     482errno_t usb_device_create_ddf(ddf_dev_t *ddf_dev,
    483483    const usb_endpoint_description_t **desc, const char **err)
    484484{
     
    492492        if (sess == NULL)
    493493                return ENOMEM;
    494         const int ret = usb_device_get_info(sess, &h, &iface_no);
     494        const errno_t ret = usb_device_get_info(sess, &h, &iface_no);
    495495        if (ret != EOK)
    496496                return ret;
     
    521521
    522522        async_sess_t *sess = devman_device_connect(handle, IPC_FLAG_BLOCKING);
    523         int ret = usb_device_get_info(sess, &h, &iface_no);
     523        errno_t ret = usb_device_get_info(sess, &h, &iface_no);
    524524        if (sess)
    525525                async_hangup(sess);
Note: See TracChangeset for help on using the changeset viewer.