[En-Nut-Discussion] Evaluating USART IOCTL errors
harald.kipp at egnite.de
Tue Jul 3 10:46:07 CEST 2012
On 02.07.2012 17:52, Uwe Bonnes wrote:
> our dev/usart.c IOCTL setting code doesn't honor if the lower level device
> driver signals some error. Even if the lower level driver is unable to
> fullfill the flag, the flag remains set.
Indeed, that's a bug.
> Is appended way of coding the right thing? It handles the
> dcb_set_flow_control cases. Only setting a feature might fail.
You probably have some doubts, because you asked. :-) To me the code doesn't look optimal, first resetting or setting the flag, then resetting it on an error. What, if the reset fails?
Another, minor comment
if (rc == -1)
may generate more instruction code than
which is sufficient, as the called function clearly states, that 0 is returned on success.
But how about
lv = dcb->dcb_modeflags;
lv |= USART_MF_LOCALECHO;
lv &= ~USART_MF_LOCALECHO;
if ((dcb->dcb_set_flow_control) (lv) == 0)
dcb->dcb_modeflags = lv;
P.S.: AFAIK the listserver silently removes attachments. No idea, how you managed to convince him, that _your_ attachment is harmless.
More information about the En-Nut-Discussion