From 1b3b35987cc3e8c555f148306234e5f732761bd5 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Tue, 28 Oct 2008 21:49:02 +0000 Subject: fix a large number of warnings found by sparse, the kernel code sanity checking tool. some of these fixes are non-optimal (casting 'unsigned long' to '__user void *'), but are unavoidable in many cases. started from tzafrir's patch, did most of the work myself. (closes issue #13763) Reported by: tzafrir Patches: sparse_fixes_1.diff uploaded by tzafrir (license 46) git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5162 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wctdm.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'drivers/dahdi/wctdm.c') diff --git a/drivers/dahdi/wctdm.c b/drivers/dahdi/wctdm.c index 09f079c..036f418 100644 --- a/drivers/dahdi/wctdm.c +++ b/drivers/dahdi/wctdm.c @@ -1791,7 +1791,7 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long case DAHDI_ONHOOKTRANSFER: if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS) return -EINVAL; - if (get_user(x, (int *)data)) + if (get_user(x, (__user int *) data)) return -EFAULT; wc->mod[chan->chanpos - 1].fxs.ohttimer = x << 3; if (reversepolarity) @@ -1808,7 +1808,7 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long } break; case DAHDI_SETPOLARITY: - if (get_user(x, (int *)data)) + if (get_user(x, (__user int *) data)) return -EFAULT; if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS) return -EINVAL; @@ -1834,7 +1834,7 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long stats.batvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000; } else return -EINVAL; - if (copy_to_user((struct wctdm_stats *)data, &stats, sizeof(stats))) + if (copy_to_user((__user void *)data, &stats, sizeof(stats))) return -EFAULT; break; case WCTDM_GET_REGS: @@ -1848,11 +1848,11 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long for (x=0;xchanpos - 1, x); } - if (copy_to_user((struct wctdm_regs *)data, ®s, sizeof(regs))) + if (copy_to_user((__user void *)data, ®s, sizeof(regs))) return -EFAULT; break; case WCTDM_SET_REG: - if (copy_from_user(®op, (struct wctdm_regop *)data, sizeof(regop))) + if (copy_from_user(®op, (__user void *) data, sizeof(regop))) return -EFAULT; if (regop.indirect) { if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS) @@ -1867,7 +1867,7 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long break; case WCTDM_SET_ECHOTUNE: printk(KERN_INFO "-- Setting echo registers: \n"); - if (copy_from_user(&echoregs, (struct wctdm_echo_coefs*)data, sizeof(echoregs))) + if (copy_from_user(&echoregs, (__user void *)data, sizeof(echoregs))) return -EFAULT; if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXO) { @@ -1893,7 +1893,7 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long } break; case DAHDI_SET_HWGAIN: - if (copy_from_user(&hwgain, (struct dahdi_hwgain*) data, sizeof(hwgain))) + if (copy_from_user(&hwgain, (__user void *) data, sizeof(hwgain))) return -EFAULT; wctdm_set_hwgain(wc, chan->chanpos-1, hwgain.newgain, hwgain.tx); @@ -2322,8 +2322,6 @@ static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_devic if (wctdm_hardware_init(wc)) { - unsigned char x; - /* Set Reset Low */ x=inb(wc->ioaddr + WC_CNTL); outb((~0x1)&x, wc->ioaddr + WC_CNTL); @@ -2420,12 +2418,12 @@ static struct pci_device_id wctdm_pci_tbl[] = { MODULE_DEVICE_TABLE(pci, wctdm_pci_tbl); static struct pci_driver wctdm_driver = { - name: "wctdm", - probe: wctdm_init_one, - remove: __devexit_p(wctdm_remove_one), - suspend: NULL, - resume: NULL, - id_table: wctdm_pci_tbl, + .name = "wctdm", + .probe = wctdm_init_one, + .remove =__devexit_p(wctdm_remove_one), + .suspend = NULL, + .resume = NULL, + .id_table = wctdm_pci_tbl, }; static int __init wctdm_init(void) -- cgit v1.2.3