[mplayer-dev at kernel.dk: [MPlayer-dev-eng] [PATCH] sizeof(int) != sizeof(pointer)]
Jens Axboe
mplayer-dev at kernel.dk
Wed Mar 12 13:38:20 CET 2003
On Wed, Mar 12 2003, Jens Axboe wrote:
> On Wed, Mar 12 2003, D Richard Felker III wrote:
> > On Wed, Mar 12, 2003 at 11:46:10AM +0100, Jens Axboe wrote:
> > >
> > > Is someone going to commit this or not? It's clearly a bug.
> > >
> > > ----- Forwarded message from Jens Axboe <mplayer-dev at kernel.dk> -----
> > >
> > > From: Jens Axboe <mplayer-dev at kernel.dk>
> > > Reply-To: mplayer-dev-eng at mplayerhq.hu
> > > Date: Tue, 11 Mar 2003 10:39:28 +0100
> > > To: mplayer-dev-eng at mplayerhq.hu
> > > Subject: [MPlayer-dev-eng] [PATCH] sizeof(int) != sizeof(pointer)
> > >
> > > Hi,
> > >
> > > Should not need a lot of comments, this is pretty basic. Though shallt
> > > not cast pointers to ints, on 64-bit archs this is really bad. Below
> > > patch fixes segfault on volume up/down for me with mplayer cvs.
> >
> > There is definitely a bug but this is not the correct fix. A quick
> > glance seems to indicate that the second argument to control() is
> > always a pointer, so it should just be declared to take a void *!!!
> > 1000l to whoever wrote that mess!
>
> Well that is fine, fix it that way if you want. As long as it will hold
> a pointer. void * is just as, if not more so, ugly as unsigned long,
> though :)
Since I'm such a nice guy, I updated the patch to accommodate your
wishes.
Index: mixer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mixer.c,v
retrieving revision 1.12
diff -u -r1.12 mixer.c
--- mixer.c 6 Jun 2002 07:13:42 -0000 1.12
+++ mixer.c 12 Mar 2003 12:52:00 -0000
@@ -22,7 +22,7 @@
ao_control_vol_t vol;
*l=0; *r=0;
if(audio_out){
- if(CONTROL_OK != audio_out->control(AOCONTROL_GET_VOLUME,(int)&vol))
+ if(CONTROL_OK != audio_out->control(AOCONTROL_GET_VOLUME,&vol))
return;
*r=vol.right;
*l=vol.left;
@@ -34,7 +34,7 @@
ao_control_vol_t vol;
vol.right=r; vol.left=l;
if(audio_out){
- if(CONTROL_OK != audio_out->control(AOCONTROL_SET_VOLUME,(int)&vol))
+ if(CONTROL_OK != audio_out->control(AOCONTROL_SET_VOLUME,&vol))
return;
}
muted=0;
Index: libao2/ao_alsa5.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa5.c,v
retrieving revision 1.13
diff -u -r1.13 ao_alsa5.c
--- libao2/ao_alsa5.c 1 Nov 2002 17:46:42 -0000 1.13
+++ libao2/ao_alsa5.c 12 Mar 2003 12:52:00 -0000
@@ -32,7 +32,7 @@
static int alsa_rate = SND_PCM_RATE_CONTINUOUS;
/* to set/get/query special features/parameters */
-static int control(int cmd, int arg)
+static int control(int cmd, void *arg)
{
return(CONTROL_UNKNOWN);
}
Index: libao2/ao_alsa9.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa9.c,v
retrieving revision 1.30
diff -u -r1.30 ao_alsa9.c
--- libao2/ao_alsa9.c 10 Jan 2003 18:28:18 -0000 1.30
+++ libao2/ao_alsa9.c 12 Mar 2003 12:52:00 -0000
@@ -79,7 +79,7 @@
/* to set/get/query special features/parameters */
-static int control(int cmd, int arg)
+static int control(int cmd, void *arg)
{
switch(cmd) {
case AOCONTROL_QUERY_FORMAT:
Index: libao2/ao_arts.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_arts.c,v
retrieving revision 1.4
diff -u -r1.4 ao_arts.c
--- libao2/ao_arts.c 27 Dec 2002 16:35:29 -0000 1.4
+++ libao2/ao_arts.c 12 Mar 2003 12:52:00 -0000
@@ -34,7 +34,7 @@
LIBAO_EXTERN(arts)
-static int control(int cmd, int arg)
+static int control(int cmd, void *arg)
{
return(CONTROL_UNKNOWN);
}
Index: libao2/ao_dxr2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_dxr2.c,v
retrieving revision 1.3
diff -u -r1.3 ao_dxr2.c
--- libao2/ao_dxr2.c 17 May 2002 23:51:36 -0000 1.3
+++ libao2/ao_dxr2.c 12 Mar 2003 12:52:01 -0000
@@ -28,7 +28,7 @@
extern int dxr2_fd;
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_GET_VOLUME:
if(dxr2_fd > 0) {
Index: libao2/ao_esd.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_esd.c,v
retrieving revision 1.2
diff -u -r1.2 ao_esd.c
--- libao2/ao_esd.c 28 Dec 2002 18:51:08 -0000 1.2
+++ libao2/ao_esd.c 12 Mar 2003 12:52:01 -0000
@@ -74,7 +74,7 @@
/*
* to set/get/query special features/parameters
*/
-static int control(int cmd, int arg)
+static int control(int cmd, void *arg)
{
esd_player_info_t *esd_pi;
esd_info_t *esd_i;
Index: libao2/ao_mpegpes.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_mpegpes.c,v
retrieving revision 1.17
diff -u -r1.17 ao_mpegpes.c
--- libao2/ao_mpegpes.c 12 Feb 2003 23:26:12 -0000 1.17
+++ libao2/ao_mpegpes.c 12 Mar 2003 12:52:01 -0000
@@ -49,7 +49,7 @@
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
#ifdef HAVE_DVB
switch(cmd){
case AOCONTROL_GET_VOLUME:
Index: libao2/ao_nas.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_nas.c,v
retrieving revision 1.11
diff -u -r1.11 ao_nas.c
--- libao2/ao_nas.c 24 Nov 2002 23:13:15 -0000 1.11
+++ libao2/ao_nas.c 12 Mar 2003 12:52:01 -0000
@@ -333,7 +333,7 @@
}
// to set/get/query special features/parameters
-static int control(int cmd, int arg)
+static int control(int cmd, void *arg)
{
AuDeviceAttributes *dattr;
AuFixedPoint fpgain;
Index: libao2/ao_null.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_null.c,v
retrieving revision 1.9
diff -u -r1.9 ao_null.c
--- libao2/ao_null.c 22 Sep 2002 02:33:24 -0000 1.9
+++ libao2/ao_null.c 12 Mar 2003 12:52:01 -0000
@@ -41,7 +41,7 @@
}
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
return -1;
}
Index: libao2/ao_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_oss.c,v
retrieving revision 1.38
diff -u -r1.38 ao_oss.c
--- libao2/ao_oss.c 28 Jan 2003 17:25:53 -0000 1.38
+++ libao2/ao_oss.c 12 Mar 2003 12:52:01 -0000
@@ -39,7 +39,7 @@
char *oss_mixer_device = PATH_DEV_MIXER;
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_SET_DEVICE:
dsp=(char*)arg;
Index: libao2/ao_pcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_pcm.c,v
retrieving revision 1.16
diff -u -r1.16 ao_pcm.c
--- libao2/ao_pcm.c 4 Feb 2003 18:22:43 -0000 1.16
+++ libao2/ao_pcm.c 12 Mar 2003 12:52:01 -0000
@@ -68,7 +68,7 @@
static FILE *fp = NULL;
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
return -1;
}
Index: libao2/ao_plugin.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_plugin.c,v
retrieving revision 1.22
diff -u -r1.22 ao_plugin.c
--- libao2/ao_plugin.c 18 Jan 2003 01:06:05 -0000 1.22
+++ libao2/ao_plugin.c 12 Mar 2003 12:52:01 -0000
@@ -44,10 +44,10 @@
ao_plugin_cfg_t ao_plugin_cfg=CFG_DEFAULTS; // Set in cfg-mplayer.h
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_SET_PLUGIN_DRIVER:
- ao_plugin_local_data.driver=(ao_functions_t*)arg;
+ ao_plugin_local_data.driver=arg;
return CONTROL_OK;
case AOCONTROL_GET_VOLUME:
case AOCONTROL_SET_VOLUME:
Index: libao2/ao_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sdl.c,v
retrieving revision 1.21
diff -u -r1.21 ao_sdl.c
--- libao2/ao_sdl.c 1 Nov 2002 17:46:42 -0000 1.21
+++ libao2/ao_sdl.c 12 Mar 2003 12:52:01 -0000
@@ -113,7 +113,7 @@
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch (cmd) {
case AOCONTROL_GET_VOLUME:
{
Index: libao2/ao_sgi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sgi.c,v
retrieving revision 1.2
diff -u -r1.2 ao_sgi.c
--- libao2/ao_sgi.c 24 Nov 2001 05:21:22 -0000 1.2
+++ libao2/ao_sgi.c 12 Mar 2003 12:52:01 -0000
@@ -27,7 +27,7 @@
static ALport ao_port;
// to set/get/query special features/parameters
-static int control(int cmd, int arg){
+static int control(int cmd, void *arg){
printf("ao_sgi, control\n");
Index: libao2/ao_sun.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sun.c,v
retrieving revision 1.23
diff -u -r1.23 ao_sun.c
--- libao2/ao_sun.c 1 Nov 2002 17:46:42 -0000 1.23
+++ libao2/ao_sun.c 12 Mar 2003 12:52:01 -0000
@@ -376,7 +376,7 @@
}
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_SET_DEVICE:
audio_dev=(char*)arg;
Index: libao2/ao_win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_win32.c,v
retrieving revision 1.2
diff -u -r1.2 ao_win32.c
--- libao2/ao_win32.c 30 Dec 2002 13:52:29 -0000 1.2
+++ libao2/ao_win32.c 12 Mar 2003 12:52:01 -0000
@@ -64,7 +64,7 @@
}
// to set/get/query special features/parameters
-static int control(int cmd,int arg)
+static int control(int cmd,void *arg)
{
DWORD volume;
switch (cmd)
Index: libao2/audio_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.c,v
retrieving revision 1.32
diff -u -r1.32 audio_out.c
--- libao2/audio_out.c 3 Jan 2003 05:10:29 -0000 1.32
+++ libao2/audio_out.c 12 Mar 2003 12:52:01 -0000
@@ -124,7 +124,7 @@
if(!strcmp(audio_out->info->short_name,ao)){
// name matches, try it
if(use_plugin){
- audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out);
+ audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out);
audio_out=&audio_out_plugin;
}
if(audio_out->init(rate,channels,format,flags))
@@ -140,7 +140,7 @@
for(i=0;audio_out_drivers[i];i++){
ao_functions_t* audio_out=audio_out_drivers[i];
if(use_plugin){
- audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out);
+ audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out);
audio_out=&audio_out_plugin;
}
if(audio_out->init(rate,channels,format,flags))
Index: libao2/audio_out.h
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.h,v
retrieving revision 1.11
diff -u -r1.11 audio_out.h
--- libao2/audio_out.h 29 Sep 2002 22:57:54 -0000 1.11
+++ libao2/audio_out.h 12 Mar 2003 12:52:01 -0000
@@ -18,7 +18,7 @@
typedef struct ao_functions_s
{
ao_info_t *info;
- int (*control)(int cmd,int arg);
+ int (*control)(int cmd,void *arg);
int (*init)(int rate,int channels,int format,int flags);
void (*uninit)();
void (*reset)();
Index: libao2/audio_out_internal.h
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out_internal.h,v
retrieving revision 1.3
diff -u -r1.3 audio_out_internal.h
--- libao2/audio_out_internal.h 24 Nov 2001 05:21:22 -0000 1.3
+++ libao2/audio_out_internal.h 12 Mar 2003 12:52:01 -0000
@@ -1,7 +1,7 @@
// prototypes:
//static ao_info_t info;
-static int control(int cmd,int arg);
+static int control(int cmd, void *arg);
static int init(int rate,int channels,int format,int flags);
static void uninit();
static void reset();
Index: libao2/audio_plugin.h
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_plugin.h,v
retrieving revision 1.12
diff -u -r1.12 audio_plugin.h
--- libao2/audio_plugin.h 25 Jul 2002 20:28:47 -0000 1.12
+++ libao2/audio_plugin.h 12 Mar 2003 12:52:01 -0000
@@ -5,7 +5,7 @@
typedef struct ao_plugin_functions_s
{
ao_info_t *info;
- int (*control)(int cmd,int arg);
+ int (*control)(int cmd, void *arg);
int (*init)();
void (*uninit)();
void (*reset)();
Index: libao2/audio_plugin_internal.h
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_plugin_internal.h,v
retrieving revision 1.3
diff -u -r1.3 audio_plugin_internal.h
--- libao2/audio_plugin_internal.h 4 Dec 2001 15:45:21 -0000 1.3
+++ libao2/audio_plugin_internal.h 12 Mar 2003 12:52:01 -0000
@@ -1,5 +1,5 @@
// prototypes:
-static int control(int cmd,int arg);
+static int control(int cmd, void *arg);
static int init();
static void uninit();
static void reset();
Index: libao2/pl_delay.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_delay.c,v
retrieving revision 1.6
diff -u -r1.6 pl_delay.c
--- libao2/pl_delay.c 22 Sep 2002 02:33:24 -0000 1.6
+++ libao2/pl_delay.c 12 Mar 2003 12:52:01 -0000
@@ -38,7 +38,7 @@
static pl_delay_t pl_delay={NULL,NULL,0,0,0,0};
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
if(pl_delay.data)
Index: libao2/pl_eq.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_eq.c,v
retrieving revision 1.7
diff -u -r1.7 pl_eq.c
--- libao2/pl_eq.c 3 Jan 2003 15:12:18 -0000 1.7
+++ libao2/pl_eq.c 12 Mar 2003 12:52:01 -0000
@@ -62,7 +62,7 @@
static pl_eq_t pl_eq;
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
Index: libao2/pl_extrastereo.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_extrastereo.c,v
retrieving revision 1.4
diff -u -r1.4 pl_extrastereo.c
--- libao2/pl_extrastereo.c 3 Jan 2003 15:12:18 -0000 1.4
+++ libao2/pl_extrastereo.c 12 Mar 2003 12:52:01 -0000
@@ -39,7 +39,7 @@
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
Index: libao2/pl_format.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_format.c,v
retrieving revision 1.7
diff -u -r1.7 pl_format.c
--- libao2/pl_format.c 2 Feb 2003 02:42:57 -0000 1.7
+++ libao2/pl_format.c 12 Mar 2003 12:52:01 -0000
@@ -57,7 +57,7 @@
#define SIGN_MASK (1<<3)
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
if(pl_format.data)
Index: libao2/pl_resample.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_resample.c,v
retrieving revision 1.12
diff -u -r1.12 pl_resample.c
--- libao2/pl_resample.c 3 Jan 2003 15:12:18 -0000 1.12
+++ libao2/pl_resample.c 12 Mar 2003 12:52:01 -0000
@@ -93,7 +93,7 @@
static pl_resample_t pl_resample = {NULL,NULL,1,1,1,0,W};
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
if(pl_resample.data)
Index: libao2/pl_surround.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_surround.c,v
retrieving revision 1.13
diff -u -r1.13 pl_surround.c
--- libao2/pl_surround.c 3 Jan 2003 15:12:18 -0000 1.13
+++ libao2/pl_surround.c 12 Mar 2003 12:52:01 -0000
@@ -79,7 +79,7 @@
static pl_surround_t pl_surround={0,20,NULL,NULL,NULL,0,0,NULL,0,0,0};
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
if (pl_surround.passthrough) return CONTROL_OK;
Index: libao2/pl_volnorm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_volnorm.c,v
retrieving revision 1.6
diff -u -r1.6 pl_volnorm.c
--- libao2/pl_volnorm.c 3 Jan 2003 15:12:18 -0000 1.6
+++ libao2/pl_volnorm.c 12 Mar 2003 12:52:01 -0000
@@ -103,7 +103,7 @@
// minimal interface
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
Index: libao2/pl_volume.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_volume.c,v
retrieving revision 1.3
diff -u -r1.3 pl_volume.c
--- libao2/pl_volume.c 3 Jan 2003 15:12:18 -0000 1.3
+++ libao2/pl_volume.c 12 Mar 2003 12:52:01 -0000
@@ -43,7 +43,7 @@
static pl_volume_t pl_volume={0,0,0};
// to set/get/query special features/parameters
-static int control(int cmd,int arg){
+static int control(int cmd,void *arg){
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
--
Jens Axboe
More information about the MPlayer-dev-eng
mailing list