A typical sequence is like the one to set the bus width.
err = sdio_select(rca);
if (! err) {
err = sdio_command(55, rca << 16);
if (! err) {
err = sdio_command(6, 2);
}
}
sdio_deslect();
return err;
I had originally done it the other way err = sdio_select(rca);
if (err) {
return err;
}
err = sdio_command(55, rca << 16);
if (err) {
sdio_deselect();
return err;
}
err = sdio_command(6, 2);
sdio_deselect();
return err;
I find the first form more readable. It also generates
fewer branches in the generated code. The sample code I first looked at was doing Goto's to the exit code (deselect/return error) which was unacceptable :-).In the original article the confusion arose around negative test cases and then testing for them negatively (double negatives) which I think are always bad from a readability point of view.