mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
cangen: parse_dataoptarg(): avoid loop initial declaration
| cangen.c: In function ‘parse_dataoptarg’:
| cangen.c:422:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
| for (int i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
| ^
| cangen.c:422:2: note: use option -std=c99 or -std=gnu99 to compile your code
| cangen.c: In function ‘main’:
| cangen.c:796:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
| for (int i = 0; i < frame.len; i++) {
| ^
Reported-by: https://github.com/yannS2016
Link: https://github.com/linux-can/can-utils/issues/428
Fixes: e409aa4c8c ("cangen: new generation mode - partially randomized payload (-D)")
This commit is contained in:
@@ -417,9 +417,10 @@ static int parse_dataoptarg(char *dataoptarg, unsigned char *rand_position)
|
|||||||
{
|
{
|
||||||
int mode_format_selected = MODE_FIX;
|
int mode_format_selected = MODE_FIX;
|
||||||
int arglen = strlen(dataoptarg);
|
int arglen = strlen(dataoptarg);
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Mark nibbles with * as fuzzable */
|
/* Mark nibbles with * as fuzzable */
|
||||||
for (int i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
|
for (i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
|
||||||
if (optarg[2 * i] == CHAR_RANDOM) {
|
if (optarg[2 * i] == CHAR_RANDOM) {
|
||||||
optarg[2 * i] = '0';
|
optarg[2 * i] = '0';
|
||||||
rand_position[i] += NIBBLE_H;
|
rand_position[i] += NIBBLE_H;
|
||||||
|
|||||||
Reference in New Issue
Block a user