• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-mcu / 183223423

13 Mar 2025 01:47PM UTC coverage: 61.445% (+36.0%) from 25.489%
183223423

push

gitlab-ci

danielskinstad
ci: add branch name to coveralls job

Signed-off-by: Daniel Skinstad Drabitzius <daniel.drabitzius@northern.tech>

1965 of 3198 relevant lines covered (61.44%)

170.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.67
/src/core/update-module.c
1
/**
2
 * @file      update-module.c
3
 * @brief     Mender update Module implementation
4
 *
5
 * Copyright Northern.tech AS
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19

20
#include "alloc.h"
21
#include "log.h"
22
#include "update-module.h"
23
#include "utils.h"
24

25
/**
26
 * @brief Mender update modules list
27
 */
28
static mender_update_module_t **update_modules_list  = NULL;
29
static size_t                   update_modules_count = 0;
30

31
mender_err_t
32
mender_update_module_register(mender_update_module_t *update_module) {
69✔
33
    assert(NULL != update_module);
69✔
34

35
    mender_update_module_t **tmp;
36
    mender_err_t             ret = MENDER_OK;
69✔
37

38
    for (size_t i = 0; i < update_modules_count; i++) {
69✔
39
        if (StringEqual(update_module->artifact_type, update_modules_list[i]->artifact_type)) {
×
40
            mender_log_error("Not registering another update module for artifact type: %s", update_module->artifact_type);
×
41
            return MENDER_FAIL;
×
42
        }
43
    }
44

45
    /* Add mender artifact type to the list */
46
    if (NULL == (tmp = (mender_update_module_t **)mender_realloc(update_modules_list, (update_modules_count + 1) * sizeof(mender_update_module_t *)))) {
69✔
47
        mender_log_error("Unable to allocate memory for update modules list");
×
48
        ret = MENDER_FAIL;
×
49
        goto END;
×
50
    }
51
    update_modules_list                         = tmp;
69✔
52
    update_modules_list[update_modules_count++] = update_module;
69✔
53
    ret                                         = MENDER_OK;
69✔
54

55
END:
69✔
56

57
    return ret;
69✔
58
}
59

60
void
61
mender_update_module_unregister_all(void) {
×
62
    if (NULL != update_modules_list) {
×
63
        for (size_t update_module_index = 0; update_module_index < update_modules_count; update_module_index++) {
×
64
            mender_free(update_modules_list[update_module_index]);
×
65
        }
66
        FREE_AND_NULL(update_modules_list);
×
67
    }
68
    update_modules_count = 0;
×
69
}
×
70

71
mender_update_module_t *
72
mender_update_module_get(const char *artifact_type) {
66✔
73
    mender_update_module_t *ret = NULL;
66✔
74

75
    /* Treatment depending of the type */
76
    if (NULL != update_modules_list) {
66✔
77
        for (size_t update_module_index = 0; (NULL == ret) && (update_module_index < update_modules_count); update_module_index++) {
132✔
78
            /* Check artifact type */
79
            if (StringEqual(artifact_type, update_modules_list[update_module_index]->artifact_type)) {
66✔
80
                ret = update_modules_list[update_module_index];
66✔
81
            }
82
        }
83
    }
84

85
    return ret;
66✔
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc