Skip to contentSkip to conversation

fbcmap.c: mark structs const or __read_mostly

PATCH In review Helge Deller 2 participants 3 messages Sep 14, 2006 Framebuffer layer

lore
Share & tools
lore

Helge Deller

author maintainer
#0 lore raw

PATCH 1/5 fbcmap.c: mark structs const or __read_mostly

- Mark the default colormaps read-only, as nobody should be allowed to modify them
- Additionally mark color values as __read_mostly since they will only be modified (very seldom) by fb_invert_cmaps()
- Add named initializers in fb_cmap structs and use the ARRAY_SIZE() macro

- Mark the default colormaps read-only, as nobody should be allowed to modify them
- Additionally mark color values as __read_mostly since they will only be modified (very seldom) by fb_invert_cmaps()
- Add named initializers in fb_cmap structs and use the ARRAY_SIZE() macro

include/linux/fb.h +3 -3
index 2f335e9..15eaf4b 100644
@@ -967,11 +967,11 @@ extern struct fb_videomode *fb_find_best
 /* drivers/video/fbcmap.c */
 extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
 extern void fb_dealloc_cmap(struct fb_cmap *cmap);
-extern int fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to);
-extern int fb_cmap_to_user(struct fb_cmap *from, struct fb_cmap_user *to);
+extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
+extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
 extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
 extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
-extern struct fb_cmap *fb_default_cmap(int len);
+extern const struct fb_cmap *fb_default_cmap(int len);
 extern void fb_invert_cmaps(void);
 
 struct fb_videomode {
drivers/video/fbcmap.c +28 -27

134 lines not on this page · raw message

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

#1 lore raw
Quoted 12 lines · Helge Deller

- Add named initializers in fb_cmap structs and use the ARRAY_SIZE() macro

drivers/video/fbcmap.c +4 -4
-static struct fb_cmap default_2_colors = {
-    0, 2, red2, green2, blue2, NULL
+static const struct fb_cmap default_2_colors = {
+    len:2, red:red2, green:green2, blue:blue2
 };
-static struct fb_cmap default_8_colors = {
-    0, 8, red8, green8, blue8, NULL
+static const struct fb_cmap default_8_colors = {
+    len:8, red:red8, green:green8, blue:blue8
 };

drivers/video/fbcmap.c line 75

Quoted 10 lines
drivers/video/fbcmap.c +4 -4
-static struct fb_cmap default_4_colors = {
-    0, 4, red4, green4, blue4, NULL
+static const struct fb_cmap default_4_colors = {
+    len:4, red:red4, green:green4, blue:blue4
 };
-static struct fb_cmap default_16_colors = {
-    0, 16, red16, green16, blue16, NULL
+static const struct fb_cmap default_16_colors = {
+    len:16, red:red16, green:green16, blue:blue16
 };

Please use the C99 variant instead of the obsolete GNU variant.

Gr{oetje,eeting}s,

Geert

P.S. Please inline your patches, to facilitate adding review comments. --
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

author maintainer
#2 lore raw
In reply to Helge Deller

(resent with fixed C99 style inizializers as noticed by Geert Uytterhoeven)

- Mark the default colormaps read-only, as nobody should be allowed to modify them
- Additionally mark color values as __read_mostly since they will only be modified (very seldom) by fb_invert_cmaps()
- Add named C99-initializers in fb_cmap structs and use the ARRAY_SIZE() macro

- Mark the default colormaps read-only, as nobody should be allowed to modify them
- Additionally mark color values as __read_mostly since they will only be modified (very seldom) by fb_invert_cmaps()
- Add named C99-initializers in fb_cmap structs and use the ARRAY_SIZE() macro

include/linux/fb.h +3 -3
index 2f335e9..15eaf4b 100644
@@ -967,11 +967,11 @@ extern struct fb_videomode *fb_find_best
 /* drivers/video/fbcmap.c */
 extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
 extern void fb_dealloc_cmap(struct fb_cmap *cmap);
-extern int fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to);
-extern int fb_cmap_to_user(struct fb_cmap *from, struct fb_cmap_user *to);
+extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
+extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
 extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
 extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
-extern struct fb_cmap *fb_default_cmap(int len);
+extern const struct fb_cmap *fb_default_cmap(int len);
 extern void fb_invert_cmaps(void);
 
 struct fb_videomode {
drivers/video/fbcmap.c +28 -27

134 lines not on this page · raw message

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel