Changeset a35b458 in mainline for uspace/srv/devman/match.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/match.c
r3061bc1 ra35b458 69 69 link_t *drv_head = &drv->match_ids.ids.head; 70 70 link_t *dev_head = &dev->pfun->match_ids.ids.head; 71 71 72 72 if (list_empty(&drv->match_ids.ids) || 73 73 list_empty(&dev->pfun->match_ids.ids)) { 74 74 return 0; 75 75 } 76 76 77 77 /* 78 78 * Go through all pairs, return the highest score obtained. 79 79 */ 80 80 int highest_score = 0; 81 81 82 82 link_t *drv_link = drv->match_ids.ids.head.next; 83 83 while (drv_link != drv_head) { … … 86 86 match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link); 87 87 match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link); 88 88 89 89 int score = compute_match_score(drv_id, dev_id); 90 90 if (score > highest_score) { … … 94 94 dev_link = dev_link->next; 95 95 } 96 96 97 97 drv_link = drv_link->next; 98 98 } 99 99 100 100 return highest_score; 101 101 } … … 111 111 char *res = NULL; 112 112 size_t len = get_nonspace_len(*buf); 113 113 114 114 if (len > 0) { 115 115 res = malloc(len + 1); … … 119 119 } 120 120 } 121 121 122 122 return res; 123 123 } … … 141 141 char *id = NULL; 142 142 int ids_read = 0; 143 143 144 144 while (true) { 145 145 /* skip spaces */ … … 151 151 continue; 152 152 } 153 153 154 154 /* read score */ 155 155 score = strtoul(buf, &buf, 10); 156 156 157 157 /* skip spaces */ 158 158 if (!skip_spaces(&buf)) 159 159 break; 160 160 161 161 /* read id */ 162 162 id = read_match_id(&buf); 163 163 if (NULL == id) 164 164 break; 165 165 166 166 /* create new match_id structure */ 167 167 match_id_t *mid = create_match_id(); 168 168 mid->id = id; 169 169 mid->score = score; 170 170 171 171 /* add it to the list */ 172 172 add_match_id(ids, mid); 173 173 174 174 ids_read++; 175 175 } 176 176 177 177 return ids_read > 0; 178 178 } … … 194 194 { 195 195 log_msg(LOG_DEFAULT, LVL_DEBUG, "read_match_ids(conf_path=\"%s\")", conf_path); 196 196 197 197 bool suc = false; 198 198 char *buf = NULL; … … 201 201 size_t len = 0; 202 202 vfs_stat_t st; 203 203 204 204 errno_t rc = vfs_lookup_open(conf_path, WALK_REGULAR, MODE_READ, &fd); 205 205 if (rc != EOK) { … … 209 209 } 210 210 opened = true; 211 211 212 212 rc = vfs_stat(fd, &st); 213 213 if (rc != EOK) { … … 222 222 goto cleanup; 223 223 } 224 224 225 225 buf = malloc(len + 1); 226 226 if (buf == NULL) { … … 229 229 goto cleanup; 230 230 } 231 231 232 232 size_t read_bytes; 233 233 rc = vfs_read(fd, (aoff64_t []) {0}, buf, len, &read_bytes); … … 238 238 } 239 239 buf[read_bytes] = 0; 240 240 241 241 suc = parse_match_ids(buf, ids); 242 242 243 243 cleanup: 244 244 free(buf); 245 245 246 246 if (opened) 247 247 vfs_put(fd); 248 248 249 249 return suc; 250 250 }
Note:
See TracChangeset
for help on using the changeset viewer.