Changeset 25697163 in mainline


Ignore:
Timestamp:
2019-10-06T19:47:15Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
9559cf8
Parents:
102f641
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-09-06 17:58:36)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-10-06 19:47:15)
Message:

Replacing int with errno_t

The merged code from system-daemon still used the type int
for indicating an error instead of using errno_t. This
commit corrects this mistake

Location:
uspace
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/dyn_array.c

    r102f641 r25697163  
    4444#include <stdlib.h>
    4545
    46 static int dyn_array_realloc(dyn_array_t *da, size_t capacity)
     46static errno_t dyn_array_realloc(dyn_array_t *da, size_t capacity)
    4747{
    4848        if (capacity == da->capacity) {
     
    7070        assert(index < da->size);
    7171        _dyn_array_unshift(da, index, 1);
    72         int rc = dyn_array_reserve(da, da->size);
     72        errno_t rc = dyn_array_reserve(da, da->size);
    7373        assert(rc == EOK);
    7474}
     
    9292
    9393        _dyn_array_unshift(da, begin, end - begin);
    94         int rc = dyn_array_reserve(da, da->size);
     94        errno_t rc = dyn_array_reserve(da, da->size);
    9595        assert(rc == EOK);
    9696}
     
    104104 * @return ENOMEM when allocation fails
    105105 */
    106 int dyn_array_concat(dyn_array_t *da1, dyn_array_t *da2)
     106errno_t dyn_array_concat(dyn_array_t *da1, dyn_array_t *da2)
    107107{
    108108        assert(da1->_item_size == da2->_item_size);
    109109
    110         int rc = dyn_array_reserve(da1, da1->size + da2->size);
     110        errno_t rc = dyn_array_reserve(da1, da1->size + da2->size);
    111111        if (rc != EOK) {
    112112                return rc;
     
    129129 * @return ENOMEM
    130130 */
    131 int dyn_array_reserve(dyn_array_t *da, size_t capacity)
     131errno_t dyn_array_reserve(dyn_array_t *da, size_t capacity)
    132132{
    133133        const size_t factor = 2;
  • uspace/lib/c/include/adt/dyn_array.h

    r102f641 r25697163  
    3636#define LIBC_DYN_ARRAY_H_
    3737
     38#include <errno.h>
    3839#include <stdbool.h>
    3940#include <stddef.h>
     
    8384        size_t _index = (index);                                               \
    8485        dyn_array_t *_da = (dyn_array);                                        \
    85         int rc = dyn_array_reserve(_da, _da->size + 1);                        \
     86        errno_t rc = dyn_array_reserve(_da, _da->size + 1);                        \
    8687        if (!rc) {                                                             \
    8788                _dyn_array_shift(_da, _index, 1);                              \
     
    134135void dyn_array_clear(dyn_array_t *);
    135136void dyn_array_clear_range(dyn_array_t *, size_t, size_t);
    136 extern int dyn_array_concat(dyn_array_t *, dyn_array_t *);
    137 extern int dyn_array_reserve(dyn_array_t *, size_t);
     137extern errno_t dyn_array_concat(dyn_array_t *, dyn_array_t *);
     138extern errno_t dyn_array_reserve(dyn_array_t *, size_t);
    138139
    139140extern void _dyn_array_initialize(dyn_array_t *, size_t);
  • uspace/lib/c/include/taskman_noasync.h

    r102f641 r25697163  
    3737
    3838/* Internal functions to be used by NS only */
    39 extern int taskman_intro_ns_noasync(void);
     39extern errno_t taskman_intro_ns_noasync(void);
    4040
    4141extern void task_retval_noasync(int);
  • uspace/lib/c/test/dyn_array.c

    r102f641 r25697163  
    4141{
    4242        dyn_array_initialize(&da, data_t);
    43         int rc = dyn_array_reserve(&da, 3);
     43        errno_t rc = dyn_array_reserve(&da, 3);
    4444        assert(rc == EOK);
    4545}
  • uspace/srv/sysman/connection_broker.c

    r102f641 r25697163  
    6060        sysarg_t retval;
    6161
    62         int rc = async_data_write_accept((void **) &unit_name, true,
     62        errno_t rc = async_data_write_accept((void **) &unit_name, true,
    6363            0, 0, 0, NULL);
    6464        if (rc != EOK) {
     
    8989
    9090        /* Just accept data and further not supported. */
    91         int rc = async_data_write_accept((void **) &exposee, true,
     91        errno_t rc = async_data_write_accept((void **) &exposee, true,
    9292            0, 0, 0, NULL);
    9393        if (rc != EOK) {
  • uspace/srv/sysman/connection_ctl.c

    r102f641 r25697163  
    7070        sysarg_t retval;
    7171
    72         int rc = async_data_write_accept((void **) &unit_name, true,
     72        errno_t rc = async_data_write_accept((void **) &unit_name, true,
    7373            0, 0, 0, NULL);
    7474        if (rc != EOK) {
     
    9797        sysarg_t retval;
    9898
    99         int rc = async_data_write_accept((void **) &unit_name, true,
     99        errno_t rc = async_data_write_accept((void **) &unit_name, true,
    100100            0, 0, 0, NULL);
    101101        if (rc != EOK) {
     
    186186}
    187187
    188 static int fill_handles_buffer(unit_handle_t *buffer, size_t size,
     188static errno_t fill_handles_buffer(unit_handle_t *buffer, size_t size,
    189189    size_t *act_size)
    190190{
     
    213213        size_t size;
    214214        size_t act_size;
    215         int rc;
     215        errno_t rc;
    216216
    217217        if (!async_data_read_receive(&call, &size)) {
  • uspace/srv/sysman/edge.c

    r102f641 r25697163  
    7777}
    7878
    79 int edge_sprout_out(unit_t *input, const char *output_name)
     79errno_t edge_sprout_out(unit_t *input, const char *output_name)
    8080{
    81         int rc;
     81        errno_t rc;
    8282        unit_edge_t *e = edge_create();
    8383
     
    123123 * @return        EEXIST
    124124 */
    125 int edge_connect(unit_t *input, unit_t *output)
     125errno_t edge_connect(unit_t *input, unit_t *output)
    126126{
    127127        if (edge_extract_internal(input, output)) {
  • uspace/srv/sysman/edge.h

    r102f641 r25697163  
    6565extern void edge_destroy(unit_edge_t **);
    6666
    67 extern int edge_sprout_out(unit_t *, const char *);
     67extern errno_t edge_sprout_out(unit_t *, const char *);
    6868extern void edge_resolve_output(unit_edge_t *, unit_t *);
    6969
    70 extern int edge_connect(unit_t *, unit_t *);
     70extern errno_t edge_connect(unit_t *, unit_t *);
    7171extern void edge_remove(unit_edge_t **);
    7272
  • uspace/srv/sysman/job.c

    r102f641 r25697163  
    198198        }
    199199
    200         int rc;
     200        errno_t rc;
    201201        // TODO put here similar evaluation as in job_check
    202202        //      goal is to have job_run "idempotent"
  • uspace/srv/sysman/job_closure.c

    r102f641 r25697163  
    5151         * return result of visit (error stops further traversal)
    5252         */
    53         int (*visit)(unit_t *, unit_edge_t *, bfs_ops_t *, void *);
     53        errno_t (*visit)(unit_t *, unit_edge_t *, bfs_ops_t *, void *);
    5454
    5555        /** Clean units remaining in BFS queue after error */
     
    6161 */
    6262
    63 static int job_add_blocked_job(job_t *blocking_job, job_t *blocked_job)
     63static errno_t job_add_blocked_job(job_t *blocking_job, job_t *blocked_job)
    6464{
    6565        assert(blocking_job->blocked_jobs.size ==
    6666            blocking_job->blocked_jobs_count);
    6767
    68         int rc = dyn_array_append(&blocking_job->blocked_jobs, job_t *,
     68        errno_t rc = dyn_array_append(&blocking_job->blocked_jobs, job_t *,
    6969            blocked_job);
    7070        if (rc != EOK) {
     
    8686 * @return EOK on success
    8787 */
    88 static int visit_propagate_job(unit_t *u, unit_edge_t *e, bfs_ops_t *ops,
     88static errno_t visit_propagate_job(unit_t *u, unit_edge_t *e, bfs_ops_t *ops,
    8989    void *arg)
    9090{
    91         int rc = EOK;
     91        errno_t rc = EOK;
    9292        job_t *created_job = NULL;
    9393        job_closure_t *closure = arg;
     
    138138}
    139139
    140 static int visit_isolate(unit_t *u, unit_edge_t *e, bfs_ops_t *ops, void *arg)
    141 {
    142         int rc = EOK;
     140static errno_t visit_isolate(unit_t *u, unit_edge_t *e, bfs_ops_t *ops, void *arg)
     141{
     142        errno_t rc = EOK;
    143143        job_t *created_job = NULL;
    144144        job_closure_t *closure = arg;
     
    187187}
    188188
    189 static int bfs_traverse_component_internal(unit_t *origin, bfs_ops_t *ops,
     189static errno_t bfs_traverse_component_internal(unit_t *origin, bfs_ops_t *ops,
    190190    void *arg)
    191191{
    192         int rc;
     192        errno_t rc;
    193193        list_t units_fifo;
    194194        list_initialize(&units_fifo);
     
    247247}
    248248
    249 static int bfs_traverse_component(unit_t *origin, bfs_ops_t *ops, void *arg)
     249static errno_t bfs_traverse_component(unit_t *origin, bfs_ops_t *ops, void *arg)
    250250{
    251251        /* Check invariant */
     
    253253                assert(u->bfs_tag == false);
    254254        }
    255         int rc = bfs_traverse_component_internal(origin, ops, arg);
     255        errno_t rc = bfs_traverse_component_internal(origin, ops, arg);
    256256
    257257        /* Clean after ourselves (BFS tag jobs) */
     
    262262}
    263263
    264 static int bfs_traverse_all(bfs_ops_t *ops, void *arg)
     264static errno_t bfs_traverse_all(bfs_ops_t *ops, void *arg)
    265265{
    266266        /* Check invariant */
     
    268268                assert(u->bfs_tag == false);
    269269        }
    270         int rc = EOK;
     270        errno_t rc = EOK;
    271271
    272272        repo_foreach(origin) {
     
    299299 * @return EOK on success otherwise propagated error
    300300 */
    301 int job_create_closure(job_t *main_job, job_closure_t *job_closure, int flags)
     301errno_t job_create_closure(job_t *main_job, job_closure_t *job_closure, int flags)
    302302{
    303303        sysman_log(LVL_DEBUG2, "%s(%s)", __func__, unit_name(main_job->unit));
     
    308308        }
    309309
    310         int rc = dyn_array_append(job_closure, job_t *, main_job);
     310        errno_t rc = dyn_array_append(job_closure, job_t *, main_job);
    311311        if (rc != EOK) {
    312312                return rc;
  • uspace/srv/sysman/job_closure.h

    r102f641 r25697163  
    3838typedef dyn_array_t job_closure_t;
    3939
    40 extern int job_create_closure(job_t *, job_closure_t *, int);
     40extern errno_t job_create_closure(job_t *, job_closure_t *, int);
    4141
    4242#endif
  • uspace/srv/sysman/job_queue.c

    r102f641 r25697163  
    103103 * @return error code on fail
    104104 */
    105 static int job_pre_merge(job_t *trunk, job_t *other)
     105static errno_t job_pre_merge(job_t *trunk, job_t *other)
    106106{
    107107        assert(trunk->unit == other->unit);
     
    110110        assert(other->merged_into == NULL);
    111111
    112         int rc = dyn_array_concat(&trunk->blocked_jobs, &other->blocked_jobs);
     112        errno_t rc = dyn_array_concat(&trunk->blocked_jobs, &other->blocked_jobs);
    113113        if (rc != EOK) {
    114114                return rc;
     
    134134         */
    135135        size_t observers_refs = sysman_observers_count(other);
    136         int rc = sysman_move_observers(other, trunk);
     136        errno_t rc = sysman_move_observers(other, trunk);
    137137        assert(rc == EOK);
    138138
     
    166166 * @return EBUSY when any job in closure is conflicting
    167167 */
    168 int job_queue_add_closure(job_closure_t *closure)
     168errno_t job_queue_add_closure(job_closure_t *closure)
    169169{
    170170        bool has_error = false;
    171         int rc = EOK;
     171        errno_t rc = EOK;
    172172
    173173        /* Check consistency with existing jobs. */
  • uspace/srv/sysman/job_queue.h

    r102f641 r25697163  
    3333
    3434extern void job_queue_init(void);
    35 extern int job_queue_add_closure(job_closure_t *);
     35extern errno_t job_queue_add_closure(job_closure_t *);
    3636extern void job_queue_process(void);
    3737
  • uspace/srv/sysman/repo.c

    r102f641 r25697163  
    151151}
    152152
    153 int repo_add_unit(unit_t *unit)
     153errno_t repo_add_unit(unit_t *unit)
    154154{
    155155        assert(unit);
     
    172172}
    173173
    174 int repo_remove_unit(unit_t *unit)
     174errno_t repo_remove_unit(unit_t *unit)
    175175{
    176176        unit->repo_state = REPO_ZOMBIE;
     
    283283 * @return ENOENT  when one or more resolution fails, information is logged
    284284 */
    285 int repo_resolve_references(void)
     285errno_t repo_resolve_references(void)
    286286{
    287287        sysman_log(LVL_DEBUG2, "%s", __func__);
  • uspace/srv/sysman/repo.h

    r102f641 r25697163  
    6464extern void repo_init(void);
    6565
    66 extern int repo_add_unit(unit_t *);
    67 extern int repo_remove_unit(unit_t *);
     66extern errno_t repo_add_unit(unit_t *);
     67extern errno_t repo_remove_unit(unit_t *);
    6868
    6969extern void repo_begin_update(void);
     
    7373extern void repo_rollback(void);
    7474
    75 extern int repo_resolve_references(void);
     75extern errno_t repo_resolve_references(void);
    7676
    7777extern unit_t *repo_find_unit_by_name(const char *);
  • uspace/srv/sysman/sm_task.c

    r102f641 r25697163  
    8888        unit_t *u_svc = unit_create(UNIT_SERVICE);
    8989        bool in_repo_update = false;
    90         int rc = EOK;
     90        errno_t rc = EOK;
    9191
    9292        if (u_svc == NULL) {
     
    139139{
    140140        repo_begin_update();
    141         int rc = repo_remove_unit(&u_svc->unit);
     141        errno_t rc = repo_remove_unit(&u_svc->unit);
    142142        if (rc != EOK) {
    143143                sysman_log(LVL_WARN, "Can't remove unit %s (%i).",
  • uspace/srv/sysman/sysman.c

    r102f641 r25697163  
    375375        free(job_args);
    376376
    377         int rc = job_create_closure(job, &job_closure, flags);
     377        errno_t rc = job_create_closure(job, &job_closure, flags);
    378378        if (rc != EOK) {
    379379                sysman_log(LVL_ERROR, "Cannot create closure for job %p (%i)",
  • uspace/srv/sysman/test/job_closure.c

    r102f641 r25697163  
    114114
    115115        dyn_array_initialize(&exp_closure, job_t *);
    116         int rc = dyn_array_reserve(&exp_closure, MAX_TYPES * MAX_UNITS);
     116        errno_t rc = dyn_array_reserve(&exp_closure, MAX_TYPES * MAX_UNITS);
    117117        assert(rc == EOK);
    118118
     
    153153        assert(main_job);
    154154
    155         int rc = job_create_closure(main_job, &act_closure, 0);
     155        errno_t rc = job_create_closure(main_job, &act_closure, 0);
    156156        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    157157
     
    185185        assert(main_job);
    186186
    187         int rc = job_create_closure(main_job, &act_closure, 0);
     187        errno_t rc = job_create_closure(main_job, &act_closure, 0);
    188188        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    189189
     
    219219        assert(main_job);
    220220
    221         int rc = job_create_closure(main_job, &act_closure, 0);
     221        errno_t rc = job_create_closure(main_job, &act_closure, 0);
    222222        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    223223
     
    266266        assert(main_job);
    267267
    268         int rc = job_create_closure(main_job, &act_closure, CLOSURE_ISOLATE);
     268        errno_t rc = job_create_closure(main_job, &act_closure, CLOSURE_ISOLATE);
    269269        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    270270
  • uspace/srv/sysman/test/job_queue.c

    r102f641 r25697163  
    8686        job_t *job = NULL;
    8787
    88         int rc = sysman_run_job(u, STATE_STARTED, 0, &job_finished_cb,
     88        errno_t rc = sysman_run_job(u, STATE_STARTED, 0, &job_finished_cb,
    8989            &job);
    9090        PCUT_ASSERT_INT_EQUALS(EOK, rc);
     
    106106        job_t *job = NULL;
    107107
    108         int rc = sysman_run_job(u, STATE_STARTED, 0, &job_finished_cb, &job);
     108        errno_t rc = sysman_run_job(u, STATE_STARTED, 0, &job_finished_cb, &job);
    109109        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    110110
     
    147147        /* Run test */
    148148        job_t *job = NULL;
    149         int rc = sysman_run_job(s1, STATE_STARTED, 0, &job_finished_cb, &job);
     149        errno_t rc = sysman_run_job(s1, STATE_STARTED, 0, &job_finished_cb, &job);
    150150        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    151151
     
    169169        /* Create and start first job */
    170170        job_t *j0 = NULL;
    171         int rc = sysman_run_job(s0, STATE_STARTED, 0, &job_finished_cb, &j0);
     171        errno_t rc = sysman_run_job(s0, STATE_STARTED, 0, &job_finished_cb, &j0);
    172172        PCUT_ASSERT_INT_EQUALS(EOK, rc);
    173173
  • uspace/srv/sysman/test/mock_unit.c

    r102f641 r25697163  
    7878void mock_add_edge(unit_t *input, unit_t *output)
    7979{
    80         int rc = edge_connect(input, output);
     80        errno_t rc = edge_connect(input, output);
    8181        assert(rc == EOK);
    8282
     
    8787}
    8888
    89 int mock_unit_vmt_start_sync(unit_t *unit)
     89errno_t mock_unit_vmt_start_sync(unit_t *unit)
    9090{
    9191        unit->state = STATE_STARTED;
     
    9393}
    9494
    95 int mock_unit_vmt_start_async(unit_t *unit)
     95errno_t mock_unit_vmt_start_async(unit_t *unit)
    9696{
    9797        unit->state = STATE_STARTING;
  • uspace/srv/sysman/test/mock_unit.h

    r102f641 r25697163  
    4848extern void mock_add_edge(unit_t *, unit_t *);
    4949
    50 extern int mock_unit_vmt_start_sync(unit_t *);
    51 extern int mock_unit_vmt_start_async(unit_t *);
     50extern errno_t mock_unit_vmt_start_sync(unit_t *);
     51extern errno_t mock_unit_vmt_start_async(unit_t *);
    5252extern void mock_unit_vmt_exposee_created(unit_t *);
    5353
  • uspace/srv/sysman/unit.c

    r102f641 r25697163  
    105105}
    106106
    107 int unit_load(unit_t *unit, ini_configuration_t *ini_conf,
     107errno_t unit_load(unit_t *unit, ini_configuration_t *ini_conf,
    108108    text_parse_t *text_parse)
    109109{
    110110        sysman_log(LVL_DEBUG, "%s('%s')", __func__, unit_name(unit));
    111111
    112         int rc = EOK;
     112        errno_t rc = EOK;
    113113        ini_section_t *unit_section = ini_get_section(ini_conf, section_name);
    114114        if (unit_section) {
     
    135135 *   - STATE_FAILED.  (unit state changed and error occured)
    136136 */
    137 int unit_start(unit_t *unit)
     137errno_t unit_start(unit_t *unit)
    138138{
    139139        sysman_log(LVL_NOTE, "%s('%s')", __func__, unit_name(unit));
     
    145145 * Same semantics like for unit_start applies.
    146146 */
    147 int unit_stop(unit_t *unit)
     147errno_t unit_stop(unit_t *unit)
    148148{
    149149        sysman_log(LVL_NOTE, "%s('%s')", __func__, unit_name(unit));
  • uspace/srv/sysman/unit.h

    r102f641 r25697163  
    120120        void (*destroy)(unit_t *);
    121121
    122         int (*load)(unit_t *, ini_configuration_t *, text_parse_t *);
     122        errno_t (*load)(unit_t *, ini_configuration_t *, text_parse_t *);
    123123
    124         int (*start)(unit_t *);
     124        errno_t (*start)(unit_t *);
    125125
    126         int (*stop)(unit_t *);
     126        errno_t (*stop)(unit_t *);
    127127
    128128        void (*exposee_created)(unit_t *);
     
    150150extern void unit_destroy(unit_t **);
    151151
    152 extern int unit_load(unit_t *, ini_configuration_t *, text_parse_t *);
    153 extern int unit_start(unit_t *);
    154 extern int unit_stop(unit_t *);
     152extern errno_t unit_load(unit_t *, ini_configuration_t *, text_parse_t *);
     153extern errno_t unit_start(unit_t *);
     154extern errno_t unit_stop(unit_t *);
    155155extern void unit_exposee_created(unit_t *);
    156156extern void unit_fail(unit_t *);
  • uspace/srv/sysman/units/unit_tgt.c

    r102f641 r25697163  
    4545}
    4646
    47 static int unit_tgt_load(unit_t *unit, ini_configuration_t *ini_conf,
     47static errno_t unit_tgt_load(unit_t *unit, ini_configuration_t *ini_conf,
    4848    text_parse_t *text_parse)
    4949{
     
    5454}
    5555
    56 static int unit_tgt_start(unit_t *unit)
     56static errno_t unit_tgt_start(unit_t *unit)
    5757{
    5858        unit_tgt_t *u_tgt = CAST_TGT(unit);
     
    6363}
    6464
    65 static int unit_tgt_stop(unit_t *unit)
     65static errno_t unit_tgt_stop(unit_t *unit)
    6666{
    6767        unit_tgt_t *u_tgt = CAST_TGT(unit);
  • uspace/srv/taskman/task.c

    r102f641 r25697163  
    119119}
    120120
    121 int tasks_init(void)
     121errno_t tasks_init(void)
    122122{
    123123        if (!hash_table_create(&task_hash_table, 0, 0, &task_hash_table_ops)) {
     
    191191}
    192192
    193 int task_intro(task_id_t id)
    194 {
    195         int rc = EOK;
     193errno_t task_intro(task_id_t id)
     194{
     195        errno_t rc = EOK;
    196196
    197197        fibril_rwlock_write_lock(&task_hash_table_lock);
  • uspace/srv/taskman/task.h

    r102f641 r25697163  
    7777extern fibril_rwlock_t task_hash_table_lock;
    7878
    79 extern int tasks_init(void);
     79extern errno_t tasks_init(void);
    8080
    8181extern task_t *task_get_by_id(task_id_t);
     
    8585extern void task_remove(task_t **);
    8686
    87 extern int task_intro(task_id_t);
     87extern errno_t task_intro(task_id_t);
    8888
    8989#endif
Note: See TracChangeset for help on using the changeset viewer.