Changeset 88ad75f in mainline


Ignore:
Timestamp:
2020-01-09T01:04:57Z (4 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
76c8209
Parents:
0939097
git-author:
Matthieu Riolo <matthieu.riolo@…> (2020-01-05 19:24:23)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2020-01-09 01:04:57)
Message:

repo_add_unit() returned an errno_t but it was never handled. This
commit adds a check if EOK is returned or else the repo will be left
unchanged

Location:
uspace/srv/sysman
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/main.c

    r0939097 r88ad75f  
    135135        repo_begin_update();
    136136
    137         repo_add_unit(mnt_initrd);
    138         repo_add_unit(cfg_init);
    139         repo_add_unit(tgt_init);
     137        rc = repo_add_unit(mnt_initrd);
     138        if (rc != EOK)
     139                goto rollback;
     140        rc = repo_add_unit(cfg_init);
     141        if (rc != EOK)
     142                goto rollback;
     143        rc = repo_add_unit(tgt_init);
     144        if (rc != EOK)
     145                goto rollback;
    140146
    141147        rc = edge_connect(tgt_init, cfg_init);
    142         if (rc != EOK) {
    143                 goto rollback;
    144         }
     148        if (rc != EOK)
     149                goto rollback;
    145150
    146151        rc = edge_connect(cfg_init, mnt_initrd);
    147         if (rc != EOK) {
    148                 goto rollback;
    149         }
     152        if (rc != EOK)
     153                goto rollback;
    150154
    151155        repo_commit();
    152 
    153156        return EOK;
    154157
  • uspace/srv/sysman/test/job_closure.c

    r0939097 r88ad75f  
    245245        repo_begin_update();
    246246        for (int i = 0; i < 7; ++i) {
    247                 repo_add_unit(mock_units[UNIT_SERVICE][i]);
     247                errno_t rc = repo_add_unit(mock_units[UNIT_SERVICE][i]);
     248                PCUT_ASSERT_INT_EQUALS(EOK, rc);
    248249        }
    249250        repo_commit();
  • uspace/srv/sysman/units/unit_cfg.c

    r0939097 r88ad75f  
    155155        DIR *dir;
    156156        struct dirent *de;
     157        errno_t rc;
    157158
    158159        dir = opendir(path);
     
    167168        while ((de = readdir(dir))) {
    168169                unit_t *unit = NULL;
    169                 errno_t rc = cfg_parse_file(path, de->d_name, &unit);
     170                rc = cfg_parse_file(path, de->d_name, &unit);
    170171                if (rc != EOK) {
    171172                        sysman_log(LVL_WARN, "Cannot load unit from file %s/%s",
     
    179180
    180181                assert(unit->repo_state == REPO_EMBRYO);
    181                 repo_add_unit(unit);
     182                rc = repo_add_unit(unit);
     183                if (rc != EOK)
     184                        goto error;
     185
    182186        }
    183187        closedir(dir);
    184188
    185         errno_t rc = repo_resolve_references();
    186         if (rc != EOK) {
    187                 repo_rollback();
    188                 return rc;
    189         }
     189        rc = repo_resolve_references();
     190        if (rc != EOK)
     191                goto error;
    190192
    191193        repo_commit();
    192194        return EOK;
     195
     196error:
     197        repo_rollback();
     198        return rc;
    193199}
    194200
Note: See TracChangeset for help on using the changeset viewer.