Skip to contentSkip to conversation

Curious code in init()

DISCUSSION Erwan Velu 2 participants 2 messages Apr 2, 2014

lore
Share & tools
lore

Erwan Velu

author
#0 lore raw

Hey Jens,

The following code is pretty confusing for me :
http://git.kernel.dk/?p=fio.git;a=blob;f=init.c;h=c3996a76c12840e3ab3cf6514e5d5dce611a1077;hb=HEAD#l1962

The "if (nr_clients && fio_clients_connect()) {" is using the do_exit concept while being after the code that manage it and does a return -1 while exit code is set to 1.

I don't get how it should be fixed.
1- we shall move the if nr_clients before the "if (do_exit", remove the return -1 and adjust the exit_code ? 2- we shall get rid of the do_exit & exit code semantic of the if nr_clients.

What was the intent while reading the code ? ;o)

Erwan,

#1 lore raw
Quoted 10 lines · Erwan Velu

Hey Jens,

The following code is pretty confusing for me :
http://git.kernel.dk/?p=fio.git;a=blob;f=init.c;h=c3996a76c12840e3ab3cf6514e5d5dce611a1077;hb=HEAD#l1962

The "if (nr_clients && fio_clients_connect()) {" is using the do_exit concept while being after the code that manage it and does a return -1 while exit code is set to 1.

Quoted 7 lines

I don't get how it should be fixed.
1- we shall move the if nr_clients before the "if (do_exit", remove the return -1 and adjust the exit_code ?
2- we shall get rid of the do_exit & exit code semantic of the if nr_clients.

What was the intent while reading the code ? ;o)

It should probably just be turned into an exit(1) or similar exit code. The current code will work to the extent that it will properly exit, however it wont signal the error correctly in the return value.

Signature · 1 line
Jens Axboe