Re: [PATCH 7/8] Psmouse - add packet size

From: Vojtech Pavlik
Date: Wed Sep 29 2004 - 08:44:27 EST


On Wed, Sep 29, 2004 at 08:24:58AM -0500, Dmitry Torokhov wrote:

> I have been battling with myself about whether to keep them consistent
> with probe/init or make them as they are today... My issue with
> *detect returning -1 on failure is that the caller's code will look
> like:
>
> if (max_proto >= PSMOUSE_IMPS && !intellimouse_detect(psmouse, set_properties))
> return PSMOUSE_IMPS;
>
> or
>
> if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0)
> return PSMOUSE_IMPS;
>
> which does not flow for me when I read the code. With pretty much every
> other function caller checks for negative and exits in case of error, it
> reads naturally as well. Here with multiple btanches I go "... and
> intellimouse is NOT detected... oh, wait, it IS detected..."

Well, yeah. I kinda got used to that reversed logic after a while.

> Oh, well. I guess I will convert them... unless I managed to presuade you
> to keep them as is ;).

Well, I understand your point, but I still think it's worth keeping the
return values consistent with the rest of the probe routines, because if
not, THEN you (or some other reader) would get used to the
positive-style returns with the protocol detection routines and
definitely understand it wrong elsewhere.

--
Vojtech Pavlik
SuSE Labs, SuSE CR
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/