[MPlayer-dev-eng] [PATCH] cast null pointers

Edd Barrett vext01 at gmail.com
Thu Aug 12 17:56:49 CEST 2010


Hi,

Just a small stylistic note. Null pointers for execl should be casted to
pointer types. Pointed out to me by naddy@ (http://c-faq.com/null/null2.html):

Index: mplayer.c
===================================================================
--- mplayer.c	(revision 31958)
+++ mplayer.c	(working copy)
@@ -854,7 +854,8 @@
           char spid[20];
           snprintf(spid, sizeof(spid), "%i", getppid());
           getch2_disable(); // allow terminal to work properly with gdb
-          if (execlp("gdb", "gdb", prog_path, spid, "-ex", "bt", NULL) == -1)
+          if (execlp("gdb", "gdb", prog_path, spid, "-ex", "bt",
+	    (char *) NULL) == -1)
             mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't start gdb\n");
         } else if (gdb_pid < 0)
           mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't fork\n");
Index: unrar_exec.c
===================================================================
--- unrar_exec.c	(revision 31958)
+++ unrar_exec.c	(working copy)
@@ -66,10 +66,10 @@
                 || open("/dev/null", O_WRONLY) != 2)
             _exit(EXIT_FAILURE);
         if (action == UNRAR_LIST)
-            execl(executable, executable, "v", archive, NULL);
+            execl(executable, executable, "v", archive, (char *) NULL);
         else if (action == UNRAR_EXTRACT)
             execl(executable, executable, "p", "-inul", "-p-",
-                  archive,filename,NULL);
+                  archive,filename, (char *) NULL);
         mp_msg(MSGT_GLOBAL, MSGL_ERR, "UnRAR: Cannot execute %s\n", executable);
         _exit(EXIT_FAILURE);
     }
Index: command.c
===================================================================
--- command.c	(revision 31958)
+++ command.c	(working copy)
@@ -3262,7 +3262,7 @@
         case MP_CMD_RUN:
 #ifndef __MINGW32__
             if (!fork()) {
-                execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, NULL);
+                execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, (char *) NULL);
                 exit(0);
             }
 #endif


Cheers

-- 
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk


More information about the MPlayer-dev-eng mailing list