Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1507313 > unrolled thread
| Started by | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| First post | 2016-10-24 17:40 +0200 |
| Last post | 2016-10-24 18:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] nouveau: hide gcc-4.9 -Wmaybe-uninitialized Arnd Bergmann <arnd@arndb.de> - 2016-10-24 17:40 +0200
Re: [Nouveau] [PATCH] nouveau: hide gcc-4.9 -Wmaybe-uninitialized Karol Herbst <karolherbst@gmail.com> - 2016-10-24 18:00 +0200
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-10-24 17:40 +0200 |
| Subject | [PATCH] nouveau: hide gcc-4.9 -Wmaybe-uninitialized |
| Message-ID | <svPvY-14z-9@gated-at.bofh.it> |
gcc-4.9 notices that the validate_init() function returns unintialized
data when called with a zero 'nr_buffers' argument, when called with the
-Wmaybe-uninitialized flag:
drivers/gpu/drm/nouveau/nouveau_gem.c: In function ‘validate_init.isra.6’:
drivers/gpu/drm/nouveau/nouveau_gem.c:457:5: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
However, the only caller of this function always passes a nonzero
argument, and gcc-6 is clever enough to take this into account and
not warn about it any more.
Adding an explicit initialization to -EINVAL here is correct even if
the caller changed, and it avoids the warning on gcc-4.9 as well.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 0bd7164bc817..4f3c5f3eaa16 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -369,7 +369,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
{
struct nouveau_cli *cli = nouveau_cli(file_priv);
int trycnt = 0;
- int ret, i;
+ int ret = -EINVAL, i;
struct nouveau_bo *res_bo = NULL;
LIST_HEAD(gart_list);
LIST_HEAD(vram_list);
--
2.9.0
[toc] | [next] | [standalone]
| From | Karol Herbst <karolherbst@gmail.com> |
|---|---|
| Date | 2016-10-24 18:00 +0200 |
| Subject | Re: [Nouveau] [PATCH] nouveau: hide gcc-4.9 -Wmaybe-uninitialized |
| Message-ID | <svPPj-1bs-13@gated-at.bofh.it> |
| In reply to | #1507313 |
uhh, that function looks so odd, ... yeah. Change looks fine.
Reviewed-By: Karol Herbst <karolherbst@gmail.com>
2016-10-24 17:30 GMT+02:00 Arnd Bergmann <arnd@arndb.de>:
> gcc-4.9 notices that the validate_init() function returns unintialized
> data when called with a zero 'nr_buffers' argument, when called with the
> -Wmaybe-uninitialized flag:
>
> drivers/gpu/drm/nouveau/nouveau_gem.c: In function ‘validate_init.isra.6’:
> drivers/gpu/drm/nouveau/nouveau_gem.c:457:5: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> However, the only caller of this function always passes a nonzero
> argument, and gcc-6 is clever enough to take this into account and
> not warn about it any more.
>
> Adding an explicit initialization to -EINVAL here is correct even if
> the caller changed, and it avoids the warning on gcc-4.9 as well.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index 0bd7164bc817..4f3c5f3eaa16 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -369,7 +369,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
> {
> struct nouveau_cli *cli = nouveau_cli(file_priv);
> int trycnt = 0;
> - int ret, i;
> + int ret = -EINVAL, i;
> struct nouveau_bo *res_bo = NULL;
> LIST_HEAD(gart_list);
> LIST_HEAD(vram_list);
> --
> 2.9.0
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web