Changeset b7fd2a0 in mainline for uspace/lib/drv/generic/driver.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/drv/generic/driver.c

    r36f0738 rb7fd2a0  
    124124       
    125125        char *dev_name = NULL;
    126         int rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
     126        errno_t rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
    127127        if (rc != EOK) {
    128128                async_answer_0(iid, rc);
     
    157157        (void) parent_fun_handle;
    158158       
    159         int res = driver->driver_ops->dev_add(dev);
     159        errno_t res = driver->driver_ops->dev_add(dev);
    160160       
    161161        if (res != EOK) {
     
    189189        }
    190190       
    191         int rc;
     191        errno_t rc;
    192192       
    193193        if (driver->driver_ops->dev_remove != NULL)
     
    217217        }
    218218       
    219         int rc;
     219        errno_t rc;
    220220       
    221221        if (driver->driver_ops->dev_gone != NULL)
     
    253253       
    254254        /* Call driver entry point */
    255         int rc;
     255        errno_t rc;
    256256       
    257257        if (driver->driver_ops->fun_online != NULL)
     
    288288       
    289289        /* Call driver entry point */
    290         int rc;
     290        errno_t rc;
    291291       
    292292        if (driver->driver_ops->fun_offline != NULL)
     
    404404         */
    405405       
    406         int ret = EOK;
     406        errno_t ret = EOK;
    407407        /* Open device function */
    408408        if (fun->ops != NULL && fun->ops->open != NULL)
     
    666666 * @return      EOK on success, ENOMEM if out of memory
    667667 */
    668 int ddf_fun_set_name(ddf_fun_t *dev, const char *name)
     668errno_t ddf_fun_set_name(ddf_fun_t *dev, const char *name)
    669669{
    670670        assert(dev->name == NULL);
     
    815815 *
    816816 */
    817 int ddf_fun_bind(ddf_fun_t *fun)
     817errno_t ddf_fun_bind(ddf_fun_t *fun)
    818818{
    819819        assert(fun->bound == false);
     
    822822       
    823823        add_to_functions_list(fun);
    824         int res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
     824        errno_t res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
    825825            fun->dev->handle, &fun->handle);
    826826        if (res != EOK) {
     
    843843 *
    844844 */
    845 int ddf_fun_unbind(ddf_fun_t *fun)
     845errno_t ddf_fun_unbind(ddf_fun_t *fun)
    846846{
    847847        assert(fun->bound == true);
    848848       
    849         int res = devman_remove_function(fun->handle);
     849        errno_t res = devman_remove_function(fun->handle);
    850850        if (res != EOK)
    851851                return res;
     
    864864 *
    865865 */
    866 int ddf_fun_online(ddf_fun_t *fun)
     866errno_t ddf_fun_online(ddf_fun_t *fun)
    867867{
    868868        assert(fun->bound == true);
    869869       
    870         int res = devman_drv_fun_online(fun->handle);
     870        errno_t res = devman_drv_fun_online(fun->handle);
    871871        if (res != EOK)
    872872                return res;
     
    882882 *
    883883 */
    884 int ddf_fun_offline(ddf_fun_t *fun)
     884errno_t ddf_fun_offline(ddf_fun_t *fun)
    885885{
    886886        assert(fun->bound == true);
    887887       
    888         int res = devman_drv_fun_offline(fun->handle);
     888        errno_t res = devman_drv_fun_offline(fun->handle);
    889889        if (res != EOK)
    890890                return res;
     
    906906 *
    907907 */
    908 int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
     908errno_t ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
    909909    int match_score)
    910910{
     
    953953 *
    954954 */
    955 int ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name)
     955errno_t ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name)
    956956{
    957957        assert(fun->bound == true);
     
    974974         */
    975975        port_id_t port;
    976         int rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
     976        errno_t rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
    977977            NULL, &port);
    978978        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.