[PATCH 2/2] Added 'const' attribute to all filename arguments in the API

Christophe christophe.curis at free.fr
Wed May 1 01:39:38 PDT 2013


From: Christophe CURIS <christophe.curis at free.fr>

The filename is always a read-only argument, so it is a good idea
to let the caller now about it.

This patch does not change active code; the place were the attribute
is added will not break source-level compatibility because it adds
no restriction on caller side, just adds information; because the
lib code behaved the same way it will not break the binary interface
either.
---
 include/X11/xpm.h |   20 ++++++++++----------
 src/RdFToBuf.c    |    2 +-
 src/RdFToDat.c    |    2 +-
 src/RdFToI.c      |    4 ++--
 src/RdFToP.c      |    2 +-
 src/WrFFrBuf.c    |    2 +-
 src/WrFFrDat.c    |    2 +-
 src/WrFFrI.c      |    4 ++--
 src/WrFFrP.c      |    2 +-
 9 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/include/X11/xpm.h b/include/X11/xpm.h
index 38c62d8..f108f1f 100644
--- a/include/X11/xpm.h
+++ b/include/X11/xpm.h
@@ -304,13 +304,13 @@ _XFUNCPROTOBEGIN
 
     FUNC(XpmReadFileToPixmap, int, (Display *display,
 				    Drawable d,
-				    char *filename,
+				    const char *filename,
 				    Pixmap *pixmap_return,
 				    Pixmap *shapemask_return,
 				    XpmAttributes *attributes));
 
     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
-				       char *filename,
+				       const char *filename,
 				       Pixmap pixmap,
 				       Pixmap shapemask,
 				       XpmAttributes *attributes));
@@ -329,13 +329,13 @@ _XFUNCPROTOBEGIN
 				       XpmAttributes *attributes));
 
     FUNC(XpmReadFileToImage, int, (Display *display,
-				   char *filename,
+				   const char *filename,
 				   XImage **image_return,
 				   XImage **shapeimage_return,
 				   XpmAttributes *attributes));
 
     FUNC(XpmWriteFileFromImage, int, (Display *display,
-				      char *filename,
+				      const char *filename,
 				      XImage *image,
 				      XImage *shapeimage,
 				      XpmAttributes *attributes));
@@ -365,11 +365,11 @@ _XFUNCPROTOBEGIN
 					  Pixmap shapemask,
 					  XpmAttributes *attributes));
 #endif
-    FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
-    FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
+    FUNC(XpmReadFileToBuffer, int, (const char *filename, char **buffer_return));
+    FUNC(XpmWriteFileFromBuffer, int, (const char *filename, char *buffer));
 
-    FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
-    FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
+    FUNC(XpmReadFileToData, int, (const char *filename, char ***data_return));
+    FUNC(XpmWriteFileFromData, int, (const char *filename, char **data));
 
     FUNC(XpmAttributesSize, int, (void));
     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
@@ -382,11 +382,11 @@ _XFUNCPROTOBEGIN
     FUNC(XpmLibraryVersion, int, (void));
 
     /* XpmImage functions */
-    FUNC(XpmReadFileToXpmImage, int, (char *filename,
+    FUNC(XpmReadFileToXpmImage, int, (const char *filename,
 				      XpmImage *image,
 				      XpmInfo *info));
 
-    FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
+    FUNC(XpmWriteFileFromXpmImage, int, (const char *filename,
 					 XpmImage *image,
 					 XpmInfo *info));
 #if !defined(FOR_MSW) && !defined(AMIGA)
diff --git a/src/RdFToBuf.c b/src/RdFToBuf.c
index 8501d23..7f8ebee 100644
--- a/src/RdFToBuf.c
+++ b/src/RdFToBuf.c
@@ -60,7 +60,7 @@
 
 int
 XpmReadFileToBuffer(
-    char	 *filename,
+    const char	 *filename,
     char	**buffer_return)
 {
     int fd, fcheck;
diff --git a/src/RdFToDat.c b/src/RdFToDat.c
index 87f7f1e..fa92bd4 100644
--- a/src/RdFToDat.c
+++ b/src/RdFToDat.c
@@ -39,7 +39,7 @@
 
 int
 XpmReadFileToData(
-    char	  *filename,
+    const char	  *filename,
     char	***data_return)
 {
     XpmImage image;
diff --git a/src/RdFToI.c b/src/RdFToI.c
index 83340a6..bd09611 100644
--- a/src/RdFToI.c
+++ b/src/RdFToI.c
@@ -61,7 +61,7 @@ FUNC(xpmPipeThrough, FILE*, (int fd,
 int
 XpmReadFileToImage(
     Display		 *display,
-    char		 *filename,
+    const char		 *filename,
     XImage		**image_return,
     XImage		**shapeimage_return,
     XpmAttributes	 *attributes)
@@ -104,7 +104,7 @@ XpmReadFileToImage(
 
 int
 XpmReadFileToXpmImage(
-    char	*filename,
+    const char	*filename,
     XpmImage	*image,
     XpmInfo	*info)
 {
diff --git a/src/RdFToP.c b/src/RdFToP.c
index bacedda..f829757 100644
--- a/src/RdFToP.c
+++ b/src/RdFToP.c
@@ -41,7 +41,7 @@ int
 XpmReadFileToPixmap(
     Display		*display,
     Drawable		 d,
-    char		*filename,
+    const char		*filename,
     Pixmap		*pixmap_return,
     Pixmap		*shapemask_return,
     XpmAttributes	*attributes)
diff --git a/src/WrFFrBuf.c b/src/WrFFrBuf.c
index bd1c45b..b80aa62 100644
--- a/src/WrFFrBuf.c
+++ b/src/WrFFrBuf.c
@@ -41,7 +41,7 @@
 
 int
 XpmWriteFileFromBuffer(
-    char	*filename,
+    const char	*filename,
     char	*buffer)
 {
     int fcheck, len;
diff --git a/src/WrFFrDat.c b/src/WrFFrDat.c
index dc738b9..3f40c84 100644
--- a/src/WrFFrDat.c
+++ b/src/WrFFrDat.c
@@ -39,7 +39,7 @@
 
 int
 XpmWriteFileFromData(
-    char	 *filename,
+    const char	 *filename,
     char	**data)
 {
     XpmImage image;
diff --git a/src/WrFFrI.c b/src/WrFFrI.c
index bf47481..4bcaba7 100644
--- a/src/WrFFrI.c
+++ b/src/WrFFrI.c
@@ -69,7 +69,7 @@ LFUNC(xpmDataClose, void, (xpmData *mdata));
 int
 XpmWriteFileFromImage(
     Display		*display,
-    char		*filename,
+    const char		*filename,
     XImage		*image,
     XImage		*shapeimage,
     XpmAttributes	*attributes)
@@ -99,7 +99,7 @@ XpmWriteFileFromImage(
 
 int
 XpmWriteFileFromXpmImage(
-    char	*filename,
+    const char	*filename,
     XpmImage	*image,
     XpmInfo	*info)
 {
diff --git a/src/WrFFrP.c b/src/WrFFrP.c
index 497ba56..078ea2f 100644
--- a/src/WrFFrP.c
+++ b/src/WrFFrP.c
@@ -40,7 +40,7 @@
 int
 XpmWriteFileFromPixmap(
     Display		*display,
-    char		*filename,
+    const char		*filename,
     Pixmap		 pixmap,
     Pixmap		 shapemask,
     XpmAttributes	*attributes)
-- 
1.7.10.4



More information about the xorg-devel mailing list