Changes in uspace/lib/c/generic/rtld/module.c [1567471:a0e2f9c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/rtld/module.c
r1567471 ra0e2f9c 65 65 66 66 module = calloc(1, sizeof(module_t)); 67 if (module == NULL) 67 if (module == NULL) { 68 DPRINTF("malloc failed\n"); 68 69 return ENOMEM; 70 } 69 71 70 72 module->id = rtld_get_next_id(rtld); … … 182 184 char name_buf[NAME_BUF_SIZE]; 183 185 module_t *m; 184 int rc;186 errno_t rc; 185 187 186 188 m = calloc(1, sizeof(module_t)); 187 189 if (m == NULL) { 188 printf("malloc failed\n");189 exit(1);190 DPRINTF("malloc failed\n"); 191 goto error; 190 192 } 191 193 … … 197 199 198 200 if (str_size(name) > NAME_BUF_SIZE - 2) { 199 printf("soname too long. increase NAME_BUF_SIZE\n");200 exit(1);201 DPRINTF("soname too long. increase NAME_BUF_SIZE\n"); 202 goto error; 201 203 } 202 204 … … 208 210 209 211 rc = elf_load_file_name(name_buf, RTLD_MODULE_LDF, &info); 210 if (rc != E E_OK) {211 printf("Failed to load '%s'\n", name_buf);212 exit(1);212 if (rc != EOK) { 213 DPRINTF("Failed to load '%s'\n", name_buf); 214 goto error; 213 215 } 214 216 … … 218 220 219 221 if (info.dynamic == NULL) { 220 printf("Error: '%s' is not a dynamically-linked object.\n",222 DPRINTF("Error: '%s' is not a dynamically-linked object.\n", 221 223 name_buf); 222 exit(1);224 goto error; 223 225 } 224 226 … … 243 245 244 246 return m; 247 248 error: 249 if (m) 250 free(m); 251 252 return NULL; 245 253 } 246 254 247 255 /** Load all modules on which m (transitively) depends. 248 256 */ 249 voidmodule_load_deps(module_t *m, mlflags_t flags)257 errno_t module_load_deps(module_t *m, mlflags_t flags) 250 258 { 251 259 elf_dyn_t *dp; … … 274 282 /* There are no dependencies, so we are done. */ 275 283 m->deps = NULL; 276 return ;284 return EOK; 277 285 } 278 286 279 287 m->deps = malloc(n * sizeof(module_t *)); 280 288 if (!m->deps) { 281 printf("malloc failed\n");282 exit(1);289 DPRINTF("malloc failed\n"); 290 return ENOMEM; 283 291 } 284 292 … … 294 302 if (!dm) { 295 303 dm = module_load(m->rtld, dep_name, flags); 296 module_load_deps(dm, flags); 304 if (!dm) { 305 return EINVAL; 306 } 307 308 errno_t rc = module_load_deps(dm, flags); 309 if (rc != EOK) { 310 return rc; 311 } 297 312 } 298 313 … … 302 317 ++dp; 303 318 } 319 320 return EOK; 304 321 } 305 322
Note:
See TracChangeset
for help on using the changeset viewer.