Re: [PATCH 1/2] extcon: Use BIT() macro for the left-shift operation
From: Andy Shevchenko
Date: Thu Mar 30 2017 - 05:02:14 EST
On Thu, Mar 30, 2017 at 11:39 AM, Chanwoo Choi <cw00.choi@xxxxxxxxxxx> wrote:
> This patch just uses the BIT() macro to make the code simple.
> for (i = 0; i < edev->max_supported; i++) {
> count += sprintf(buf + count, "%s=%d\n",
> extcon_info[edev->supported_cable[i]].name,
> - !!(edev->state & (1 << i)));
> + !!(edev->state & BIT(i)));
> }
While change is okay, the above code is fragile. There is a potential
buffer overflow.
--
With Best Regards,
Andy Shevchenko