Changeset 3fddb55 in mainline for uspace/drv/test1/test1.c
- Timestamp:
- 2011-03-30T13:20:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fc8c2b6
- Parents:
- 0876062
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/test1/test1.c
r0876062 r3fddb55 58 58 */ 59 59 static int register_fun_verbose(ddf_dev_t *parent, const char *message, 60 const char *name, const char *match_id, int match_score) 60 const char *name, const char *match_id, int match_score, 61 int expected_rc) 61 62 { 62 ddf_fun_t *fun ;63 ddf_fun_t *fun = NULL; 63 64 int rc; 64 65 … … 68 69 if (fun == NULL) { 69 70 printf(NAME ": error creating function %s\n", name); 70 return ENOMEM; 71 rc = ENOMEM; 72 goto leave; 71 73 } 72 74 73 rc = ddf_fun_add_match_id(fun, match_id, match_score);75 rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score); 74 76 if (rc != EOK) { 75 77 printf(NAME ": error adding match IDs to function %s\n", name); 76 ddf_fun_destroy(fun); 77 return rc; 78 goto leave; 78 79 } 79 80 … … 82 83 printf(NAME ": error binding function %s: %s\n", name, 83 84 str_error(rc)); 84 ddf_fun_destroy(fun); 85 return rc; 85 goto leave; 86 86 } 87 87 88 88 printf(NAME ": registered child device `%s'\n", name); 89 return EOK; 89 rc = EOK; 90 91 92 leave: 93 if (rc != expected_rc) { 94 fprintf(stderr, 95 NAME ": Unexpected error registering function `%s'.\n" \ 96 NAME ": Expected \"%s\" but got \"%s\".\n", 97 name, str_error(expected_rc), str_error(rc)); 98 } 99 100 if ((rc != EOK) && (fun != NULL)) { 101 ddf_fun_destroy(fun); 102 } 103 104 return rc; 90 105 } 91 106 … … 133 148 ddf_fun_add_to_class(fun_a, "virt-null"); 134 149 } else if (str_cmp(dev->name, "test1") == 0) { 135 (void) register_fun_verbose(dev, "cloning myself ;-)", "clone", 136 "virtual&test1", 10); 150 (void) register_fun_verbose(dev, 151 "cloning myself ;-)", "clone", 152 "virtual&test1", 10, EOK); 153 (void) register_fun_verbose(dev, 154 "cloning myself twice ;-)", "clone", 155 "virtual&test1", 10, EEXISTS); 137 156 } else if (str_cmp(dev->name, "clone") == 0) { 138 (void) register_fun_verbose(dev, "run by the same task", "child", 139 "virtual&test1&child", 10); 157 (void) register_fun_verbose(dev, 158 "run by the same task", "child", 159 "virtual&test1&child", 10, EOK); 140 160 } 141 161
Note:
See TracChangeset
for help on using the changeset viewer.