Skip to content

Commit 1f9e444

Browse files
committed
OSPF: Add some spaces around operators (style)
Before further updates. [skip ci]
1 parent 641bd6e commit 1f9e444

File tree

1 file changed

+62
-60
lines changed

1 file changed

+62
-60
lines changed

print-ospf.c

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ ospf_grace_lsa_print(netdissect_options *ndo,
243243
}
244244
tlv_type = GET_BE_U_2(tptr);
245245
tlv_length = GET_BE_U_2(tptr + 2);
246-
tptr+=4;
247-
ls_length-=4;
246+
tptr += 4;
247+
ls_length -= 4;
248248

249249
ND_PRINT("\n\t %s TLV (%u), length %u, value: ",
250250
tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
@@ -258,7 +258,7 @@ ospf_grace_lsa_print(netdissect_options *ndo,
258258
}
259259

260260
/* Infinite loop protection. */
261-
if (tlv_type == 0 || tlv_length ==0) {
261+
if (tlv_type == 0 || tlv_length == 0) {
262262
nd_print_invalid(ndo);
263263
return -1;
264264
}
@@ -301,16 +301,16 @@ ospf_grace_lsa_print(netdissect_options *ndo,
301301

302302
}
303303
/* in OSPF everything has to be 32-bit aligned, including TLVs */
304-
if (tlv_length%4 != 0) {
305-
tlv_length+=4-(tlv_length%4);
304+
if (tlv_length % 4 != 0) {
305+
tlv_length += 4 - (tlv_length % 4);
306306
if (tlv_length > ls_length) {
307307
ND_PRINT("\n\t Bogus padded length %u > %u", tlv_length,
308308
ls_length);
309309
return -1;
310310
}
311311
}
312-
ls_length-=tlv_length;
313-
tptr+=tlv_length;
312+
ls_length -= tlv_length;
313+
tptr += tlv_length;
314314
}
315315

316316
return 0;
@@ -334,8 +334,8 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
334334
}
335335
subtlv_type = GET_BE_U_2(tptr);
336336
subtlv_length = GET_BE_U_2(tptr + 2);
337-
tptr+=4;
338-
tlv_length-=4;
337+
tptr += 4;
338+
tlv_length -= 4;
339339

340340
/* Infinite loop protection */
341341
if (subtlv_type == 0 || subtlv_length == 0)
@@ -371,7 +371,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
371371
GET_BE_U_4(tptr));
372372
if (subtlv_length == 8) /* rfc4203 */
373373
ND_PRINT(", %s (0x%08x)",
374-
GET_IPADDR_STRING(tptr+4),
374+
GET_IPADDR_STRING(tptr + 4),
375375
GET_BE_U_4(tptr + 4));
376376
break;
377377
case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
@@ -419,7 +419,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
419419
goto invalid;
420420
}
421421
/* decode BCs until the subTLV ends */
422-
for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
422+
for (te_class = 0; te_class < (subtlv_length - 4) / 4; te_class++) {
423423
ND_PRINT("\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
424424
te_class,
425425
GET_BE_F_4(tptr + 4 + te_class * 4) * 8 / 1000000);
@@ -476,7 +476,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
476476
ND_PRINT("\n\t\t Shared risk group: ");
477477
while (count_srlg != 0) {
478478
ND_PRINT("%u", GET_BE_U_4(tptr));
479-
tptr+=4;
479+
tptr += 4;
480480
count_srlg--;
481481
if (count_srlg > 0)
482482
ND_PRINT(", ");
@@ -490,17 +490,17 @@ ospf_te_tlv_link_print(netdissect_options *ndo,
490490
break;
491491
}
492492
/* in OSPF everything has to be 32-bit aligned, including subTLVs */
493-
if (subtlv_length%4 != 0) {
494-
subtlv_length+=4-(subtlv_length%4);
493+
if (subtlv_length % 4 != 0) {
494+
subtlv_length += 4 - (subtlv_length % 4);
495495

496496
if (tlv_length < subtlv_length) {
497497
ND_PRINT("\n\t Remaining TLV length %u < %u",
498498
tlv_length, subtlv_length);
499499
return -1;
500500
}
501501
}
502-
tlv_length-=subtlv_length;
503-
tptr+=subtlv_length;
502+
tlv_length -= subtlv_length;
503+
tptr += subtlv_length;
504504
}
505505
return 0;
506506
trunc:
@@ -525,8 +525,8 @@ ospf_te_lsa_print(netdissect_options *ndo,
525525
}
526526
tlv_type = GET_BE_U_2(tptr);
527527
tlv_length = GET_BE_U_2(tptr + 2);
528-
tptr+=4;
529-
ls_length-=4;
528+
tptr += 4;
529+
ls_length -= 4;
530530

531531
ND_PRINT("\n\t %s TLV (%u), length: %u",
532532
tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
@@ -540,7 +540,7 @@ ospf_te_lsa_print(netdissect_options *ndo,
540540
}
541541

542542
/* Infinite loop protection. */
543-
if (tlv_type == 0 || tlv_length ==0) {
543+
if (tlv_type == 0 || tlv_length == 0) {
544544
nd_print_invalid(ndo);
545545
goto invalid;
546546
}
@@ -567,16 +567,16 @@ ospf_te_lsa_print(netdissect_options *ndo,
567567
break;
568568
}
569569
/* in OSPF everything has to be 32-bit aligned, including TLVs */
570-
if (tlv_length%4 != 0) {
571-
tlv_length+=4-(tlv_length%4);
570+
if (tlv_length % 4 != 0) {
571+
tlv_length += 4 - (tlv_length % 4);
572572
if (tlv_length > ls_length) {
573573
ND_PRINT("\n\t Bogus padded length %u > %u", tlv_length,
574574
ls_length);
575575
goto invalid;
576576
}
577577
}
578-
ls_length-=tlv_length;
579-
tptr+=tlv_length;
578+
ls_length -= tlv_length;
579+
tptr += tlv_length;
580580
}
581581
return 0;
582582
trunc:
@@ -657,7 +657,7 @@ ospf_print_tos_metrics(netdissect_options *ndo,
657657
u_int toscount;
658658
u_int tos_type;
659659

660-
toscount = GET_U_1(tos->link.link_tos_count)+1;
660+
toscount = GET_U_1(tos->link.link_tos_count) + 1;
661661
metric_count = 0;
662662

663663
/*
@@ -693,9 +693,9 @@ ospf_print_ri_lsa_sid_label_range_tlv(netdissect_options *ndo, const uint8_t *tp
693693
while (tlv_length >= 4) {
694694

695695
subtlv_type = GET_BE_U_2(tptr);
696-
subtlv_length = GET_BE_U_2(tptr+2);
697-
tptr+=4;
698-
tlv_length-=4;
696+
subtlv_length = GET_BE_U_2(tptr + 2);
697+
tptr += 4;
698+
tlv_length -= 4;
699699

700700
/* Infinite loop protection. */
701701
if (subtlv_type == 0 || subtlv_length == 0) {
@@ -741,8 +741,8 @@ ospf_print_ri_lsa_sid_label_range_tlv(netdissect_options *ndo, const uint8_t *tp
741741
return -1;
742742
}
743743
}
744-
tptr+=subtlv_length;
745-
tlv_length-=subtlv_length;
744+
tptr += subtlv_length;
745+
tlv_length -= subtlv_length;
746746
}
747747
return 0;
748748
}
@@ -756,9 +756,9 @@ ospf_print_ep_lsa_extd_prefix_tlv(netdissect_options *ndo, const uint8_t *tptr,
756756

757757
while (tlv_length >= 4) {
758758
subtlv_type = GET_BE_U_2(tptr);
759-
subtlv_length = GET_BE_U_2(tptr+2);
760-
tptr+=4;
761-
tlv_length-=4;
759+
subtlv_length = GET_BE_U_2(tptr + 2);
760+
tptr += 4;
761+
tlv_length -= 4;
762762

763763
/* Infinite loop protection. */
764764
if (subtlv_type == 0 || subtlv_length == 0) {
@@ -780,13 +780,13 @@ ospf_print_ep_lsa_extd_prefix_tlv(netdissect_options *ndo, const uint8_t *tptr,
780780
switch (subtlv_type) {
781781
case LS_OPAQUE_EP_SUBTLV_PREFIX_SID:
782782
flags = GET_U_1(tptr);
783-
mt_id = GET_U_1(tptr+2);
784-
algo = GET_U_1(tptr+3);
783+
mt_id = GET_U_1(tptr + 2);
784+
algo = GET_U_1(tptr + 3);
785785

786786
if (subtlv_length == 7) {
787-
ND_PRINT("\n\t\t Label: %u", GET_BE_U_3(tptr+4));
787+
ND_PRINT("\n\t\t Label: %u", GET_BE_U_3(tptr + 4));
788788
} else if (subtlv_length == 8) {
789-
ND_PRINT("\n\t\t Index: %u", GET_BE_U_4(tptr+4));
789+
ND_PRINT("\n\t\t Index: %u", GET_BE_U_4(tptr + 4));
790790
} else {
791791
ND_PRINT("\n\t\tBogus subTLV length %u", subtlv_length);
792792
break;
@@ -812,8 +812,8 @@ ospf_print_ep_lsa_extd_prefix_tlv(netdissect_options *ndo, const uint8_t *tptr,
812812
return -1;
813813
}
814814
}
815-
tptr+=subtlv_length;
816-
tlv_length-=subtlv_length;
815+
tptr += subtlv_length;
816+
tlv_length -= subtlv_length;
817817
}
818818
return 0;
819819
}
@@ -828,9 +828,9 @@ ospf_ep_lsa_print(netdissect_options *ndo, const uint8_t *tptr, u_int lsa_length
828828
while (lsa_length >= 4) {
829829

830830
tlv_type = GET_BE_U_2(tptr);
831-
tlv_length = GET_BE_U_2(tptr+2);
832-
tptr+=4;
833-
lsa_length-=4;
831+
tlv_length = GET_BE_U_2(tptr + 2);
832+
tptr += 4;
833+
lsa_length -= 4;
834834

835835
/* Infinite loop protection. */
836836
if (tlv_type == 0 || tlv_length == 0) {
@@ -851,10 +851,10 @@ ospf_ep_lsa_print(netdissect_options *ndo, const uint8_t *tptr, u_int lsa_length
851851

852852
switch (tlv_type) {
853853
case LS_OPAQUE_EP_EXTD_PREFIX_TLV:
854-
prefix_length = GET_U_1(tptr+1);
855-
af = GET_U_1(tptr+2);
854+
prefix_length = GET_U_1(tptr + 1);
855+
af = GET_U_1(tptr + 2);
856856
route_type = GET_U_1(tptr);
857-
flags = GET_U_1(tptr+3);
857+
flags = GET_U_1(tptr + 3);
858858

859859
if (af != 0) {
860860
ND_PRINT("\n\t Bogus AF %u", af);
@@ -867,23 +867,23 @@ ospf_ep_lsa_print(netdissect_options *ndo, const uint8_t *tptr, u_int lsa_length
867867
}
868868

869869
ND_PRINT("\n\t IPv4 prefix: %15s/%u, Route Type: %s, Flags [%s]",
870-
GET_IPADDR_STRING(tptr+4), prefix_length,
870+
GET_IPADDR_STRING(tptr + 4), prefix_length,
871871
tok2str(lsa_opaque_ep_route_type_values, "Unknown", route_type),
872872
bittok2str(ep_tlv_flag_values, "none", flags));
873873

874874
/* subTLVs present ? */
875875
if (tlv_length > 12) {
876-
if (ospf_print_ep_lsa_extd_prefix_tlv(ndo, tptr+8, tlv_length-8) == -1) {
876+
if (ospf_print_ep_lsa_extd_prefix_tlv(ndo, tptr + 8, tlv_length - 8) == -1) {
877877
return -1;
878878
}
879879
}
880880
break;
881881

882882
case LS_OPAQUE_EP_EXTD_PREFIX_RANGE_TLV:
883883
prefix_length = GET_U_1(tptr);
884-
af = GET_U_1(tptr+1);
885-
range_size = GET_BE_U_2(tptr+2);
886-
flags = GET_U_1(tptr+4);
884+
af = GET_U_1(tptr + 1);
885+
range_size = GET_BE_U_2(tptr + 2);
886+
flags = GET_U_1(tptr + 4);
887887

888888
if (af != 0) {
889889
ND_PRINT("\n\t Bogus AF %u", af);
@@ -896,13 +896,13 @@ ospf_ep_lsa_print(netdissect_options *ndo, const uint8_t *tptr, u_int lsa_length
896896
}
897897

898898
ND_PRINT("\n\t IPv4 prefix: %15s/%u, Range size: %u, Flags [%s]",
899-
GET_IPADDR_STRING(tptr+8), prefix_length,
899+
GET_IPADDR_STRING(tptr + 8), prefix_length,
900900
range_size,
901901
bittok2str(ep_tlv_flag_values, "none", flags));
902902

903903
/* subTLVs present ? */
904904
if (tlv_length > 12) {
905-
if (ospf_print_ep_lsa_extd_prefix_tlv(ndo, tptr+12, tlv_length-12) == -1) {
905+
if (ospf_print_ep_lsa_extd_prefix_tlv(ndo, tptr + 12, tlv_length - 12) == -1) {
906906
return -1;
907907
}
908908
}
@@ -924,8 +924,8 @@ ospf_ep_lsa_print(netdissect_options *ndo, const uint8_t *tptr, u_int lsa_length
924924
return -1;
925925
}
926926
}
927-
tptr+=tlv_length;
928-
lsa_length-=tlv_length;
927+
tptr += tlv_length;
928+
lsa_length -= tlv_length;
929929
}
930930
return 0;
931931
}
@@ -1131,8 +1131,8 @@ ospf_print_lsa(netdissect_options *ndo,
11311131
}
11321132
tlv_type = GET_BE_U_2(tptr);
11331133
tlv_length = GET_BE_U_2(tptr + 2);
1134-
tptr+=4;
1135-
ls_length_remaining-=4;
1134+
tptr += 4;
1135+
ls_length_remaining -= 4;
11361136

11371137
ND_PRINT("\n\t %s TLV (%u), length: %u, value: ",
11381138
tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
@@ -1165,7 +1165,9 @@ ospf_print_lsa(netdissect_options *ndo,
11651165
num_tlv = tlv_length;
11661166
while (num_tlv >= 1) {
11671167
ND_PRINT("\n\t %s (%u)",
1168-
tok2str(lsa_opaque_ri_tlv_sr_algos, "Unknown", GET_U_1(tptr+tlv_length-num_tlv)), GET_U_1(tptr+tlv_length-num_tlv));
1168+
tok2str(lsa_opaque_ri_tlv_sr_algos,
1169+
"Unknown", GET_U_1(tptr + tlv_length - num_tlv)),
1170+
GET_U_1(tptr + tlv_length - num_tlv));
11691171
num_tlv--;
11701172
}
11711173
break;
@@ -1174,7 +1176,7 @@ ospf_print_lsa(netdissect_options *ndo,
11741176
case LS_OPAQUE_RI_TLV_SR_LOCAL_BLOCK:
11751177
ND_TCHECK_4(tptr);
11761178
ND_PRINT("\n\t Range size: %u", GET_BE_U_3(tptr));
1177-
if (ospf_print_ri_lsa_sid_label_range_tlv(ndo, tptr+4, tlv_length-4) == -1) {
1179+
if (ospf_print_ri_lsa_sid_label_range_tlv(ndo, tptr + 4, tlv_length - 4) == -1) {
11781180
return(ls_end);
11791181
}
11801182
break;
@@ -1205,8 +1207,8 @@ ospf_print_lsa(netdissect_options *ndo,
12051207
return(NULL);
12061208
}
12071209
}
1208-
tptr+=tlv_length;
1209-
ls_length_remaining-=tlv_length;
1210+
tptr += tlv_length;
1211+
ls_length_remaining -= tlv_length;
12101212
}
12111213
break;
12121214

@@ -1426,7 +1428,7 @@ ospf_decode_v2(netdissect_options *ndo,
14261428
lsap = op->ospf_lsu.lsu_lsa;
14271429
lsa_count_max = GET_BE_U_4(op->ospf_lsu.lsu_count);
14281430
ND_PRINT(", %u LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
1429-
for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
1431+
for (lsa_count = 1; lsa_count <= lsa_count_max; lsa_count++) {
14301432
ND_PRINT("\n\t LSA #%u", lsa_count);
14311433
lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
14321434
if (lsap == NULL)

0 commit comments

Comments
 (0)