[MPlayer-users] Bug in input/joystick.c?

William Plant w at wplant.com
Tue May 21 11:42:02 CEST 2002


We have:

int mp_input_joystick_init(char* dev) {
  int fd,l=0;
  int inited = 0;
  struct js_event ev;
...
  while(! inited) {
    l = 0;
    while((unsigned int)l < sizeof(struct js_event)) {
      int r = read(fd,&ev+l,sizeof(struct js_event)-l);
...
      l += r;
    }

shouldn't this be:
    int r = read(fd,(char *)&ev+l,sizeof(struct js_event)-l);

because otherwise C's pointer arithmetic is going to multiply l by sizeof
struct js_event before adding it to &ev.

This usage appears also in mp_input_joystick_read() and in the file
input/input.c .

It doesn't seem to cause any problems at present because l is always 0.
Also, shouldn't l be a size_t ?

And a few questions -
Is the joystick input much used? 

Would it be simple to modify the joystick code to use an analog stick for
fast forward/rewind where the position determined the rate of movement, or
can the user input abstraction only handle a simple event, and not one
associated with a value?

Is there an option somewhere so that mplayer doesn't exit when the file
finishes playing, so you could fast-forward to the end, and jam there,
like when rewinding you can't go beyond the beginning?


Cheers,

-- 
William Plant   w at wplant.com




More information about the MPlayer-users mailing list