diff options
author | Florian Schmaus <fschmaus@gmail.com> | 2011-12-08 12:12:45 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-12-08 15:59:09 -0800 |
commit | c5018168a59b92ec3bd0f7b598e6d0d64d507e1e (patch) | |
tree | 9ff403e6cb3631eb9746d1cf719cc20ed6f09cf0 /drivers/staging/comedi | |
parent | 2e1c394fc398afb75d89c53f933149d33dc9e280 (diff) |
staging: comedi: comedi_fops: Removed int overflow check
This became unnecessary with the previous commit.
Improved the readability of the remaining check, by using UINT_MAX.
Signed-off-by: Florian Schmaus <fschmaus@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 60200b46be0b..15877fb0a363 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2430,7 +2430,7 @@ static ssize_t store_max_read_buffer_kb(struct device *dev, { struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned int new_max_size_kb; - uint64_t new_max_size; + unsigned int new_max_size; int ret; struct comedi_subdevice *const read_subdevice = comedi_get_read_subdevice(info); @@ -2438,11 +2438,9 @@ static ssize_t store_max_read_buffer_kb(struct device *dev, ret = kstrtouint(buf, 10, &new_max_size_kb); if (ret) return ret; - if (new_max_size_kb != (uint32_t) new_max_size_kb) - return -EINVAL; - new_max_size = ((uint64_t) new_max_size_kb) * bytes_per_kibi; - if (new_max_size != (uint32_t) new_max_size) + if (new_max_size_kb > (UINT_MAX / bytes_per_kibi)) return -EINVAL; + new_max_size = new_max_size_kb * bytes_per_kibi; mutex_lock(&info->device->mutex); if (read_subdevice == NULL || @@ -2493,7 +2491,7 @@ static ssize_t store_read_buffer_kb(struct device *dev, { struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned int new_size_kb; - uint64_t new_size; + unsigned int new_size; int retval; int ret; struct comedi_subdevice *const read_subdevice = @@ -2502,11 +2500,9 @@ static ssize_t store_read_buffer_kb(struct device *dev, ret = kstrtouint(buf, 10, &new_size_kb); if (ret) return ret; - if (new_size_kb != (uint32_t) new_size_kb) - return -EINVAL; - new_size = ((uint64_t) new_size_kb) * bytes_per_kibi; - if (new_size != (uint32_t) new_size) + if (new_size_kb > (UINT_MAX / bytes_per_kibi)) return -EINVAL; + new_size = new_size_kb * bytes_per_kibi; mutex_lock(&info->device->mutex); if (read_subdevice == NULL || @@ -2561,7 +2557,7 @@ static ssize_t store_max_write_buffer_kb(struct device *dev, { struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned int new_max_size_kb; - uint64_t new_max_size; + unsigned int new_max_size; int ret; struct comedi_subdevice *const write_subdevice = comedi_get_write_subdevice(info); @@ -2569,11 +2565,9 @@ static ssize_t store_max_write_buffer_kb(struct device *dev, ret = kstrtouint(buf, 10, &new_max_size_kb); if (ret) return ret; - if (new_max_size_kb != (uint32_t) new_max_size_kb) - return -EINVAL; - new_max_size = ((uint64_t) new_max_size_kb) * bytes_per_kibi; - if (new_max_size != (uint32_t) new_max_size) + if (new_max_size_kb > (UINT_MAX / bytes_per_kibi)) return -EINVAL; + new_max_size = new_max_size_kb * bytes_per_kibi; mutex_lock(&info->device->mutex); if (write_subdevice == NULL || @@ -2624,7 +2618,7 @@ static ssize_t store_write_buffer_kb(struct device *dev, { struct comedi_device_file_info *info = dev_get_drvdata(dev); unsigned int new_size_kb; - uint64_t new_size; + unsigned int new_size; int retval; int ret; struct comedi_subdevice *const write_subdevice = @@ -2633,11 +2627,9 @@ static ssize_t store_write_buffer_kb(struct device *dev, ret = kstrtouint(buf, 10, &new_size_kb); if (ret) return ret; - if (new_size_kb != (uint32_t) new_size_kb) + if (new_size_kb > (UINT_MAX / bytes_per_kibi)) return -EINVAL; new_size = ((uint64_t) new_size_kb) * bytes_per_kibi; - if (new_size != (uint32_t) new_size) - return -EINVAL; mutex_lock(&info->device->mutex); if (write_subdevice == NULL || |