[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <nycvar.YFH.7.76.1711211259180.11505@cbobk.fhfr.pm>
Date: Tue, 21 Nov 2017 13:00:47 +0100 (CET)
From: Jiri Kosina <jikos@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
cc: luca abeni <luca.abeni@...tannapisa.it>,
Peter Zijlstra <peterz@...radead.org>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Juri Lelli <juri.lelli@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Mike Galbraith <efault@....de>,
Steven Rostedt <rostedt@...dmis.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] sched/deadline: Use unsigned type for the state flags
Commit
799ba82de01e ("sched/deadline: Use C bitfields for the state flags")
converted state flags into one-bit signed int. Signed one-bit type can be
either 0 or -1, which is going to cause a problem once 1 is assigned to
it and then the value later tested against 1.
The current code is okay, as all the checks are (non-)zero check, but I believe
that we'd rather be safe than sorry here; remove the fragility by converting
the state flags to unsigned int, where 1 actually really is 1.
This also silences annoying sparse complaints about this very issue when
compiling any code that includes sched.h.
Fixes: 799ba82de01e ("sched/deadline: Use C bitfields for the state flags")
Cc: luca abeni <luca.abeni@...tannapisa.it>
Cc: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Daniel Bristot de Oliveira <bristot@...hat.com>
Cc: Juri Lelli <juri.lelli@....com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Mathieu Poirier <mathieu.poirier@...aro.org>
Cc: Mike Galbraith <efault@....de>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Signed-off-by: Jiri Kosina <jkosina@...e.cz>
---
v2: switch over to unsisgned int from bool, as asked for by Thomas. Feel
free to pick either of the versions
include/linux/sched.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a5dc7c98b0a2..b634da8a35a3 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -473,10 +473,10 @@ struct sched_dl_entity {
* conditions between the inactive timer handler and the wakeup
* code.
*/
- int dl_throttled : 1;
- int dl_boosted : 1;
- int dl_yielded : 1;
- int dl_non_contending : 1;
+ unsigned int dl_throttled : 1;
+ unsigned int dl_boosted : 1;
+ unsigned int dl_yielded : 1;
+ unsigned int dl_non_contending : 1;
/*
* Bandwidth enforcement timer. Each -deadline task has its
--
Jiri Kosina
SUSE Labs
Powered by blists - more mailing lists