Changeset b7fd2a0 in mainline for uspace/drv/test


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 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.

Location:
uspace/drv/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/test/test1/test1.c

    r36f0738 rb7fd2a0  
    4040#include "test1.h"
    4141
    42 static int test1_dev_add(ddf_dev_t *dev);
    43 static int test1_dev_remove(ddf_dev_t *dev);
    44 static int test1_dev_gone(ddf_dev_t *dev);
    45 static int test1_fun_online(ddf_fun_t *fun);
    46 static int test1_fun_offline(ddf_fun_t *fun);
     42static errno_t test1_dev_add(ddf_dev_t *dev);
     43static errno_t test1_dev_remove(ddf_dev_t *dev);
     44static errno_t test1_dev_gone(ddf_dev_t *dev);
     45static errno_t test1_fun_online(ddf_fun_t *fun);
     46static errno_t test1_fun_offline(ddf_fun_t *fun);
    4747
    4848static driver_ops_t driver_ops = {
     
    7373 * @param score Device match score.
    7474 */
    75 static int register_fun_verbose(ddf_dev_t *parent, const char *message,
     75static errno_t register_fun_verbose(ddf_dev_t *parent, const char *message,
    7676    const char *name, const char *match_id, int match_score,
    77     int expected_rc, ddf_fun_t **pfun)
     77    errno_t expected_rc, ddf_fun_t **pfun)
    7878{
    7979        ddf_fun_t *fun = NULL;
    80         int rc;
     80        errno_t rc;
    8181
    8282        ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
     
    141141 * @return Error code reporting success of the operation.
    142142 */
    143 static int test1_dev_add(ddf_dev_t *dev)
     143static errno_t test1_dev_add(ddf_dev_t *dev)
    144144{
    145145        ddf_fun_t *fun_a;
    146146        test1_t *test1;
    147147        const char *dev_name;
    148         int rc;
     148        errno_t rc;
    149149
    150150        dev_name = ddf_dev_get_name(dev);
     
    196196}
    197197
    198 static int fun_remove(ddf_fun_t *fun, const char *name)
    199 {
    200         int rc;
     198static errno_t fun_remove(ddf_fun_t *fun, const char *name)
     199{
     200        errno_t rc;
    201201
    202202        ddf_msg(LVL_DEBUG, "fun_remove(%p, '%s')", fun, name);
     
    217217}
    218218
    219 static int fun_unbind(ddf_fun_t *fun, const char *name)
    220 {
    221         int rc;
     219static errno_t fun_unbind(ddf_fun_t *fun, const char *name)
     220{
     221        errno_t rc;
    222222
    223223        ddf_msg(LVL_DEBUG, "fun_unbind(%p, '%s')", fun, name);
     
    232232}
    233233
    234 static int test1_dev_remove(ddf_dev_t *dev)
     234static errno_t test1_dev_remove(ddf_dev_t *dev)
    235235{
    236236        test1_t *test1 = (test1_t *)ddf_dev_data_get(dev);
    237         int rc;
     237        errno_t rc;
    238238
    239239        ddf_msg(LVL_DEBUG, "test1_dev_remove(%p)", dev);
     
    260260}
    261261
    262 static int test1_dev_gone(ddf_dev_t *dev)
     262static errno_t test1_dev_gone(ddf_dev_t *dev)
    263263{
    264264        test1_t *test1 = (test1_t *)ddf_dev_data_get(dev);
    265         int rc;
     265        errno_t rc;
    266266
    267267        ddf_msg(LVL_DEBUG, "test1_dev_remove(%p)", dev);
     
    288288}
    289289
    290 static int test1_fun_online(ddf_fun_t *fun)
     290static errno_t test1_fun_online(ddf_fun_t *fun)
    291291{
    292292        ddf_msg(LVL_DEBUG, "test1_fun_online()");
     
    294294}
    295295
    296 static int test1_fun_offline(ddf_fun_t *fun)
     296static errno_t test1_fun_offline(ddf_fun_t *fun)
    297297{
    298298        ddf_msg(LVL_DEBUG, "test1_fun_offline()");
  • uspace/drv/test/test2/test2.c

    r36f0738 rb7fd2a0  
    4040#define NAME "test2"
    4141
    42 static int test2_dev_add(ddf_dev_t *dev);
    43 static int test2_dev_remove(ddf_dev_t *dev);
    44 static int test2_dev_gone(ddf_dev_t *dev);
    45 static int test2_fun_online(ddf_fun_t *fun);
    46 static int test2_fun_offline(ddf_fun_t *fun);
     42static errno_t test2_dev_add(ddf_dev_t *dev);
     43static errno_t test2_dev_remove(ddf_dev_t *dev);
     44static errno_t test2_dev_gone(ddf_dev_t *dev);
     45static errno_t test2_fun_online(ddf_fun_t *fun);
     46static errno_t test2_fun_offline(ddf_fun_t *fun);
    4747
    4848static driver_ops_t driver_ops = {
     
    7777 * @param score Device match score.
    7878 */
    79 static int register_fun_verbose(ddf_dev_t *parent, const char *message,
     79static errno_t register_fun_verbose(ddf_dev_t *parent, const char *message,
    8080    const char *name, const char *match_id, int match_score, ddf_fun_t **pfun)
    8181{
    8282        ddf_fun_t *fun;
    83         int rc;
     83        errno_t rc;
    8484
    8585        ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
     
    118118 * @return Always EOK.
    119119 */
    120 static int plug_unplug(void *arg)
     120static errno_t plug_unplug(void *arg)
    121121{
    122122        test2_t *test2 = (test2_t *) arg;
    123123        ddf_fun_t *fun_a;
    124         int rc;
     124        errno_t rc;
    125125
    126126        async_usleep(1000);
     
    157157}
    158158
    159 static int fun_remove(ddf_fun_t *fun, const char *name)
    160 {
    161         int rc;
     159static errno_t fun_remove(ddf_fun_t *fun, const char *name)
     160{
     161        errno_t rc;
    162162
    163163        ddf_msg(LVL_DEBUG, "fun_remove(%p, '%s')", fun, name);
     
    178178}
    179179
    180 static int fun_unbind(ddf_fun_t *fun, const char *name)
    181 {
    182         int rc;
     180static errno_t fun_unbind(ddf_fun_t *fun, const char *name)
     181{
     182        errno_t rc;
    183183
    184184        ddf_msg(LVL_DEBUG, "fun_unbind(%p, '%s')", fun, name);
     
    193193}
    194194
    195 static int test2_dev_add(ddf_dev_t *dev)
     195static errno_t test2_dev_add(ddf_dev_t *dev)
    196196{
    197197        test2_t *test2;
     
    224224}
    225225
    226 static int test2_dev_remove(ddf_dev_t *dev)
     226static errno_t test2_dev_remove(ddf_dev_t *dev)
    227227{
    228228        test2_t *test2 = (test2_t *)ddf_dev_data_get(dev);
    229         int rc;
     229        errno_t rc;
    230230
    231231        ddf_msg(LVL_DEBUG, "test2_dev_remove(%p)", dev);
     
    258258}
    259259
    260 static int test2_dev_gone(ddf_dev_t *dev)
     260static errno_t test2_dev_gone(ddf_dev_t *dev)
    261261{
    262262        test2_t *test2 = (test2_t *)ddf_dev_data_get(dev);
    263         int rc;
     263        errno_t rc;
    264264
    265265        ddf_msg(LVL_DEBUG, "test2_dev_gone(%p)", dev);
     
    293293
    294294
    295 static int test2_fun_online(ddf_fun_t *fun)
     295static errno_t test2_fun_online(ddf_fun_t *fun)
    296296{
    297297        ddf_msg(LVL_DEBUG, "test2_fun_online()");
     
    299299}
    300300
    301 static int test2_fun_offline(ddf_fun_t *fun)
     301static errno_t test2_fun_offline(ddf_fun_t *fun)
    302302{
    303303        ddf_msg(LVL_DEBUG, "test2_fun_offline()");
  • uspace/drv/test/test3/test3.c

    r36f0738 rb7fd2a0  
    4141#define NUM_FUNCS 20
    4242
    43 static int test3_dev_add(ddf_dev_t *dev);
    44 static int test3_dev_remove(ddf_dev_t *dev);
    45 static int test3_fun_online(ddf_fun_t *fun);
    46 static int test3_fun_offline(ddf_fun_t *fun);
     43static errno_t test3_dev_add(ddf_dev_t *dev);
     44static errno_t test3_dev_remove(ddf_dev_t *dev);
     45static errno_t test3_fun_online(ddf_fun_t *fun);
     46static errno_t test3_fun_offline(ddf_fun_t *fun);
    4747
    4848static driver_ops_t driver_ops = {
     
    6363} test3_t;
    6464
    65 static int register_fun_and_add_to_category(ddf_dev_t *parent,
     65static errno_t register_fun_and_add_to_category(ddf_dev_t *parent,
    6666    const char *base_name, size_t index, const char *class_name,
    6767    ddf_fun_t **pfun)
    6868{
    6969        ddf_fun_t *fun = NULL;
    70         int rc;
     70        errno_t rc;
    7171        char *fun_name = NULL;
    7272       
     
    106106}
    107107
    108 static int fun_remove(ddf_fun_t *fun, const char *name)
     108static errno_t fun_remove(ddf_fun_t *fun, const char *name)
    109109{
    110         int rc;
     110        errno_t rc;
    111111
    112112        ddf_msg(LVL_DEBUG, "fun_remove(%p, '%s')", fun, name);
     
    127127}
    128128
    129 static int test3_dev_add(ddf_dev_t *dev)
     129static errno_t test3_dev_add(ddf_dev_t *dev)
    130130{
    131         int rc = EOK;
     131        errno_t rc = EOK;
    132132        test3_t *test3;
    133133
     
    153153}
    154154
    155 static int test3_dev_remove(ddf_dev_t *dev)
     155static errno_t test3_dev_remove(ddf_dev_t *dev)
    156156{
    157157        test3_t *test3 = (test3_t *)ddf_dev_data_get(dev);
    158158        char *fun_name;
    159         int rc;
     159        errno_t rc;
    160160        size_t i;
    161161
     
    176176}
    177177
    178 static int test3_fun_online(ddf_fun_t *fun)
     178static errno_t test3_fun_online(ddf_fun_t *fun)
    179179{
    180180        ddf_msg(LVL_DEBUG, "test3_fun_online()");
     
    182182}
    183183
    184 static int test3_fun_offline(ddf_fun_t *fun)
     184static errno_t test3_fun_offline(ddf_fun_t *fun)
    185185{
    186186        ddf_msg(LVL_DEBUG, "test3_fun_offline()");
Note: See TracChangeset for help on using the changeset viewer.