On Mon, Oct 10, 2011 at 09:52:10PM +0100, Przemo Firszt wrote:
> Hi,
> I need some advice, which one is "better".
> "IF" version:
> if ((data[0] == 0x03) | (data[0] == 0x04)) {
>         wacom_i4_parse_report(hdev, wdata, input, data + 1);
>         wacom_i4_parse_report(hdev, wdata, input, data + 11);
>         if (data[0] == 0x04)
>                 wacom_i4_parse_report(hdev, wdata, input, data + 21);
> } else {
>         hid_err(hdev, "Unknown report: %d,%d size:%d\n",data[0],
>                             data[1], size);
>         return 0;
> }
> 
> "SWITCH" version:
> i = 1;
> switch(data[0]) {
> case 0x04:
>         wacom_i4_parse_report(hdev, wdata, input, data + i);
>         i = i + 10;
>         /* fall through */
> case 0x03:
>         wacom_i4_parse_report(hdev, wdata, input, data + i);
>         i = i + 10;
>         wacom_i4_parse_report(hdev, wdata, input, data + i);
>         break;
> default:
>         hid_err(hdev, "Unknown report: %d,%d size:%d\n",data[0],
>                         data[1], size);
>         return 0;
> }
> 
> Both do the same. Any opinions or better options?


I'd go for the second one (using i += 10 too ;) because it's less nesting.
but this is kernel code and coding style is something very subjective.

Cheers,
  Peter

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to