Skip to content

Commit 4ffac87

Browse files
committed
fix missing braces for if statements
Signed-off-by: Sheldon Wu <[email protected]>
1 parent 37eea16 commit 4ffac87

20 files changed

+3812
-1926
lines changed

generated/dpll-user.cpp

Lines changed: 190 additions & 95 deletions
Large diffs are not rendered by default.

generated/ethtool-user.cpp

Lines changed: 1558 additions & 779 deletions
Large diffs are not rendered by default.

generated/fou-user.cpp

Lines changed: 84 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ static constexpr std::array<std::string_view, FOU_CMD_GET + 1> fou_op_strmap = [
2424

2525
std::string_view fou_op_str(int op)
2626
{
27-
if (op < 0 || op >= (int)(fou_op_strmap.size()))
27+
if (op < 0 || op >= (int)(fou_op_strmap.size())) {
2828
return "";
29+
}
2930
return fou_op_strmap[op];
3031
}
3132

@@ -39,8 +40,9 @@ static constexpr std::array<std::string_view, 2 + 1> fou_encap_type_strmap = [](
3940

4041
std::string_view fou_encap_type_str(int value)
4142
{
42-
if (value < 0 || value >= (int)(fou_encap_type_strmap.size()))
43+
if (value < 0 || value >= (int)(fou_encap_type_strmap.size())) {
4344
return "";
45+
}
4446
return fou_encap_type_strmap[value];
4547
}
4648

@@ -91,30 +93,41 @@ int fou_add(ynl_cpp::ynl_socket& ys, fou_add_req& req)
9193
nlh = ynl_gemsg_start_req(ys, ((struct ynl_sock*)ys)->family_id, FOU_CMD_ADD, 1);
9294
((struct ynl_sock*)ys)->req_policy = &fou_nest;
9395

94-
if (req.port.has_value())
96+
if (req.port.has_value()) {
9597
ynl_attr_put_u16(nlh, FOU_ATTR_PORT, req.port.value());
96-
if (req.ipproto.has_value())
98+
}
99+
if (req.ipproto.has_value()) {
97100
ynl_attr_put_u8(nlh, FOU_ATTR_IPPROTO, req.ipproto.value());
98-
if (req.type.has_value())
101+
}
102+
if (req.type.has_value()) {
99103
ynl_attr_put_u8(nlh, FOU_ATTR_TYPE, req.type.value());
100-
if (req.remcsum_nopartial)
104+
}
105+
if (req.remcsum_nopartial) {
101106
ynl_attr_put(nlh, FOU_ATTR_REMCSUM_NOPARTIAL, NULL, 0);
102-
if (req.local_v4.has_value())
107+
}
108+
if (req.local_v4.has_value()) {
103109
ynl_attr_put_u32(nlh, FOU_ATTR_LOCAL_V4, req.local_v4.value());
104-
if (req.peer_v4.has_value())
110+
}
111+
if (req.peer_v4.has_value()) {
105112
ynl_attr_put_u32(nlh, FOU_ATTR_PEER_V4, req.peer_v4.value());
106-
if (req.local_v6.size() > 0)
113+
}
114+
if (req.local_v6.size() > 0) {
107115
ynl_attr_put(nlh, FOU_ATTR_LOCAL_V6, req.local_v6.data(), req.local_v6.size());
108-
if (req.peer_v6.size() > 0)
116+
}
117+
if (req.peer_v6.size() > 0) {
109118
ynl_attr_put(nlh, FOU_ATTR_PEER_V6, req.peer_v6.data(), req.peer_v6.size());
110-
if (req.peer_port.has_value())
119+
}
120+
if (req.peer_port.has_value()) {
111121
ynl_attr_put_u16(nlh, FOU_ATTR_PEER_PORT, req.peer_port.value());
112-
if (req.ifindex.has_value())
122+
}
123+
if (req.ifindex.has_value()) {
113124
ynl_attr_put_s32(nlh, FOU_ATTR_IFINDEX, req.ifindex.value());
125+
}
114126

115127
err = ynl_exec(ys, nlh, &yrs);
116-
if (err < 0)
128+
if (err < 0) {
117129
return -1;
130+
}
118131

119132
return 0;
120133
}
@@ -130,26 +143,35 @@ int fou_del(ynl_cpp::ynl_socket& ys, fou_del_req& req)
130143
nlh = ynl_gemsg_start_req(ys, ((struct ynl_sock*)ys)->family_id, FOU_CMD_DEL, 1);
131144
((struct ynl_sock*)ys)->req_policy = &fou_nest;
132145

133-
if (req.af.has_value())
146+
if (req.af.has_value()) {
134147
ynl_attr_put_u8(nlh, FOU_ATTR_AF, req.af.value());
135-
if (req.ifindex.has_value())
148+
}
149+
if (req.ifindex.has_value()) {
136150
ynl_attr_put_s32(nlh, FOU_ATTR_IFINDEX, req.ifindex.value());
137-
if (req.port.has_value())
151+
}
152+
if (req.port.has_value()) {
138153
ynl_attr_put_u16(nlh, FOU_ATTR_PORT, req.port.value());
139-
if (req.peer_port.has_value())
154+
}
155+
if (req.peer_port.has_value()) {
140156
ynl_attr_put_u16(nlh, FOU_ATTR_PEER_PORT, req.peer_port.value());
141-
if (req.local_v4.has_value())
157+
}
158+
if (req.local_v4.has_value()) {
142159
ynl_attr_put_u32(nlh, FOU_ATTR_LOCAL_V4, req.local_v4.value());
143-
if (req.peer_v4.has_value())
160+
}
161+
if (req.peer_v4.has_value()) {
144162
ynl_attr_put_u32(nlh, FOU_ATTR_PEER_V4, req.peer_v4.value());
145-
if (req.local_v6.size() > 0)
163+
}
164+
if (req.local_v6.size() > 0) {
146165
ynl_attr_put(nlh, FOU_ATTR_LOCAL_V6, req.local_v6.data(), req.local_v6.size());
147-
if (req.peer_v6.size() > 0)
166+
}
167+
if (req.peer_v6.size() > 0) {
148168
ynl_attr_put(nlh, FOU_ATTR_PEER_V6, req.peer_v6.data(), req.peer_v6.size());
169+
}
149170

150171
err = ynl_exec(ys, nlh, &yrs);
151-
if (err < 0)
172+
if (err < 0) {
152173
return -1;
174+
}
153175

154176
return 0;
155177
}
@@ -167,47 +189,57 @@ int fou_get_rsp_parse(const struct nlmsghdr *nlh, struct ynl_parse_arg *yarg)
167189
unsigned int type = ynl_attr_type(attr);
168190

