* [PATCH] drm/edid: make a couple of read-only arrays static const
@ 2022-11-03 13:37 Colin Ian King
2022-11-03 13:51 ` Jani Nikula
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2022-11-03 13:37 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, dri-devel
Cc: kernel-janitors, linux-kernel
Don't populate two read-only arrays on the stack but instead make
them static const . Also makes the object code a little smaller.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/gpu/drm/drm_edid.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 4671dc23abe0..50d488cc840e 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3916,8 +3916,8 @@ static int drm_cvt_modes(struct drm_connector *connector,
struct drm_display_mode *newmode;
struct drm_device *dev = connector->dev;
const struct cvt_timing *cvt;
- const int rates[] = { 60, 85, 75, 60, 50 };
- const u8 empty[3] = { 0, 0, 0 };
+ static const int rates[] = { 60, 85, 75, 60, 50 };
+ static const u8 empty[3] = { 0, 0, 0 };
for (i = 0; i < 4; i++) {
int width, height;
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/edid: make a couple of read-only arrays static const
2022-11-03 13:37 [PATCH] drm/edid: make a couple of read-only arrays static const Colin Ian King
@ 2022-11-03 13:51 ` Jani Nikula
0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2022-11-03 13:51 UTC (permalink / raw)
To: Colin Ian King, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Daniel Vetter, dri-devel
Cc: kernel-janitors, linux-kernel
On Thu, 03 Nov 2022, Colin Ian King <colin.i.king@gmail.com> wrote:
> Don't populate two read-only arrays on the stack but instead make
> them static const . Also makes the object code a little smaller.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/gpu/drm/drm_edid.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 4671dc23abe0..50d488cc840e 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3916,8 +3916,8 @@ static int drm_cvt_modes(struct drm_connector *connector,
> struct drm_display_mode *newmode;
> struct drm_device *dev = connector->dev;
> const struct cvt_timing *cvt;
> - const int rates[] = { 60, 85, 75, 60, 50 };
> - const u8 empty[3] = { 0, 0, 0 };
> + static const int rates[] = { 60, 85, 75, 60, 50 };
> + static const u8 empty[3] = { 0, 0, 0 };
The change is fine per se, but I think this whole array is silly. Could
be removed with:
- if (!memcmp(cvt->code, empty, 3))
+ if (!memchr_inv(cvt->code, 0, sizeof(cvt->code)))
BR,
Jani.
PS. I also note that rates[0] is never used, but that's another story,
maybe a bug.
>
> for (i = 0; i < 4; i++) {
> int width, height;
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-03 13:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 13:37 [PATCH] drm/edid: make a couple of read-only arrays static const Colin Ian King
2022-11-03 13:51 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).