
Reinhard Meyer (-VC) wrote:
That poses the general question what a function that initializes several devices should do if one of the devices should return an error and what to return if ALL devices return an error.
I believe the consensus is that any device initialization function that returns an error is simply ignored and skipped, which is what my patch does:
for (i = 0; i < num; i++) { ret = tsec_initialize(bis, &tsecs[i]); if (ret > 0) count += ret; }
I could have done "if (ret >= 0)", but that's less efficient.
At least in the last case I would assume to return the error code of one of the devices.
But which error code? What if the first device returns -1, and the second one returns -2?
In the cases where not all, but at least one of the devices get initialized without error, the number of successful devices might be returned.
That's what we do today.
However, in most contexts that might not be helpful to the rest of the system anyway.