Hello there,

----------------------------------------
> Are you certain of that? The analyzer output you posted says
> "Redundant bitwise operation on 'pm' in 'switch' statement" -- that
> "redundant" seems to refer to the fact that the macro values are the
> same.

Agreed - the macro values being the same is triggering the static analyser 
error.

My mistake. Sorry. There is a similar message the analyser produces for
missing breaks which confused me.
 
>> I''m not sure if this fallthrough is intentional or not.
>
> It is. It's a not-uncommon idiom.

Agreed. Always IMHO wise to document it, though.

> Perhaps a better solution would be like this:
>
> case 1:
> pm |= CCR_PM_USBPW1;
> break;
> case 2:
> pm |= CCR_PM_USBPW1 | CCR_PM_USBPW2;
> break;
> case 3:
> pm |= CCR_PM_USBPW1 | CCR_PM_USBPW2 | CCR_PM_USBPW3;
> break;

Looks best solution to me. Maybe the only minor style quibble I have is to add 
() around
the rhs of the |=. Like

    pm |= (CCR_PM_USBPW1 | CCR_PM_USBPW2 | CCR_PM_USBPW3);

> This is okay with only three cases, but it starts to get unwieldy.

Agreed. If more cases are to be added in the future, it might be worth 
inventing some new macros.


Regards

David Binderman
                                          --
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to