@@ -43,20 +43,25 @@ bool parseVal(const std::string& str, VALObject& obj) {
4343 for (;;) {
4444 switch (state) {
4545 case Identifier: {
46- if (*a != ' V' )
46+ if (*a != ' V' ) {
4747 return false ;
48+ }
4849 a++;
49- if (*a != ' A' )
50+ if (*a != ' A' ) {
5051 return false ;
52+ }
5153 a++;
52- if (*a != ' L' )
54+ if (*a != ' L' ) {
5355 return false ;
56+ }
5457 a++;
55- if (*a != ' _' )
58+ if (*a != ' _' ) {
5659 return false ;
60+ }
5761 a++;
58- if (*a != ' ' )
62+ if (*a != ' ' ) {
5963 return false ;
64+ }
6065 a++; // skip whitespace
6166 state = CANId;
6267 break ;
@@ -67,27 +72,31 @@ bool parseVal(const std::string& str, VALObject& obj) {
6772 can_id_str += *a;
6873 a++;
6974 }
70- if (can_id_str.empty ())
75+ if (can_id_str.empty ()) {
7176 return false ;
77+ }
7278 obj.can_id = static_cast <uint32_t >(std::stoul (can_id_str));
73- if (*a != ' ' )
79+ if (*a != ' ' ) {
7480 return false ;
81+ }
7582 a++; // skip whitespace
7683 state = SignalName;
7784 break ;
7885 }
7986 case SignalName: {
80- if ((*a >= ' a' && *a <= ' z' ) || (*a >= ' A' && *a <= ' Z' ) || *a == ' _' )
87+ if ((*a >= ' a' && *a <= ' z' ) || (*a >= ' A' && *a <= ' Z' ) || *a == ' _' ) {
8188 obj.signal_name += *a;
82- else
89+ } else {
8390 return false ;
91+ }
8492 a++;
8593 while ((*a >= ' a' && *a <= ' z' ) || (*a >= ' A' && *a <= ' Z' ) || *a == ' _' || (*a >= ' 0' && *a <= ' 9' )) {
8694 obj.signal_name += *a;
8795 a++;
8896 }
89- if (*a != ' ' )
97+ if (*a != ' ' ) {
9098 return false ;
99+ }
91100 a++; // skip whitespace
92101 state = Value;
93102 break ;
@@ -99,34 +108,40 @@ bool parseVal(const std::string& str, VALObject& obj) {
99108 a++;
100109 }
101110 if (*a == ' ;' ) {
102- if (value_str.empty ())
111+ if (value_str.empty ()) {
103112 return true ;
113+ }
104114 return false ;
105115 }
106- if (value_str.empty ())
116+ if (value_str.empty ()) {
107117 return false ;
118+ }
108119
109- if (*a != ' ' )
120+ if (*a != ' ' ) {
110121 return false ;
122+ }
111123 a++; // skip whitespace
112124 vd.value = (uint32_t )std::stoul (value_str);
113125 state = Description;
114126 break ;
115127 }
116128 case Description: {
117129 std::string desc;
118- if (*a != ' "' )
130+ if (*a != ' "' ) {
119131 return false ;
132+ }
120133 a++;
121134 while (*a != ' "' && *a != 0 ) {
122135 desc += *a;
123136 a++;
124137 }
125- if (*a == 0 )
138+ if (*a == 0 ) {
126139 return false ;
140+ }
127141 a++;
128- if (*a != ' ' )
142+ if (*a != ' ' ) {
129143 return false ;
144+ }
130145 a++; // skip whitespace
131146
132147 vd.description = desc;
@@ -188,8 +203,9 @@ std::vector<libdbc::Message> DbcParser::get_messages() const {
188203
189204Message::ParseSignalsStatus DbcParser::parseMessage (const uint32_t id, const std::vector<uint8_t >& data, std::vector<double >& out_values) {
190205 for (const auto & message : messages) {
191- if (message.id () == id)
206+ if (message.id () == id) {
192207 return message.parseSignals (data, out_values);
208+ }
193209 }
194210 return Message::ParseSignalsStatus::ErrorUnknownID;
195211}
@@ -212,8 +228,9 @@ void DbcParser::parse_dbc_header(std::istream& file_stream) {
212228
213229 utils::StreamHandler::get_next_non_blank_line (file_stream, line);
214230
215- if (!std::regex_search (line, match, bit_timing_re))
231+ if (!std::regex_search (line, match, bit_timing_re)) {
216232 throw validity_error ();
233+ }
217234}
218235
219236void DbcParser::parse_dbc_nodes (std::istream& file_stream) {
@@ -222,8 +239,9 @@ void DbcParser::parse_dbc_nodes(std::istream& file_stream) {
222239
223240 utils::StreamHandler::get_next_non_blank_line (file_stream, line);
224241
225- if (!std::regex_search (line, match, node_re))
242+ if (!std::regex_search (line, match, node_re)) {
226243 throw validity_error ();
244+ }
227245
228246 if (match.length () > 2 ) {
229247 std::string n = match.str (2 );
0 commit comments