Changeset bdbb6f6 in mainline for uspace/drv/test1/test1.c


Ignore:
Timestamp:
2011-04-01T17:07:59Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ebcb05a
Parents:
cfc3027 (diff), 0864122 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~vojtech-horky/helenos/ddf-fixes

File:
1 edited

Legend:

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

    rcfc3027 rbdbb6f6  
    5959 */
    6060static int register_fun_verbose(ddf_dev_t *parent, const char *message,
    61     const char *name, const char *match_id, int match_score)
     61    const char *name, const char *match_id, int match_score,
     62    int expected_rc)
    6263{
    63         ddf_fun_t *fun;
     64        ddf_fun_t *fun = NULL;
    6465        int rc;
    6566
     
    6970        if (fun == NULL) {
    7071                ddf_msg(LVL_ERROR, "Failed creating function %s\n", name);
    71                 return ENOMEM;
     72                rc = ENOMEM;
     73                goto leave;
    7274        }
    7375
    74         rc = ddf_fun_add_match_id(fun, match_id, match_score);
     76        rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);
    7577        if (rc != EOK) {
    7678                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
    7779                    name);
    78                 ddf_fun_destroy(fun);
    79                 return rc;
     80                goto leave;
    8081        }
    8182
     
    8485                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    8586                    str_error(rc));
    86                 ddf_fun_destroy(fun);
    87                 return rc;
     87                goto leave;
    8888        }
    8989
    9090        ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name);
    91         return EOK;
     91        rc = EOK;
     92
     93leave:
     94        if (rc != expected_rc) {
     95                fprintf(stderr,
     96                    NAME ": Unexpected error registering function `%s'.\n"
     97                    NAME ":     Expected \"%s\" but got \"%s\".\n",
     98                    name, str_error(expected_rc), str_error(rc));
     99        }
     100
     101        if ((rc != EOK) && (fun != NULL)) {
     102                ddf_fun_destroy(fun);
     103        }
     104
     105        return rc;
    92106}
    93107
     
    135149                ddf_fun_add_to_class(fun_a, "virt-null");
    136150        } else if (str_cmp(dev->name, "test1") == 0) {
    137                 (void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
    138                     "virtual&test1", 10);
     151                (void) register_fun_verbose(dev,
     152                    "cloning myself ;-)", "clone",
     153                    "virtual&test1", 10, EOK);
     154                (void) register_fun_verbose(dev,
     155                    "cloning myself twice ;-)", "clone",
     156                    "virtual&test1", 10, EEXISTS);
    139157        } else if (str_cmp(dev->name, "clone") == 0) {
    140                 (void) register_fun_verbose(dev, "run by the same task", "child",
    141                     "virtual&test1&child", 10);
     158                (void) register_fun_verbose(dev,
     159                    "run by the same task", "child",
     160                    "virtual&test1&child", 10, EOK);
    142161        }
    143162
Note: See TracChangeset for help on using the changeset viewer.