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

mendersoftware / mender-mcu / 1652801795

03 Feb 2025 08:48AM UTC coverage: 25.939% (+0.3%) from 25.682%
1652801795

push

gitlab-ci

danielskinstad
chore: explicit error for no files in zephyr-image-update-module

Check if the aritfact has a payload file by adding a boolean that's set
when the download artifact flash callback is called.

Ticket: MEN-7804

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

739 of 2849 relevant lines covered (25.94%)

8.56 hits per line

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

80.0
/core/src/mender-update-module.c
1
/**
2
 * @file      mender-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 "mender-alloc.h"
21
#include "mender-log.h"
22
#include "mender-update-module.h"
23

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

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

34
    mender_update_module_t **tmp;
35
    mender_err_t             ret = MENDER_OK;
11✔
36

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

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

54
END:
11✔
55

56
    return ret;
11✔
57
}
58

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

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

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

84
    return ret;
7✔
85
}
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

© 2025 Coveralls, Inc