Ignore:
File:
1 edited

Legend:

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

    rebcb05a rfc51296  
    5959 */
    6060static int register_fun_verbose(ddf_dev_t *parent, const char *message,
    61     const char *name, const char *match_id, int match_score,
    62     int expected_rc)
     61    const char *name, const char *match_id, int match_score)
    6362{
    64         ddf_fun_t *fun = NULL;
     63        ddf_fun_t *fun;
    6564        int rc;
    6665
    67         ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
     66        ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message);
    6867
    6968        fun = ddf_fun_create(parent, fun_inner, name);
    7069        if (fun == NULL) {
    71                 ddf_msg(LVL_ERROR, "Failed creating function %s", name);
    72                 rc = ENOMEM;
    73                 goto leave;
     70                ddf_msg(LVL_ERROR, "Failed creating function %s\n", name);
     71                return ENOMEM;
    7472        }
    7573
    76         rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);
     74        rc = ddf_fun_add_match_id(fun, match_id, match_score);
    7775        if (rc != EOK) {
    78                 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
     76                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
    7977                    name);
    80                 goto leave;
     78                ddf_fun_destroy(fun);
     79                return rc;
    8180        }
    8281
    8382        rc = ddf_fun_bind(fun);
    8483        if (rc != EOK) {
    85                 ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
     84                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    8685                    str_error(rc));
    87                 goto leave;
     86                ddf_fun_destroy(fun);
     87                return rc;
    8888        }
    8989
    90         ddf_msg(LVL_NOTE, "Registered child device `%s'", name);
    91         rc = EOK;
    92 
    93 leave:
    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;
     90        ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name);
     91        return EOK;
    10692}
    10793
     
    128114        int rc;
    129115
    130         ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)",
     116        ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)\n",
    131117            dev->name, (int) dev->handle);
    132118
    133119        fun_a = ddf_fun_create(dev, fun_exposed, "a");
    134120        if (fun_a == NULL) {
    135                 ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
     121                ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n");
    136122                return ENOMEM;
    137123        }
     
    139125        rc = ddf_fun_bind(fun_a);
    140126        if (rc != EOK) {
    141                 ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
     127                ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n");
    142128                return rc;
    143129        }
     
    149135                ddf_fun_add_to_class(fun_a, "virt-null");
    150136        } else if (str_cmp(dev->name, "test1") == 0) {
    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);
     137                (void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
     138                    "virtual&test1", 10);
    157139        } else if (str_cmp(dev->name, "clone") == 0) {
    158                 (void) register_fun_verbose(dev,
    159                     "run by the same task", "child",
    160                     "virtual&test1&child", 10, EOK);
     140                (void) register_fun_verbose(dev, "run by the same task", "child",
     141                    "virtual&test1&child", 10);
    161142        }
    162143
    163         ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev->name);
     144        ddf_msg(LVL_DEBUG, "Device `%s' accepted.\n", dev->name);
    164145
    165146        return EOK;
Note: See TracChangeset for help on using the changeset viewer.