Home Home > GIT Browse > openSUSE-15.1
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-05-13 15:48:49 +0200
committerTakashi Iwai <tiwai@suse.de>2019-05-15 11:46:07 +0200
commit8a701512f48853cea33e275ac4f9cd77352cda2a (patch)
treeff4f099fad8a3e489accdfb9c23310c3499fca40
parent61795dbb49a7ede40acbfb95f4fbd2b71f3d5350 (diff)
overflow: Fix -Wtype-limits compilation warnings (bsc#1111666).
-rw-r--r--patches.fixes/overflow-Fix-Wtype-limits-compilation-warnings.patch78
-rw-r--r--series.conf1
2 files changed, 79 insertions, 0 deletions
diff --git a/patches.fixes/overflow-Fix-Wtype-limits-compilation-warnings.patch b/patches.fixes/overflow-Fix-Wtype-limits-compilation-warnings.patch
new file mode 100644
index 0000000000..9431d7b3ab
--- /dev/null
+++ b/patches.fixes/overflow-Fix-Wtype-limits-compilation-warnings.patch
@@ -0,0 +1,78 @@
+From dc7fe518b0493faa0af0568d6d8c2a33c00f58d0 Mon Sep 17 00:00:00 2001
+From: Leon Romanovsky <leonro@mellanox.com>
+Date: Sun, 17 Mar 2019 12:11:14 +0200
+Subject: [PATCH] overflow: Fix -Wtype-limits compilation warnings
+Git-commit: dc7fe518b0493faa0af0568d6d8c2a33c00f58d0
+Patch-mainline: v5.2-rc1
+References: bsc#1111666
+
+Attempt to use check_shl_overflow() with inputs of unsigned type
+produces the following compilation warnings.
+
+Drivers/infiniband/hw/mlx5/qp.c: In function _set_user_rq_size_:
+./include/linux/overflow.h:230:6: warning: comparison of unsigned
+expression >= 0 is always true [-Wtype-limits]
+ _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0; \
+ ^~
+drivers/infiniband/hw/mlx5/qp.c:5820:6: note: in expansion of macro _check_shl_overflow_
+ if (check_shl_overflow(rwq->wqe_count, rwq->wqe_shift,
+&rwq->buf_size))
+ ^~~~~~~~~~~~~~~~~~
+./include/linux/overflow.h:232:26: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
+ (_to_shift != _s || *_d < 0 || _a < 0 || \
+ ^
+drivers/infiniband/hw/mlx5/qp.c:5820:6: note: in expansion of macro _check_shl_overflow_
+ if (check_shl_overflow(rwq->wqe_count, rwq->wqe_shift, &rwq->buf_size))
+ ^~~~~~~~~~~~~~~~~~
+./include/linux/overflow.h:232:36: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
+ (_to_shift != _s || *_d < 0 || _a < 0 || \
+ ^
+drivers/infiniband/hw/mlx5/qp.c:5820:6: note: in expansion of macro _check_shl_overflow_
+ if (check_shl_overflow(rwq->wqe_count, rwq->wqe_shift,&rwq->buf_size))
+ ^~~~~~~~~~~~~~~~~~
+
+Fixes: 0c66847793d1 ("overflow.h: Add arithmetic shift helper")
+Reviewed-by: Bart Van Assche <bvanassche@acm.org>
+Acked-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
+Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/linux/overflow.h | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/include/linux/overflow.h b/include/linux/overflow.h
+index 40b48e2133cb..15eb85de9226 100644
+--- a/include/linux/overflow.h
++++ b/include/linux/overflow.h
+@@ -36,6 +36,12 @@
+ #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
+ #define type_min(T) ((T)((T)-type_max(T)-(T)1))
+
++/*
++ * Avoids triggering -Wtype-limits compilation warning,
++ * while using unsigned data types to check a < 0.
++ */
++#define is_non_negative(a) ((a) > 0 || (a) == 0)
++#define is_negative(a) (!(is_non_negative(a)))
+
+ #ifdef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
+ /*
+@@ -227,10 +233,10 @@
+ typeof(d) _d = d; \
+ u64 _a_full = _a; \
+ unsigned int _to_shift = \
+- _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0; \
++ is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \
+ *_d = (_a_full << _to_shift); \
+- (_to_shift != _s || *_d < 0 || _a < 0 || \
+- (*_d >> _to_shift) != _a); \
++ (_to_shift != _s || is_negative(*_d) || is_negative(_a) || \
++ (*_d >> _to_shift) != _a); \
+ })
+
+ /**
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 725277d72b..f02a36edc7 100644
--- a/series.conf
+++ b/series.conf
@@ -45673,6 +45673,7 @@
patches.drm/drm-i915-icl-Whitelist-GEN9_SLICE_COMMON_ECO_CHICKEN.patch
patches.drivers/ALSA-hda-realtek-Support-low-power-consumption-for-A.patch
patches.drivers/ALSA-hda-realtek-Support-low-power-consumption-ALC256.patch
+ patches.fixes/overflow-Fix-Wtype-limits-compilation-warnings.patch
# davem/net-next
patches.drivers/ibmvnic-Report-actual-backing-device-speed-and-duple.patch