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

mendersoftware / mender / 947394036

pending completion
947394036

push

gitlab-ci

kacf
chore: Treat events with no state transitions as fatal.

This was discussed with the team members. Since an unhandled event is
almost guaranteed to hang the state machine, then it's better to
terminate and let systemd try to restart us, in the hopes that
recovery will still work.

Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>

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

4268 of 5997 relevant lines covered (71.17%)

148.52 hits per line

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

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

15
#include <common/common.hpp>
16
#include <common/error.hpp>
17

18
#include <cerrno>
19
#include <cstdlib>
20

21
namespace mender {
22
namespace common {
23

24
mender::common::expected::ExpectedLongLong StringToLongLong(const string &str, int base) {
210✔
25
        char *end;
26
        errno = 0;
210✔
27
        long long num = strtoll(str.c_str(), &end, base);
210✔
28
        if (errno != 0) {
210✔
29
                int int_error = errno;
×
30
                return expected::unexpected(mender::common::error::Error(
×
31
                        std::generic_category().default_error_condition(int_error), ""));
×
32
        }
33
        if (end != &*str.end()) {
210✔
34
                return expected::unexpected(mender::common::error::Error(
×
35
                        std::make_error_condition(errc::invalid_argument),
×
36
                        str + " had trailing non-numeric data"));
×
37
        }
38

39
        return num;
210✔
40
}
41

42
vector<string> SplitString(const string &str, const string &delim) {
35✔
43
        vector<string> ret;
35✔
44
        for (size_t begin = 0, end = str.find(delim);;) {
35✔
45
                if (end == string::npos) {
62✔
46
                        ret.push_back(string(str.begin() + begin, str.end()));
35✔
47
                        break;
35✔
48
                } else {
49
                        ret.push_back(string(str.begin() + begin, str.begin() + end));
27✔
50
                        begin = end + 1;
27✔
51
                        end = str.find(delim, begin);
27✔
52
                }
53
        }
54
        return ret;
35✔
55
}
56

57
string JoinStrings(const vector<string> &str, const string &delim) {
×
58
        string ret;
×
59
        auto s = str.begin();
×
60
        if (s == str.end()) {
×
61
                return ret;
×
62
        }
63
        ret += *s;
×
64
        s++;
×
65
        for (; s != str.end(); s++) {
×
66
                ret += delim;
×
67
                ret += *s;
×
68
        }
69
        return ret;
×
70
}
71

72
} // namespace common
73
} // namespace mender
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