169191
if (type == FOU_ATTR_PORT) {
170-
if (ynl_attr_validate(yarg, attr))
192+
if (ynl_attr_validate(yarg, attr)) {
171193
return YNL_PARSE_CB_ERROR;
194+
}
172195
dst->port = (__u16)ynl_attr_get_u16(attr);
173196
} else if (type == FOU_ATTR_IPPROTO) {
174-
if (ynl_attr_validate(yarg, attr))
197+
if (ynl_attr_validate(yarg, attr)) {
175198
return YNL_PARSE_CB_ERROR;
199+
}
176200
dst->ipproto = (__u8)ynl_attr_get_u8(attr);
177201
} else if (type == FOU_ATTR_TYPE) {
178-
if (ynl_attr_validate(yarg, attr))
202+
if (ynl_attr_validate(yarg, attr)) {
179203
return YNL_PARSE_CB_ERROR;
204+
}
180205
dst->type = (__u8)ynl_attr_get_u8(attr);
181206
} else if (type == FOU_ATTR_REMCSUM_NOPARTIAL) {
182-
if (ynl_attr_validate(yarg, attr))
207+
if (ynl_attr_validate(yarg, attr)) {
183208
return YNL_PARSE_CB_ERROR;
209+
}
184210
} else if (type == FOU_ATTR_LOCAL_V4) {
185-
if (ynl_attr_validate(yarg, attr))
211+
if (ynl_attr_validate(yarg, attr)) {
186212
return YNL_PARSE_CB_ERROR;
213+
}
187214
dst->local_v4 = (__u32)ynl_attr_get_u32(attr);
188215
} else if (type == FOU_ATTR_PEER_V4) {
189-
if (ynl_attr_validate(yarg, attr))
216+
if (ynl_attr_validate(yarg, attr)) {
190217
return YNL_PARSE_CB_ERROR;
218+
}
191219
dst->peer_v4 = (__u32)ynl_attr_get_u32(attr);
192220
} else if (type == FOU_ATTR_LOCAL_V6) {
193-
if (ynl_attr_validate(yarg, attr))
221+
if (ynl_attr_validate(yarg, attr)) {
194222
return YNL_PARSE_CB_ERROR;
223+
}
195224
unsigned int len = ynl_attr_data_len(attr);
196225
__u8 *data = (__u8*)ynl_attr_data(attr);
197226
dst->local_v6.assign(data, data + len);
198227
} else if (type == FOU_ATTR_PEER_V6) {
199-
if (ynl_attr_validate(yarg, attr))
228+
if (ynl_attr_validate(yarg, attr)) {
200229
return YNL_PARSE_CB_ERROR;
230+
}
201231
unsigned int len = ynl_attr_data_len(attr);
202232
__u8 *data = (__u8*)ynl_attr_data(attr);
203233
dst->peer_v6.assign(data, data + len);
204234
} else if (type == FOU_ATTR_PEER_PORT) {
205-
if (ynl_attr_validate(yarg, attr))
235+
if (ynl_attr_validate(yarg, attr)) {
206236
return YNL_PARSE_CB_ERROR;
237+
}
207238
dst->peer_port = (__u16)ynl_attr_get_u16(attr);
208239
} else if (type == FOU_ATTR_IFINDEX) {
209-
if (ynl_attr_validate(yarg, attr))
240+
if (ynl_attr_validate(yarg, attr)) {
210241
return YNL_PARSE_CB_ERROR;
242+
}
211243
dst->ifindex = (__s32)ynl_attr_get_s32(attr);
212244
}
213245
}
@@ -226,31 +258,40 @@ std::unique_ptr<fou_get_rsp> fou_get(ynl_cpp::ynl_socket& ys, fou_get_req& req)
226258
((struct ynl_sock*)ys)->req_policy = &fou_nest;
227259
yrs.yarg.rsp_policy = &fou_nest;
228260

