From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751790AbdKUKwx (ORCPT ); Tue, 21 Nov 2017 05:52:53 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:33866 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751429AbdKUKww (ORCPT ); Tue, 21 Nov 2017 05:52:52 -0500 Date: Tue, 21 Nov 2017 11:52:37 +0100 (CET) From: Thomas Gleixner To: Jiri Kosina cc: luca abeni , Peter Zijlstra , Daniel Bristot de Oliveira , Juri Lelli , Linus Torvalds , Mathieu Poirier , Mike Galbraith , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/deadline: Use bools for the state flags In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Nov 2017, Jiri Kosina wrote: > From: Jiri Kosina > > 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 bool. > > This also silences annoying sparse complaints about this very issue when > compiling any code that includes sched.h. What's wrong with making these bitfields 'unsigned int' ? > diff --git a/include/linux/sched.h b/include/linux/sched.h > index a5dc7c98b0a2..b19fa1b96726 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; > + bool dl_throttled; > + bool dl_boosted; > + bool dl_yielded; > + bool dl_non_contending; Thanks, tglx