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

mendersoftware / mender-mcu / 1736448952

26 Mar 2025 02:50PM UTC coverage: 57.008% (-0.2%) from 57.17%
1736448952

push

gitlab-ci

danielskinstad
fix: store `MENDER_UPDATE_STATE_REBOOT` before calling callback

In the `zephyr-image` update module we set the pending image in
the install callback. If we don't store the next state before
setting the pending image, a spontaneous reboot in
`MENDER_UPDATE_STATE_INSTALL` will simply go to failure and stay in the
unconfirmed image in slot 1. By storing the next state, we assure that
the deployment will be marked as a failure and that we don't end up in
the wrong image.

Changelog: None
Ticket: None

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

11 of 11 new or added lines in 1 file covered. (100.0%)

78 existing lines in 3 files now uncovered.

2111 of 3703 relevant lines covered (57.01%)

67.57 hits per line

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

66.67
/src/core/error-counters.c
1
/**
2
 * @file      error-counters.c
3
 * @brief     Mender Error counters 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 <stdint.h>
21

22
#include "error-counters.h"
23
#include "log.h"
24
#include "utils.h"
25

26
#if CONFIG_MENDER_ERRORS_THRESHOLD_NET > 0
27

28
static uint8_t net_errors = 0;
29
#if CONFIG_MENDER_ERRORS_THRESHOLD_NET > UINT8_MAX
30
#error "CONFIG_MENDER_ERRORS_THRESHOLD_NET must be <= UINT8_MAX"
31
#endif
32

33
mender_err_t
34
mender_err_count_net_inc(void) {
7✔
35
    if (net_errors < UINT8_MAX) {
7✔
36
        net_errors++;
7✔
37
    }
38
    if (net_errors > CONFIG_MENDER_ERRORS_THRESHOLD_NET) {
7✔
39
        mender_log_warning("Network errors limit exceeded");
×
40
        return MENDER_FAIL;
×
41
    }
42
    return MENDER_OK;
7✔
43
}
44

45
mender_err_t
UNCOV
46
mender_err_count_net_check(void) {
×
UNCOV
47
    if (net_errors > CONFIG_MENDER_ERRORS_THRESHOLD_NET) {
×
48
        mender_log_warning("Network errors limit exceeded");
×
49
        return MENDER_FAIL;
×
50
    }
UNCOV
51
    return MENDER_OK;
×
52
}
53

54
mender_err_t
55
mender_err_count_net_reset(void) {
40✔
56
    net_errors = 0;
40✔
57
    return MENDER_OK;
40✔
58
}
59
#endif /* CONFIG_MENDER_ERRORS_THRESHOLD_NET > 0 */
60

61
#if CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT > 0
62

63
static uint8_t reboot_errors = 0;
64
#if CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT > UINT8_MAX
65
#error "CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT must be <= UINT8_MAX"
66
#endif
67

68
mender_err_t
69
mender_err_count_reboot_inc(void) {
14✔
70
    if (reboot_errors < UINT8_MAX) {
14✔
71
        reboot_errors++;
14✔
72
    }
73
    if (reboot_errors > CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT) {
14✔
74
        return MENDER_FAIL;
×
75
    }
76
    return MENDER_OK;
14✔
77
}
78

79
mender_err_t
80
mender_err_count_reboot_reset(void) {
84✔
81
    reboot_errors = 0;
84✔
82
    return MENDER_OK;
84✔
83
}
84
#endif /* CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT > 0 */
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