229-
if (req.af.has_value())
261+
if (req.af.has_value()) {
230262
ynl_attr_put_u8(nlh, FOU_ATTR_AF, req.af.value());
231-
if (req.ifindex.has_value())
263+
}
264+
if (req.ifindex.has_value()) {
232265
ynl_attr_put_s32(nlh, FOU_ATTR_IFINDEX, req.ifindex.value());
233-
if (req.port.has_value())
266+
}
267+
if (req.port.has_value()) {
234268
ynl_attr_put_u16(nlh, FOU_ATTR_PORT, req.port.value());
235-
if (req.peer_port.has_value())
269+
}
270+
if (req.peer_port.has_value()) {
236271
ynl_attr_put_u16(nlh, FOU_ATTR_PEER_PORT, req.peer_port.value());
237-
if (req.local_v4.has_value())
272+
}
273+
if (req.local_v4.has_value()) {
238274
ynl_attr_put_u32(nlh, FOU_ATTR_LOCAL_V4, req.local_v4.value());
239-
if (req.peer_v4.has_value())
275+
}
276+
if (req.peer_v4.has_value()) {
240277
ynl_attr_put_u32(nlh, FOU_ATTR_PEER_V4, req.peer_v4.value());
241-
if (req.local_v6.size() > 0)
278+
}
279+
if (req.local_v6.size() > 0) {
242280
ynl_attr_put(nlh, FOU_ATTR_LOCAL_V6, req.local_v6.data(), req.local_v6.size());
243-
if (req.peer_v6.size() > 0)
281+
}
282+
if (req.peer_v6.size() > 0) {
244283
ynl_attr_put(nlh, FOU_ATTR_PEER_V6, req.peer_v6.data(), req.peer_v6.size());
284+
}
245285

246286
rsp.reset(new fou_get_rsp());
247287
yrs.yarg.data = rsp.get();
248288
yrs.cb = fou_get_rsp_parse;
249289
yrs.rsp_cmd = FOU_CMD_GET;
250290

251291
err = ynl_exec(ys, nlh, &yrs);
252-
if (err < 0)
292+
if (err < 0) {
253293
return nullptr;
294+
}
254295

255296
return rsp;
256297
}
@@ -273,8 +314,9 @@ std::unique_ptr<fou_get_list> fou_get_dump(ynl_cpp::ynl_socket& ys)
273314
nlh = ynl_gemsg_start_dump(ys, ((struct ynl_sock*)ys)->family_id, FOU_CMD_GET, 1);
274315

275316
err = ynl_exec_dump_no_alloc(ys, nlh, &yds);
276-
if (err < 0)
317+
if (err < 0) {
277318
return nullptr;
319+
}
278320

279321
return ret;
280322
}

0 commit comments

Comments
 (0)