Re: [PATCH] sched/deadline: Don't use dubious signed bitfields
From: Dan Carpenter
Date: Fri Oct 13 2017 - 06:37:36 EST
On Fri, Oct 13, 2017 at 09:36:06AM +0200, Luca Abeni wrote:
> Hi,
>
> On Fri, 13 Oct 2017 10:01:22 +0300
> Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> > It doesn't cause a run-time bug, but these bitfields should be unsigned.
> > When it's signed ->dl_throttled is set to either 0 or -1, instead of
> > 0 and 1 as expected. The sched.h file is included into tons of places
> > so Sparse generates a flood of warnings like this:
> >
> > ./include/linux/sched.h:477:54: error: dubious one-bit signed bitfield
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>
> I did not notice any issue when testing
Correct. It would only cause a bug if we had a condition like:
if (foo->dl_throttled == 1) {
That would be impossible because ->dl_throttled == -1, but since the
conditions are all in the form:
if (foo->dl_throttled) {
Then that works for both 1 and -1.
regards,
dan carpenter