lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 2 Aug 2015 17:32:30 +0100
From:	Jonathan Cameron <jic23@...nel.org>
To:	Dan Carpenter <dan.carpenter@...cle.com>,
	Teodora Baluta <teodora.baluta@...el.com>
Cc:	knaack.h@....de, lars@...afoo.de, pmeerw@...erw.net,
	daniel.baluta@...el.com, linux-iio@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] iio: magnetometer: add mmc34160 magnetometer
 driver

On 20/07/15 15:14, Dan Carpenter wrote:
> On Mon, Jul 20, 2015 at 04:52:30PM +0300, Teodora Baluta wrote:
>> +static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
>> +				  int index, int *val)
>> +{
>> +	switch (index) {
>> +	case AXIS_X:
>> +		*val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X];
>> +		break;
>> +	case AXIS_Y:
>> +		*val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y];
>> +		break;
>> +	case AXIS_Z:
>> +		*val = (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
>> +		break;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +
>> +	return 0;
>> +}
> 
> We never pass invalid indexes here so this could be replaced with:
> 
> static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
> 				  int index, int *val)
> {
> 	*val = (raw[index] - nfo) * 1000 / sens[index];
> 	return 0;
Even better change the function signature and don't return anything at 
all perhaps?

Anyhow, definitely worth making this change.

> }
> 
> regards,
> dan carpenter
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