From 0c69850ffceca9a5bca800da825e8ecb61ea85e7 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 12 Feb 2008 01:12:46 +0000 Subject: [PATCH] Made comedi_ioctl take its third argument as a void* instead of and integer type, and got rid of a bunch of casts (and added a few). --- lib/buffer.c | 14 +++++++------- lib/comedi.c | 22 +++++++++++----------- lib/data.c | 4 ++-- lib/filler.c | 14 +++++++------- lib/get.c | 2 +- lib/ioctl.c | 14 +++++++------- lib/libinternal.h | 4 ++-- lib/sv.c | 8 ++++---- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/buffer.c b/lib/buffer.c index 4136062..8210067 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -33,7 +33,7 @@ int _comedi_set_buffer_size(comedi_t *it, unsigned int subdev, unsigned int size memset(&bc, 0, sizeof(bc)); bc.subdevice = subdev; bc.size = size; - ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, (unsigned long)&bc); + ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, &bc); if(ret < 0) return ret; return bc.size; @@ -48,7 +48,7 @@ int _comedi_set_max_buffer_size(comedi_t *it, unsigned int subdev, unsigned int memset(&bc, 0, sizeof(bc)); bc.subdevice = subdev; bc.maximum_size = max_size; - ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, (unsigned long)&bc); + ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, &bc); if(ret < 0) return ret; return bc.maximum_size; @@ -74,7 +74,7 @@ int _comedi_get_buffer_contents(comedi_t *it, unsigned int subdev) memset(&bi, 0, sizeof(bi)); bi.subdevice = subdev; - ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, &bi); if(ret < 0) { if(__comedi_errno == EPIPE)__comedi_errno = EBUF_OVR; @@ -92,7 +92,7 @@ int _comedi_mark_buffer_read(comedi_t *it, unsigned int subdev, unsigned int byt memset(&bi, 0, sizeof(bi)); bi.subdevice = subdev; bi.bytes_read = bytes; - ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, &bi); if(ret < 0) { if(__comedi_errno == EPIPE)__comedi_errno = EBUF_OVR; @@ -110,7 +110,7 @@ int _comedi_mark_buffer_written(comedi_t *it, unsigned int subdev, unsigned int memset(&bi, 0, sizeof(bi)); bi.subdevice = subdev; bi.bytes_written = bytes; - ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, &bi); if(ret < 0) { if(__comedi_errno == EPIPE)__comedi_errno = EBUF_UNDR; @@ -127,7 +127,7 @@ int _comedi_get_buffer_offset(comedi_t *it, unsigned int subdev) memset(&bi, 0, sizeof(bi)); bi.subdevice = subdev; - ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, &bi); if(ret < 0) return ret; return bi.buf_read_ptr; } @@ -140,7 +140,7 @@ int _comedi_get_front_count(comedi_t *it, unsigned int subdev) memset(&bi, 0, sizeof(bi)); bi.subdevice = subdev; - ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, &bi); if(ret < 0) return ret; return bi.buf_write_count; } diff --git a/lib/comedi.c b/lib/comedi.c index 91903ae..e390758 100644 --- a/lib/comedi.c +++ b/lib/comedi.c @@ -65,7 +65,7 @@ comedi_t* _comedi_open(const char *fn) goto cleanup; } - if(comedi_ioctl(it->fd, COMEDI_DEVINFO, (unsigned long)&it->devinfo)<0) + if(comedi_ioctl(it->fd, COMEDI_DEVINFO, &it->devinfo) < 0) goto cleanup; it->n_subdevices=it->devinfo.n_subdevs; @@ -124,13 +124,13 @@ int _comedi_close(comedi_t *it) EXPORT_ALIAS_DEFAULT(_comedi_cancel,comedi_cancel,0.7.18); int _comedi_cancel(comedi_t *it,unsigned int subdevice) { - return comedi_ioctl(it->fd,COMEDI_CANCEL,subdevice); + return comedi_ioctl(it->fd, COMEDI_CANCEL, (void*)subdevice); } EXPORT_ALIAS_DEFAULT(_comedi_poll,comedi_poll,0.7.18); int _comedi_poll(comedi_t *it,unsigned int subdevice) { - return comedi_ioctl(it->fd,COMEDI_POLL,subdevice); + return comedi_ioctl(it->fd, COMEDI_POLL, (void*)subdevice); } EXPORT_ALIAS_DEFAULT(_comedi_fileno,comedi_fileno,0.7.18); @@ -148,14 +148,14 @@ int _comedi_trigger(comedi_t *it,comedi_trig *t) if(!it || !t) return -1; - return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)t); + return comedi_ioctl(it->fd, COMEDI_TRIG, t); } EXPORT_ALIAS_DEFAULT(_comedi_command,comedi_command,0.7.18); int _comedi_command(comedi_t *it,comedi_cmd *t) { int ret; - ret = comedi_ioctl(it->fd, COMEDI_CMD, (unsigned long)t); + ret = comedi_ioctl(it->fd, COMEDI_CMD, t); __comedi_errno = errno; switch(__comedi_errno){ case EIO: @@ -169,7 +169,7 @@ EXPORT_ALIAS_DEFAULT(_comedi_command_test,comedi_command_test,0.7.18); int _comedi_command_test(comedi_t *it,comedi_cmd *t) { int ret; - ret = comedi_ioctl(it->fd, COMEDI_CMDTEST, (unsigned long)t); + ret = comedi_ioctl(it->fd, COMEDI_CMDTEST, t); __comedi_errno = errno; switch(__comedi_errno){ case EIO: @@ -183,7 +183,7 @@ EXPORT_ALIAS_DEFAULT(_comedi_do_insnlist,comedi_do_insnlist,0.7.18); int _comedi_do_insnlist(comedi_t *it,comedi_insnlist *il) { int ret; - ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)il); + ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, il); __comedi_errno = errno; return ret; } @@ -192,7 +192,7 @@ EXPORT_ALIAS_DEFAULT(_comedi_do_insn,comedi_do_insn,0.7.18); int _comedi_do_insn(comedi_t *it,comedi_insn *insn) { if(it->has_insn_ioctl){ - return comedi_ioctl(it->fd, COMEDI_INSN, (unsigned long)insn); + return comedi_ioctl(it->fd, COMEDI_INSN, insn); }else{ comedi_insnlist il; int ret; @@ -200,7 +200,7 @@ int _comedi_do_insn(comedi_t *it,comedi_insn *insn) il.n_insns = 1; il.insns = insn; - ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)&il); + ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, &il); if(ret<0)return ret; return insn->n; @@ -210,12 +210,12 @@ int _comedi_do_insn(comedi_t *it,comedi_insn *insn) EXPORT_ALIAS_DEFAULT(_comedi_lock,comedi_lock,0.7.18); int _comedi_lock(comedi_t *it,unsigned int subdevice) { - return comedi_ioctl(it->fd, COMEDI_LOCK, subdevice); + return comedi_ioctl(it->fd, COMEDI_LOCK, (void*)subdevice); } EXPORT_ALIAS_DEFAULT(_comedi_unlock,comedi_unlock,0.7.18); int _comedi_unlock(comedi_t *it,unsigned int subdevice) { - return comedi_ioctl(it->fd, COMEDI_UNLOCK, subdevice); + return comedi_ioctl(it->fd, COMEDI_UNLOCK, (void*)subdevice); } diff --git a/lib/data.c b/lib/data.c index dc4fbc8..fa80f18 100644 --- a/lib/data.c +++ b/lib/data.c @@ -82,7 +82,7 @@ int _comedi_data_write(comedi_t *it,unsigned int subdev,unsigned int chan,unsign } cmd.chanlist=&chan; - return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)&cmd); + return comedi_ioctl(it->fd, COMEDI_TRIG, &cmd); } } @@ -132,7 +132,7 @@ static int comedi_internal_data_read_n(comedi_t *it, cmd.data=sdata; } - ret = comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)&cmd); + ret = comedi_ioctl(it->fd, COMEDI_TRIG, &cmd); if(ret<0) return ret; diff --git a/lib/filler.c b/lib/filler.c index 07cf40d..98e6280 100644 --- a/lib/filler.c +++ b/lib/filler.c @@ -60,7 +60,7 @@ int get_subdevices(comedi_t *it) goto cleanup; } - ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, (unsigned long)s); + ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, s); if(ret < 0) { debug_int(ret); @@ -118,7 +118,7 @@ int get_subdevices(comedi_t *it) ci.flaglist = r[i].flags_list; ci.rangelist = r[i].range_type_list; ci.maxdata_list = r[i].maxdata_list; - ret = comedi_ioctl(it->fd, COMEDI_CHANINFO, (unsigned long)&ci); + ret = comedi_ioctl(it->fd, COMEDI_CHANINFO, &ci); if(ret < 0){ debug_int(ret); goto cleanup; @@ -155,7 +155,7 @@ int get_subdevices(comedi_t *it) return 0; cleanup: - + if(s) free(s); @@ -211,7 +211,7 @@ comedi_range *get_rangeinfo(int fd,unsigned int range_type) memset(&ri, 0, sizeof(ri)); ri.range_type = range_type; ri.range_ptr = kr; - ret = comedi_ioctl(fd, COMEDI_RANGEINFO, (unsigned long)&ri); + ret = comedi_ioctl(fd, COMEDI_RANGEINFO, &ri); if(ret<0){ fprintf(stderr,"ioctl(%d,COMEDI_RANGEINFO,0x%08x,%p)\n",fd,range_type,kr); free(r); @@ -252,7 +252,7 @@ static int do_test_for_cmd(comedi_t *dev,unsigned int subdevice) it.scan_end_src = TRIG_ANY; it.stop_src = TRIG_ANY; - ret = comedi_ioctl(dev->fd, COMEDI_CMDTEST, (unsigned long)&it); + ret = comedi_ioctl(dev->fd, COMEDI_CMDTEST, &it); if(ret<0 && errno==EIO){ return 0; @@ -281,7 +281,7 @@ static int do_test_for_insnlist(comedi_t *dev) insn.data = data; memset(insn.data, 0, insn.n * sizeof(insn.data[0])); - ret = comedi_ioctl(dev->fd, COMEDI_INSNLIST, (unsigned long)&il); + ret = comedi_ioctl(dev->fd, COMEDI_INSNLIST, &il); if(ret<0){ if(errno!=EIO){ @@ -309,7 +309,7 @@ static int do_test_for_insn(comedi_t *dev) insn.data = data; memset(insn.data, 0, insn.n * sizeof(insn.data[0])); - ret = comedi_ioctl(dev->fd, COMEDI_INSN, (unsigned long)&insn); + ret = comedi_ioctl(dev->fd, COMEDI_INSN, &insn); if(ret<0){ if(errno!=EIO){ diff --git a/lib/get.c b/lib/get.c index 6d683d9..02f0e7f 100644 --- a/lib/get.c +++ b/lib/get.c @@ -93,7 +93,7 @@ int _comedi_get_subdevice_flags(comedi_t *it,unsigned int subd) libc_error(); return -1; } - ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, (unsigned long)s); + ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, s); if(ret < 0) { free(s); diff --git a/lib/ioctl.c b/lib/ioctl.c index db13bea..15dc730 100644 --- a/lib/ioctl.c +++ b/lib/ioctl.c @@ -37,23 +37,23 @@ /* ioctl wrappers */ -int _comedi_ioctl( int fd, int request, unsigned long arg ) +int _comedi_ioctl(int fd, int request, void *arg) { int ret; - ret = ioctl( fd, request, arg ); - if( ret < 0 ) + ret = ioctl(fd, request, arg); + if(ret < 0) libc_error(); return ret; } -int _comedi_ioctl_debug(int fd, int request, unsigned long arg) +int _comedi_ioctl_debug(int fd, int request, void *arg) { int ret; - fprintf(stderr,"ioctl(%d,0x%08x,0x%08lx) = ",fd,request,arg); - ret = _comedi_ioctl(fd,request,arg); - fprintf(stderr,"%d\n",ret); + fprintf(stderr,"ioctl(%d,0x%08x,%p) = ",fd, request, arg); + ret = _comedi_ioctl(fd, request, arg); + fprintf(stderr,"%d\n", ret); return ret; } diff --git a/lib/libinternal.h b/lib/libinternal.h index d260c00..462521e 100644 --- a/lib/libinternal.h +++ b/lib/libinternal.h @@ -127,8 +127,8 @@ struct subdevice_struct{ #define comedi_ioctl _comedi_ioctl //#define comedi_ioctl _comedi_ioctl_debug -int _comedi_ioctl( int fd, int request, unsigned long arg ); -int _comedi_ioctl_debug(int,int,unsigned long); +int _comedi_ioctl(int fd, int request, void *arg); +int _comedi_ioctl_debug(int, int, void*); /* filler routines */ diff --git a/lib/sv.c b/lib/sv.c index 13f228d..821a256 100644 --- a/lib/sv.c +++ b/lib/sv.c @@ -93,7 +93,7 @@ int sv_measure_l(comedi_sv_t *it,double *data) val=malloc(sizeof(*val)*it->n); chan=CR_PACK(it->chan,it->range,it->aref); - + t.subdev=it->subdevice; t.mode=0; t.flags=TRIG_DITHER; @@ -108,7 +108,7 @@ int sv_measure_l(comedi_sv_t *it,double *data) for(n=0;nn;){ t.data=(void *)(val+n); t.n=it->n-n; - i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, (unsigned long)&t); + i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, &t); if(i<=0){ ret=i; goto out; @@ -144,7 +144,7 @@ int sv_measure_s(comedi_sv_t *it,double *data) val=malloc(sizeof(*val)*it->n); chan=CR_PACK(it->chan,it->range,it->aref); - + t.subdev=it->subdevice; t.mode=0; t.flags=TRIG_DITHER; @@ -161,7 +161,7 @@ int sv_measure_s(comedi_sv_t *it,double *data) for(n=0;nn;){ t.data=val+n; t.n=it->n-n; - i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, (unsigned long)&t); + i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, &t); if(i<=0){ ret=i; goto out; -- 2.26.2