[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230531043826.991183-1-suhui@nfschina.com>
Date: Wed, 31 May 2023 12:38:26 +0800
From: Su Hui <suhui@...china.com>
To: Ben Skeggs <bskeggs@...hat.com>, Karol Herbst <kherbst@...hat.com>,
Lyude Paul <lyude@...hat.com>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>
Cc: airlied@...hat.com, dri-devel@...ts.freedesktop.org,
nouveau@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org, Su Hui <suhui@...china.com>
Subject: [PATCH] drm/nouveau/nvif: use struct_size()
Use struct_size() instead of hand writing it.
This is less verbose and more informative.
Signed-off-by: Su Hui <suhui@...china.com>
---
drivers/gpu/drm/nouveau/nvif/object.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c
index 4d1aaee8fe15..4bd693aa4ee0 100644
--- a/drivers/gpu/drm/nouveau/nvif/object.c
+++ b/drivers/gpu/drm/nouveau/nvif/object.c
@@ -65,7 +65,7 @@ nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass)
u32 size;
while (1) {
- size = sizeof(*args) + cnt * sizeof(args->sclass.oclass[0]);
+ size = struct_size(args, sclass.oclass, cnt);
if (!(args = kmalloc(size, GFP_KERNEL)))
return -ENOMEM;
args->ioctl.version = 0;
--
2.30.2
Powered by blists - more mailing lists