* [PATCH] workqueue: avoid clang warning
@ 2017-02-01 17:01 Arnd Bergmann
2017-02-02 20:28 ` Tejun Heo
2017-02-02 20:29 ` [PATCH wq/for-4.11] workqueue: clean up enum definitions in workqueue.h Tejun Heo
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-02-01 17:01 UTC (permalink / raw)
To: Tejun Heo
Cc: Arnd Bergmann, Lai Jiangshan, Sebastian Andrzej Siewior,
Thomas Gleixner, linux-kernel
Building with clang shows lots of warning like:
drivers/amba/bus.c:447:8: warning: implicit conversion from 'long long' to 'int' changes value from 4294967248 to -48
[-Wconstant-conversion]
static DECLARE_DELAYED_WORK(deferred_retry_work, amba_deferred_retry_func);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:187:26: note: expanded from macro 'DECLARE_DELAYED_WORK'
struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:177:10: note: expanded from macro '__DELAYED_WORK_INITIALIZER'
.work = __WORK_INITIALIZER((n).work, (f)), \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:170:10: note: expanded from macro '__WORK_INITIALIZER'
.data = WORK_DATA_STATIC_INIT(), \
^~~~~~~~~~~~~~~~~~~~~~~
include/linux/workqueue.h:111:39: note: expanded from macro 'WORK_DATA_STATIC_INIT'
ATOMIC_LONG_INIT(WORK_STRUCT_NO_POOL | WORK_STRUCT_STATIC)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/atomic-long.h:32:41: note: expanded from macro 'ATOMIC_LONG_INIT'
#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
~~~~~~~~~~~~^~
arch/arm/include/asm/atomic.h:21:27: note: expanded from macro 'ATOMIC_INIT'
#define ATOMIC_INIT(i) { (i) }
~ ^
This makes the type cast explicit, which shuts up the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/workqueue.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index a26cc437293c..bde063cefd04 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -106,9 +106,9 @@ struct work_struct {
#endif
};
-#define WORK_DATA_INIT() ATOMIC_LONG_INIT(WORK_STRUCT_NO_POOL)
+#define WORK_DATA_INIT() ATOMIC_LONG_INIT((unsigned long)WORK_STRUCT_NO_POOL)
#define WORK_DATA_STATIC_INIT() \
- ATOMIC_LONG_INIT(WORK_STRUCT_NO_POOL | WORK_STRUCT_STATIC)
+ ATOMIC_LONG_INIT((unsigned long)(WORK_STRUCT_NO_POOL | WORK_STRUCT_STATIC))
struct delayed_work {
struct work_struct work;
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] workqueue: avoid clang warning 2017-02-01 17:01 [PATCH] workqueue: avoid clang warning Arnd Bergmann @ 2017-02-02 20:28 ` Tejun Heo 2017-02-02 20:29 ` [PATCH wq/for-4.11] workqueue: clean up enum definitions in workqueue.h Tejun Heo 1 sibling, 0 replies; 4+ messages in thread From: Tejun Heo @ 2017-02-02 20:28 UTC (permalink / raw) To: Arnd Bergmann Cc: Lai Jiangshan, Sebastian Andrzej Siewior, Thomas Gleixner, linux-kernel On Wed, Feb 01, 2017 at 06:01:17PM +0100, Arnd Bergmann wrote: > Building with clang shows lots of warning like: > > drivers/amba/bus.c:447:8: warning: implicit conversion from 'long long' to 'int' changes value from 4294967248 to -48 ... > arch/arm/include/asm/atomic.h:21:27: note: expanded from macro 'ATOMIC_INIT' > #define ATOMIC_INIT(i) { (i) } > ~ ^ > > This makes the type cast explicit, which shuts up the warning. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Applied to wq/for-4.11. Thanks. -- tejun ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH wq/for-4.11] workqueue: clean up enum definitions in workqueue.h 2017-02-01 17:01 [PATCH] workqueue: avoid clang warning Arnd Bergmann 2017-02-02 20:28 ` Tejun Heo @ 2017-02-02 20:29 ` Tejun Heo 2017-02-02 21:56 ` Tejun Heo 1 sibling, 1 reply; 4+ messages in thread From: Tejun Heo @ 2017-02-02 20:29 UTC (permalink / raw) To: Arnd Bergmann Cc: Lai Jiangshan, Sebastian Andrzej Siewior, Thomas Gleixner, linux-kernel >From 225248f9f11895dabd86e118b69220242aece94b Mon Sep 17 00:00:00 2001 From: Tejun Heo <tj@kernel.org> Date: Thu, 2 Feb 2017 15:25:08 -0500 Consistently use UL postfix for mask calculation and drop unnecessary (unsigned long) cast from the enum definitions. Signed-off-by: Tejun Heo <tj@kernel.org> --- Arnd, I also queued this patch on top. It shouldn't change anything but can you please double check? Thanks. include/linux/workqueue.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index bde063c..1d2bce1 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -39,12 +39,12 @@ enum { WORK_STRUCT_COLOR_BITS = 4, - WORK_STRUCT_PENDING = 1 << WORK_STRUCT_PENDING_BIT, - WORK_STRUCT_DELAYED = 1 << WORK_STRUCT_DELAYED_BIT, - WORK_STRUCT_PWQ = 1 << WORK_STRUCT_PWQ_BIT, - WORK_STRUCT_LINKED = 1 << WORK_STRUCT_LINKED_BIT, + WORK_STRUCT_PENDING = 1UL << WORK_STRUCT_PENDING_BIT, + WORK_STRUCT_DELAYED = 1UL << WORK_STRUCT_DELAYED_BIT, + WORK_STRUCT_PWQ = 1UL << WORK_STRUCT_PWQ_BIT, + WORK_STRUCT_LINKED = 1UL << WORK_STRUCT_LINKED_BIT, #ifdef CONFIG_DEBUG_OBJECTS_WORK - WORK_STRUCT_STATIC = 1 << WORK_STRUCT_STATIC_BIT, + WORK_STRUCT_STATIC = 1UL << WORK_STRUCT_STATIC_BIT, #else WORK_STRUCT_STATIC = 0, #endif @@ -53,7 +53,7 @@ enum { * The last color is no color used for works which don't * participate in workqueue flushing. */ - WORK_NR_COLORS = (1 << WORK_STRUCT_COLOR_BITS) - 1, + WORK_NR_COLORS = (1UL << WORK_STRUCT_COLOR_BITS) - 1, WORK_NO_COLOR = WORK_NR_COLORS, /* not bound to any CPU, prefer the local CPU */ @@ -71,7 +71,7 @@ enum { WORK_OFFQ_FLAG_BASE = WORK_STRUCT_COLOR_SHIFT, __WORK_OFFQ_CANCELING = WORK_OFFQ_FLAG_BASE, - WORK_OFFQ_CANCELING = (1 << __WORK_OFFQ_CANCELING), + WORK_OFFQ_CANCELING = (1UL << __WORK_OFFQ_CANCELING), /* * When a work item is off queue, its high bits point to the last @@ -82,16 +82,16 @@ enum { WORK_OFFQ_POOL_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS, WORK_OFFQ_LEFT = BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT, WORK_OFFQ_POOL_BITS = WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31, - WORK_OFFQ_POOL_NONE = (1LU << WORK_OFFQ_POOL_BITS) - 1, + WORK_OFFQ_POOL_NONE = (1UL << WORK_OFFQ_POOL_BITS) - 1, /* convenience constants */ WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, - WORK_STRUCT_NO_POOL = (unsigned long)WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT, + WORK_STRUCT_NO_POOL = WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT, /* bit mask for work_busy() return values */ - WORK_BUSY_PENDING = 1 << 0, - WORK_BUSY_RUNNING = 1 << 1, + WORK_BUSY_PENDING = 1UL << 0, + WORK_BUSY_RUNNING = 1UL << 1, /* maximum string length for set_worker_desc() */ WORKER_DESC_LEN = 24, -- 2.9.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH wq/for-4.11] workqueue: clean up enum definitions in workqueue.h 2017-02-02 20:29 ` [PATCH wq/for-4.11] workqueue: clean up enum definitions in workqueue.h Tejun Heo @ 2017-02-02 21:56 ` Tejun Heo 0 siblings, 0 replies; 4+ messages in thread From: Tejun Heo @ 2017-02-02 21:56 UTC (permalink / raw) To: Arnd Bergmann Cc: Lai Jiangshan, Sebastian Andrzej Siewior, Thomas Gleixner, linux-kernel On Thu, Feb 02, 2017 at 03:29:22PM -0500, Tejun Heo wrote: > From 225248f9f11895dabd86e118b69220242aece94b Mon Sep 17 00:00:00 2001 > From: Tejun Heo <tj@kernel.org> > Date: Thu, 2 Feb 2017 15:25:08 -0500 > > Consistently use UL postfix for mask calculation and drop unnecessary > (unsigned long) cast from the enum definitions. > > Signed-off-by: Tejun Heo <tj@kernel.org> > --- > Arnd, > > I also queued this patch on top. It shouldn't change anything but can > you please double check? Ah, never mind. It does need that ulong cast. Patch dropped. Thanks. -- tejun ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-02 21:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-02-01 17:01 [PATCH] workqueue: avoid clang warning Arnd Bergmann 2017-02-02 20:28 ` Tejun Heo 2017-02-02 20:29 ` [PATCH wq/for-4.11] workqueue: clean up enum definitions in workqueue.h Tejun Heo 2017-02-02 21:56 ` Tejun Heo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox