diff --git a/scripts/dnp3-gen/dnp3-gen.py b/scripts/dnp3-gen/dnp3-gen.py index 266d32d8db..9a7bde00d6 100755 --- a/scripts/dnp3-gen/dnp3-gen.py +++ b/scripts/dnp3-gen/dnp3-gen.py @@ -420,7 +420,7 @@ static int DNP3DecodeObjectG{{object.group}}V{{object.variation}}(const uint8_t if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { diff --git a/src/app-layer-dnp3-objects.c b/src/app-layer-dnp3-objects.c index bcb07cb703..a4b39b85e3 100644 --- a/src/app-layer-dnp3-objects.c +++ b/src/app-layer-dnp3-objects.c @@ -446,7 +446,7 @@ static int DNP3DecodeObjectG1V2(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -499,7 +499,7 @@ static int DNP3DecodeObjectG2V1(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -541,7 +541,7 @@ static int DNP3DecodeObjectG2V2(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -597,7 +597,7 @@ static int DNP3DecodeObjectG2V3(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -701,7 +701,7 @@ static int DNP3DecodeObjectG3V2(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -753,7 +753,7 @@ static int DNP3DecodeObjectG4V1(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -805,7 +805,7 @@ static int DNP3DecodeObjectG4V2(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -860,7 +860,7 @@ static int DNP3DecodeObjectG4V3(const uint8_t **buf, uint16_t *len, uint8_t pref if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -963,7 +963,7 @@ static int DNP3DecodeObjectG10V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1016,7 +1016,7 @@ static int DNP3DecodeObjectG11V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1069,7 +1069,7 @@ static int DNP3DecodeObjectG11V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1125,7 +1125,7 @@ static int DNP3DecodeObjectG12V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1191,7 +1191,7 @@ static int DNP3DecodeObjectG12V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1305,7 +1305,7 @@ static int DNP3DecodeObjectG13V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1352,7 +1352,7 @@ static int DNP3DecodeObjectG13V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1402,7 +1402,7 @@ static int DNP3DecodeObjectG20V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1458,7 +1458,7 @@ static int DNP3DecodeObjectG20V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1514,7 +1514,7 @@ static int DNP3DecodeObjectG20V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1570,7 +1570,7 @@ static int DNP3DecodeObjectG20V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1626,7 +1626,7 @@ static int DNP3DecodeObjectG20V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1668,7 +1668,7 @@ static int DNP3DecodeObjectG20V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1710,7 +1710,7 @@ static int DNP3DecodeObjectG20V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1752,7 +1752,7 @@ static int DNP3DecodeObjectG20V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1794,7 +1794,7 @@ static int DNP3DecodeObjectG21V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1850,7 +1850,7 @@ static int DNP3DecodeObjectG21V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1906,7 +1906,7 @@ static int DNP3DecodeObjectG21V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -1962,7 +1962,7 @@ static int DNP3DecodeObjectG21V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2018,7 +2018,7 @@ static int DNP3DecodeObjectG21V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2077,7 +2077,7 @@ static int DNP3DecodeObjectG21V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2136,7 +2136,7 @@ static int DNP3DecodeObjectG21V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2195,7 +2195,7 @@ static int DNP3DecodeObjectG21V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2254,7 +2254,7 @@ static int DNP3DecodeObjectG21V9(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2296,7 +2296,7 @@ static int DNP3DecodeObjectG21V10(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2338,7 +2338,7 @@ static int DNP3DecodeObjectG21V11(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2380,7 +2380,7 @@ static int DNP3DecodeObjectG21V12(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2422,7 +2422,7 @@ static int DNP3DecodeObjectG22V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2478,7 +2478,7 @@ static int DNP3DecodeObjectG22V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2534,7 +2534,7 @@ static int DNP3DecodeObjectG22V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2590,7 +2590,7 @@ static int DNP3DecodeObjectG22V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2646,7 +2646,7 @@ static int DNP3DecodeObjectG22V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2705,7 +2705,7 @@ static int DNP3DecodeObjectG22V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2764,7 +2764,7 @@ static int DNP3DecodeObjectG22V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2823,7 +2823,7 @@ static int DNP3DecodeObjectG22V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2882,7 +2882,7 @@ static int DNP3DecodeObjectG23V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2938,7 +2938,7 @@ static int DNP3DecodeObjectG23V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -2994,7 +2994,7 @@ static int DNP3DecodeObjectG23V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3050,7 +3050,7 @@ static int DNP3DecodeObjectG23V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3106,7 +3106,7 @@ static int DNP3DecodeObjectG23V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3165,7 +3165,7 @@ static int DNP3DecodeObjectG23V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3224,7 +3224,7 @@ static int DNP3DecodeObjectG23V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3283,7 +3283,7 @@ static int DNP3DecodeObjectG23V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3342,7 +3342,7 @@ static int DNP3DecodeObjectG30V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3398,7 +3398,7 @@ static int DNP3DecodeObjectG30V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3454,7 +3454,7 @@ static int DNP3DecodeObjectG30V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3496,7 +3496,7 @@ static int DNP3DecodeObjectG30V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3538,7 +3538,7 @@ static int DNP3DecodeObjectG30V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3594,7 +3594,7 @@ static int DNP3DecodeObjectG30V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3650,7 +3650,7 @@ static int DNP3DecodeObjectG31V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3706,7 +3706,7 @@ static int DNP3DecodeObjectG31V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3762,7 +3762,7 @@ static int DNP3DecodeObjectG31V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3821,7 +3821,7 @@ static int DNP3DecodeObjectG31V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3880,7 +3880,7 @@ static int DNP3DecodeObjectG31V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3922,7 +3922,7 @@ static int DNP3DecodeObjectG31V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -3964,7 +3964,7 @@ static int DNP3DecodeObjectG31V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4020,7 +4020,7 @@ static int DNP3DecodeObjectG31V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4076,7 +4076,7 @@ static int DNP3DecodeObjectG32V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4132,7 +4132,7 @@ static int DNP3DecodeObjectG32V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4188,7 +4188,7 @@ static int DNP3DecodeObjectG32V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4247,7 +4247,7 @@ static int DNP3DecodeObjectG32V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4306,7 +4306,7 @@ static int DNP3DecodeObjectG32V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4362,7 +4362,7 @@ static int DNP3DecodeObjectG32V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4418,7 +4418,7 @@ static int DNP3DecodeObjectG32V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4477,7 +4477,7 @@ static int DNP3DecodeObjectG32V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4536,7 +4536,7 @@ static int DNP3DecodeObjectG33V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4592,7 +4592,7 @@ static int DNP3DecodeObjectG33V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4648,7 +4648,7 @@ static int DNP3DecodeObjectG33V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4707,7 +4707,7 @@ static int DNP3DecodeObjectG33V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4766,7 +4766,7 @@ static int DNP3DecodeObjectG33V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4822,7 +4822,7 @@ static int DNP3DecodeObjectG33V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4878,7 +4878,7 @@ static int DNP3DecodeObjectG33V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4937,7 +4937,7 @@ static int DNP3DecodeObjectG33V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -4996,7 +4996,7 @@ static int DNP3DecodeObjectG34V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5038,7 +5038,7 @@ static int DNP3DecodeObjectG34V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5080,7 +5080,7 @@ static int DNP3DecodeObjectG34V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5122,7 +5122,7 @@ static int DNP3DecodeObjectG40V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5178,7 +5178,7 @@ static int DNP3DecodeObjectG40V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5234,7 +5234,7 @@ static int DNP3DecodeObjectG40V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5290,7 +5290,7 @@ static int DNP3DecodeObjectG40V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5346,7 +5346,7 @@ static int DNP3DecodeObjectG41V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5391,7 +5391,7 @@ static int DNP3DecodeObjectG41V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5436,7 +5436,7 @@ static int DNP3DecodeObjectG41V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5481,7 +5481,7 @@ static int DNP3DecodeObjectG41V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5526,7 +5526,7 @@ static int DNP3DecodeObjectG42V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5582,7 +5582,7 @@ static int DNP3DecodeObjectG42V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5638,7 +5638,7 @@ static int DNP3DecodeObjectG42V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5697,7 +5697,7 @@ static int DNP3DecodeObjectG42V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5756,7 +5756,7 @@ static int DNP3DecodeObjectG42V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5812,7 +5812,7 @@ static int DNP3DecodeObjectG42V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5868,7 +5868,7 @@ static int DNP3DecodeObjectG42V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5927,7 +5927,7 @@ static int DNP3DecodeObjectG42V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -5986,7 +5986,7 @@ static int DNP3DecodeObjectG43V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6036,7 +6036,7 @@ static int DNP3DecodeObjectG43V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6086,7 +6086,7 @@ static int DNP3DecodeObjectG43V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6139,7 +6139,7 @@ static int DNP3DecodeObjectG43V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6192,7 +6192,7 @@ static int DNP3DecodeObjectG43V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6242,7 +6242,7 @@ static int DNP3DecodeObjectG43V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6292,7 +6292,7 @@ static int DNP3DecodeObjectG43V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6345,7 +6345,7 @@ static int DNP3DecodeObjectG43V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6398,7 +6398,7 @@ static int DNP3DecodeObjectG50V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6440,7 +6440,7 @@ static int DNP3DecodeObjectG50V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6485,7 +6485,7 @@ static int DNP3DecodeObjectG50V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6527,7 +6527,7 @@ static int DNP3DecodeObjectG50V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6575,7 +6575,7 @@ static int DNP3DecodeObjectG51V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6617,7 +6617,7 @@ static int DNP3DecodeObjectG51V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6659,7 +6659,7 @@ static int DNP3DecodeObjectG52V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6701,7 +6701,7 @@ static int DNP3DecodeObjectG52V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6743,7 +6743,7 @@ static int DNP3DecodeObjectG70V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6856,7 +6856,7 @@ static int DNP3DecodeObjectG70V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -6942,7 +6942,7 @@ static int DNP3DecodeObjectG70V3(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7029,7 +7029,7 @@ static int DNP3DecodeObjectG70V4(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7104,7 +7104,7 @@ static int DNP3DecodeObjectG70V5(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7170,7 +7170,7 @@ static int DNP3DecodeObjectG70V6(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7234,7 +7234,7 @@ static int DNP3DecodeObjectG70V7(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7315,7 +7315,7 @@ static int DNP3DecodeObjectG70V8(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7424,7 +7424,7 @@ static int DNP3DecodeObjectG81V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7477,7 +7477,7 @@ static int DNP3DecodeObjectG83V1(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7545,7 +7545,7 @@ static int DNP3DecodeObjectG86V2(const uint8_t **buf, uint16_t *len, uint8_t pre if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7598,7 +7598,7 @@ static int DNP3DecodeObjectG102V1(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7645,7 +7645,7 @@ static int DNP3DecodeObjectG120V1(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7723,7 +7723,7 @@ static int DNP3DecodeObjectG120V2(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7790,7 +7790,7 @@ static int DNP3DecodeObjectG120V3(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7835,7 +7835,7 @@ static int DNP3DecodeObjectG120V4(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7882,7 +7882,7 @@ static int DNP3DecodeObjectG120V5(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -7982,7 +7982,7 @@ static int DNP3DecodeObjectG120V6(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8054,7 +8054,7 @@ static int DNP3DecodeObjectG120V7(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8135,7 +8135,7 @@ static int DNP3DecodeObjectG120V8(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8203,7 +8203,7 @@ static int DNP3DecodeObjectG120V9(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8268,7 +8268,7 @@ static int DNP3DecodeObjectG120V10(const uint8_t **buf, uint16_t *len, uint8_t p if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8383,7 +8383,7 @@ static int DNP3DecodeObjectG120V11(const uint8_t **buf, uint16_t *len, uint8_t p if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8467,7 +8467,7 @@ static int DNP3DecodeObjectG120V12(const uint8_t **buf, uint16_t *len, uint8_t p if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8535,7 +8535,7 @@ static int DNP3DecodeObjectG120V13(const uint8_t **buf, uint16_t *len, uint8_t p if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8604,7 +8604,7 @@ static int DNP3DecodeObjectG120V14(const uint8_t **buf, uint16_t *len, uint8_t p if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8670,7 +8670,7 @@ static int DNP3DecodeObjectG120V15(const uint8_t **buf, uint16_t *len, uint8_t p if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8731,7 +8731,7 @@ static int DNP3DecodeObjectG121V1(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8790,7 +8790,7 @@ static int DNP3DecodeObjectG122V1(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { @@ -8849,7 +8849,7 @@ static int DNP3DecodeObjectG122V2(const uint8_t **buf, uint16_t *len, uint8_t pr if (*len < count/8) { goto error; } - while (count--) { + for (uint32_t i = 0; i < count; i++) { object = SCCalloc(1, sizeof(*object)); if (unlikely(object == NULL)) { diff --git a/src/app-layer-dnp3.c b/src/app-layer-dnp3.c index 9db71e9916..42dd8d24a4 100644 --- a/src/app-layer-dnp3.c +++ b/src/app-layer-dnp3.c @@ -166,7 +166,7 @@ static uint16_t DNP3ComputeCRC(const uint8_t *buf, uint32_t len) uint16_t crc = 0; int idx; - while (len--) { + for (uint32_t i = 0; i < len; i++) { idx = (crc ^ *byte) & 0xff; crc = (crc_table[idx] ^ (crc >> 8)) & 0xffff; byte++; diff --git a/src/defrag-hash.c b/src/defrag-hash.c index a9fa43ab4a..765a1fe122 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -673,9 +673,8 @@ DefragTracker *DefragLookupTrackerFromHash (Packet *p) static DefragTracker *DefragTrackerGetUsedDefragTracker(ThreadVars *tv, const DecodeThreadVars *dtv) { uint32_t idx = SC_ATOMIC_GET(defragtracker_prune_idx) % defrag_config.hash_size; - uint32_t cnt = defrag_config.hash_size; - while (cnt--) { + for (uint32_t i = 0; i < defrag_config.hash_size; i++) { if (++idx >= defrag_config.hash_size) idx = 0; @@ -722,7 +721,7 @@ static DefragTracker *DefragTrackerGetUsedDefragTracker(ThreadVars *tv, const De StatsCounterIncr(&tv->stats, dtv->counter_defrag_tracker_soft_reuse); } - (void) SC_ATOMIC_ADD(defragtracker_prune_idx, (defrag_config.hash_size - cnt)); + (void)SC_ATOMIC_ADD(defragtracker_prune_idx, i); return dt; } diff --git a/src/detect.c b/src/detect.c index 4e5e41d5f4..3306b72ab9 100644 --- a/src/detect.c +++ b/src/detect.c @@ -347,11 +347,10 @@ static inline void DetectPrefilterCopyDeDup( const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { SigIntId *pf_ptr = det_ctx->pmq.rule_id_array; - uint32_t final_cnt = det_ctx->pmq.rule_id_array_cnt; Signature **sig_array = de_ctx->sig_array; Signature **match_array = det_ctx->match_array; SigIntId previous_id = (SigIntId)-1; - while (final_cnt-- > 0) { + for (uint32_t i = 0; i < det_ctx->pmq.rule_id_array_cnt; i++) { SigIntId id = *pf_ptr++; Signature *s = sig_array[id]; @@ -813,7 +812,8 @@ static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, next_s = *match_array++; next_sflags = next_s->flags; } - while (match_cnt--) { + while (match_cnt) { + --match_cnt; RULE_PROFILING_START(p); bool break_out_of_packet_filter = false; uint8_t alert_flags = 0; diff --git a/src/host.c b/src/host.c index c055f7436a..ddf8047f71 100644 --- a/src/host.c +++ b/src/host.c @@ -659,9 +659,8 @@ Host *HostLookupHostFromHash (Address *a) static Host *HostGetUsedHost(void) { uint32_t idx = SC_ATOMIC_GET(host_prune_idx) % host_config.hash_size; - uint32_t cnt = host_config.hash_size; - while (cnt--) { + for (uint32_t i = 0; i < host_config.hash_size; i++) { if (++idx >= host_config.hash_size) idx = 0; @@ -707,7 +706,7 @@ static Host *HostGetUsedHost(void) SCMutexUnlock(&h->m); - (void) SC_ATOMIC_ADD(host_prune_idx, (host_config.hash_size - cnt)); + (void)SC_ATOMIC_ADD(host_prune_idx, i); return h; } diff --git a/src/ippair.c b/src/ippair.c index 32f523c386..c7de42680b 100644 --- a/src/ippair.c +++ b/src/ippair.c @@ -697,9 +697,8 @@ IPPair *IPPairLookupIPPairFromHash (Address *a, Address *b) static IPPair *IPPairGetUsedIPPair(void) { uint32_t idx = SC_ATOMIC_GET(ippair_prune_idx) % ippair_config.hash_size; - uint32_t cnt = ippair_config.hash_size; - while (cnt--) { + for (uint32_t i = 0; i < ippair_config.hash_size; i++) { if (++idx >= ippair_config.hash_size) idx = 0; @@ -745,7 +744,7 @@ static IPPair *IPPairGetUsedIPPair(void) SCMutexUnlock(&h->m); - (void) SC_ATOMIC_ADD(ippair_prune_idx, (ippair_config.hash_size - cnt)); + (void)SC_ATOMIC_ADD(ippair_prune_idx, i); return h; } diff --git a/src/tm-threads.c b/src/tm-threads.c index 8897d07601..57be7e1edb 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -180,7 +180,7 @@ int TmThreadTimeoutLoop(ThreadVars *tv, TmSlot *s) uint32_t len = tv->stream_pq->len; SCMutexUnlock(&tv->stream_pq->mutex_q); if (len > 0) { - while (len--) { + for (uint32_t i = 0; i < len; i++) { SCMutexLock(&tv->stream_pq->mutex_q); Packet *p = PacketDequeue(tv->stream_pq); SCMutexUnlock(&tv->stream_pq->mutex_q); diff --git a/src/util-thash.c b/src/util-thash.c index e6363d9446..ae60a4f9d9 100644 --- a/src/util-thash.c +++ b/src/util-thash.c @@ -821,9 +821,8 @@ THashData *THashLookupFromHash (THashTableContext *ctx, void *data) static THashData *THashGetUsed(THashTableContext *ctx, uint32_t data_size) { uint32_t idx = SC_ATOMIC_GET(ctx->prune_idx) % ctx->config.hash_size; - uint32_t cnt = ctx->config.hash_size; - while (cnt--) { + for (uint32_t i = 0; i < ctx->config.hash_size; i++) { if (++idx >= ctx->config.hash_size) idx = 0; @@ -874,7 +873,7 @@ static THashData *THashGetUsed(THashTableContext *ctx, uint32_t data_size) } SCMutexUnlock(&h->m); - (void) SC_ATOMIC_ADD(ctx->prune_idx, (ctx->config.hash_size - cnt)); + (void)SC_ATOMIC_ADD(ctx->prune_idx, i); if (data_size > 0) (void)SC_ATOMIC_ADD(ctx->memuse, data_size); return h;