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

mendersoftware / mender-mcu / 1749194361

02 Apr 2025 11:15AM UTC coverage: 23.209% (-34.4%) from 57.567%
1749194361

push

gitlab-ci

web-flow
Merge pull request #179 from danielskinstad/rollback-logic

Fix rollback logic

0 of 9 new or added lines in 1 file covered. (0.0%)

960 existing lines in 10 files now uncovered.

716 of 3085 relevant lines covered (23.21%)

11.45 hits per line

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

0.0
/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
UNCOV
34
mender_err_count_net_inc(void) {
×
UNCOV
35
    if (net_errors < UINT8_MAX) {
×
UNCOV
36
        net_errors++;
×
37
    }
UNCOV
38
    if (net_errors > CONFIG_MENDER_ERRORS_THRESHOLD_NET) {
×
39
        mender_log_warning("Network errors limit exceeded");
×
40
        return MENDER_FAIL;
×
41
    }
UNCOV
42
    return MENDER_OK;
×
43
}
44

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

54
mender_err_t
UNCOV
55
mender_err_count_net_reset(void) {
×
UNCOV
56
    net_errors = 0;
×
UNCOV
57
    return MENDER_OK;
×
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
UNCOV
69
mender_err_count_reboot_inc(void) {
×
UNCOV
70
    if (reboot_errors < UINT8_MAX) {
×
UNCOV
71
        reboot_errors++;
×
72
    }
UNCOV
73
    if (reboot_errors > CONFIG_MENDER_ERRORS_THRESHOLD_REBOOT) {
×
74
        return MENDER_FAIL;
×
75
    }
UNCOV
76
    return MENDER_OK;
×
77
}
78

79
mender_err_t
UNCOV
80
mender_err_count_reboot_reset(void) {
×
UNCOV
81
    reboot_errors = 0;
×
UNCOV
82
    return MENDER_OK;
×
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