[MPlayer-dev-eng] [patch] more const for function parameters & return values

Stefan Huehner stefan at huehner.org
Sun Jul 16 02:25:14 CEST 2006


On Sat, Jul 15, 2006 at 07:41:58PM +0200, Stefan Huehner wrote:
> Hi,
> 
> attached patch marks several read-only string parameters and function
> return-values which can only be used read-only  as const.

Splitted. Attached is first part (everthing as before, without an
unrelated cast).

Regards,
Stefan

-------------- next part --------------
Index: libaf/af_format.h
===================================================================
--- libaf/af_format.h	(revision 19112)
+++ libaf/af_format.h	(working copy)
@@ -84,11 +84,11 @@
 #define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_LE
 #endif
 
-extern int af_str2fmt(char *str);
-extern int af_str2fmt_short(char *str);
+extern int af_str2fmt(const char *str);
+extern int af_str2fmt_short(const char *str);
 extern int af_fmt2bits(int format);
 extern int af_bits2fmt(int bits);
 extern char* af_fmt2str(int format, char* str, int size);
-extern char* af_fmt2str_short(int format);
+extern const char* af_fmt2str_short(int format);
 
 #endif /* __af_format_h__ */
Index: libaf/format.c
===================================================================
--- libaf/format.c	(revision 19112)
+++ libaf/format.c	(working copy)
@@ -19,7 +19,7 @@
 #include "help_mp.h"
 
 // Convert from string to format
-int af_str2fmt(char* str)
+int af_str2fmt(const char* str)
 {
   int format=0;
   // Scan for endianess
@@ -178,7 +178,7 @@
     { NULL, 0 }
 };
 
-char *af_fmt2str_short(int format)
+const char *af_fmt2str_short(int format)
 {
     int i;
 
@@ -189,7 +189,7 @@
     return "??";
 }
 
-int af_str2fmt_short(char* str)
+int af_str2fmt_short(const char* str)
 {
     int i;
 
Index: libmpcodecs/img_format.c
===================================================================
--- libmpcodecs/img_format.c	(revision 19112)
+++ libmpcodecs/img_format.c	(working copy)
@@ -1,7 +1,7 @@
 #include "config.h"
 #include "img_format.h"
 
-char *vo_format_name(int format)
+const char *vo_format_name(int format)
 {
     switch(format)
     {
Index: libmpcodecs/img_format.h
===================================================================
--- libmpcodecs/img_format.h	(revision 19112)
+++ libmpcodecs/img_format.h	(working copy)
@@ -114,6 +114,6 @@
     int timestamp; // pts, 90000 Hz counter based
 } vo_mpegpes_t;
 
-char *vo_format_name(int format);
+const char *vo_format_name(int format);
 
 #endif
Index: libmpdemux/asfheader.c
===================================================================
--- libmpdemux/asfheader.c	(revision 19112)
+++ libmpdemux/asfheader.c	(working copy)
@@ -77,7 +77,7 @@
   mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", name, string);
 }
 
-static char* asf_chunk_type(unsigned char* guid) {
+static const char* asf_chunk_type(unsigned char* guid) {
   static char tmp[60];
   char *p;
   int i;
Index: libmpdemux/librtsp/rtsp.c
===================================================================
--- libmpdemux/librtsp/rtsp.c	(revision 19112)
+++ libmpdemux/librtsp/rtsp.c	(working copy)
@@ -705,7 +705,7 @@
 
 }
 
-char *rtsp_get_param(rtsp_t *s, char *p) {
+char *rtsp_get_param(rtsp_t *s, const char *p) {
   int len;
   char *param;
   if (!s->param)
Index: libmpdemux/librtsp/rtsp.h
===================================================================
--- libmpdemux/librtsp/rtsp.h	(revision 19112)
+++ libmpdemux/librtsp/rtsp.h	(working copy)
@@ -72,7 +72,7 @@
 char *rtsp_get_session(rtsp_t *s);
 
 char *rtsp_get_mrl(rtsp_t *s);
-char *rtsp_get_param(rtsp_t *s, char *param);
+char *rtsp_get_param(rtsp_t *s, const char *param);
 
 /*int      rtsp_peek_header (rtsp_t *this, char *data); */
 
Index: libmpdemux/network.c
===================================================================
--- libmpdemux/network.c	(revision 19112)
+++ libmpdemux/network.c	(working copy)
@@ -117,7 +117,7 @@
 
 // Converts an address family constant to a string
 
-char *af2String(int af) {
+const char *af2String(int af) {
 	switch (af) {
 		case AF_INET:	return "AF_INET";
 		
Index: libmpdemux/tvi_v4l2.c
===================================================================
--- libmpdemux/tvi_v4l2.c	(revision 19112)
+++ libmpdemux/tvi_v4l2.c	(working copy)
@@ -213,7 +213,7 @@
 ** Translate a video4linux2 fourcc aka pixel format
 ** to a human readable string.
 */
-static char *pixfmt2name(int pixfmt)
+static const char *pixfmt2name(int pixfmt)
 {
     static char unknown[24];
 
Index: libvo/video_out.h
===================================================================
--- libvo/video_out.h	(revision 19112)
+++ libvo/video_out.h	(working copy)
@@ -166,7 +166,7 @@
 
 } vo_functions_t;
 
-char *vo_format_name(int format);
+const char *vo_format_name(int format);
 int vo_init(void);
 
 vo_functions_t* init_best_video_out(char** vo_list);


More information about the MPlayer-dev-eng mailing list