Changeset 985e0f15 in mainline for uspace/lib/c/generic/rtld/module.c


Ignore:
Timestamp:
2019-05-18T21:42:02Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
87bc11f
Parents:
1e8b633
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-05-17 13:04:30)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-05-18 21:42:02)
Message:

Removing exit() from lib rtld

Several functions in the library rtld called
exit() from stdlib when an error occured. This
commit removes those calls and replace it with a
proper failure response

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/rtld/module.c

    r1e8b633 r985e0f15  
    187187        if (m == NULL) {
    188188                printf("malloc failed\n");
    189                 exit(1);
     189                goto error;
    190190        }
    191191
     
    198198        if (str_size(name) > NAME_BUF_SIZE - 2) {
    199199                printf("soname too long. increase NAME_BUF_SIZE\n");
    200                 exit(1);
     200                goto error;
    201201        }
    202202
     
    210210        if (rc != EE_OK) {
    211211                printf("Failed to load '%s'\n", name_buf);
    212                 exit(1);
     212                goto error;
    213213        }
    214214
     
    220220                printf("Error: '%s' is not a dynamically-linked object.\n",
    221221                    name_buf);
    222                 exit(1);
     222                goto error;
    223223        }
    224224
     
    243243
    244244        return m;
     245
     246error:
     247        if (m)
     248                free(m);
     249
     250        return NULL;
    245251}
    246252
    247253/** Load all modules on which m (transitively) depends.
    248254 */
    249 void module_load_deps(module_t *m, mlflags_t flags)
     255errno_t module_load_deps(module_t *m, mlflags_t flags)
    250256{
    251257        elf_dyn_t *dp;
     
    274280                /* There are no dependencies, so we are done. */
    275281                m->deps = NULL;
    276                 return;
     282                return EOK;
    277283        }
    278284
     
    280286        if (!m->deps) {
    281287                printf("malloc failed\n");
    282                 exit(1);
     288                return ENOMEM;
    283289        }
    284290
     
    294300                        if (!dm) {
    295301                                dm = module_load(m->rtld, dep_name, flags);
    296                                 module_load_deps(dm, flags);
     302                                errno_t rc = module_load_deps(dm, flags);
     303                                if (rc != EOK) {
     304                                        return rc;
     305                                }
    297306                        }
    298307
     
    302311                ++dp;
    303312        }
     313
     314        return EOK;
    304315}
    305316
Note: See TracChangeset for help on using the changeset viewer.