Skip to content

Commit b205d06

Browse files
author
Avi SZYCHTER
committed
If CheckAll fails, the return error code is 3
1 parent 0ad8939 commit b205d06

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

utils/can-parse/can-parse.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ int main(int argc, char** argv) {
150150
break;
151151

152152
case CheckAll:
153-
check_all_frames(db, warnings);
153+
{
154+
if(!check_all_frames(db, warnings)) {
155+
// CheckAll failed, we return an non-zero error-code.
156+
return 3;
157+
}
158+
}
154159
break;
155160

156161
case Help:

utils/can-parse/check-frame.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "CANDatabase.h"
44
#include <algorithm>
55

6-
void CppCAN::can_parse::check_all_frames(CANDatabase& db, const std::vector<CANDatabase::parsing_warning>& warnings) {
6+
bool CppCAN::can_parse::check_all_frames(CANDatabase& db, const std::vector<CANDatabase::parsing_warning>& warnings) {
77
std::vector<uint32_t> ids;
88

99
if(warnings.size() > 0) {
@@ -31,4 +31,9 @@ void CppCAN::can_parse::check_all_frames(CANDatabase& db, const std::vector<CAND
3131
}
3232
std::cout << ids.back() << std::endl;
3333
}
34+
35+
if(warnings.size() > 0 || ids.size() > 0)
36+
return false;
37+
38+
return true;
3439
}

utils/can-parse/operations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace can_parse {
2222
/**
2323
* @brief Checks the validity of all the frames of the database
2424
*/
25-
void check_all_frames(CANDatabase& db, const std::vector<CANDatabase::parsing_warning>& warnings);
25+
bool check_all_frames(CANDatabase& db, const std::vector<CANDatabase::parsing_warning>& warnings);
2626

2727
/**
2828
* Exception thrown by any operation if an error happens during their

0 commit comments

Comments
 (0)