* [patch 1/2 -next] iio: frequency: adf4350: using an uninitialized variable
@ 2012-06-08 6:54 Dan Carpenter
2012-06-08 7:24 ` Michael Hennerich
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-06-08 6:54 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Greg Kroah-Hartman, Michael Hennerich, linux-iio, kernel-janitors
GCC complains that we use an uninitialized variable if the user passes
an invalid parameter to adf4350_read(). I decided that we should return
-EINVAL instead in that case.
However, when I looked up at adf4350_write() it returned -ENODEV for
that condition. In the end, I decided the -EINVAL was the right thing
and I change adf4350_write() to match.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
index fd4c850..4729bba 100644
--- a/drivers/iio/frequency/adf4350.c
+++ b/drivers/iio/frequency/adf4350.c
@@ -272,7 +272,7 @@ static ssize_t adf4350_write(struct iio_dev *indio_dev,
adf4350_sync_config(st);
break;
default:
- ret = -ENODEV;
+ ret = -EINVAL;
}
mutex_unlock(&indio_dev->mlock);
@@ -310,6 +310,8 @@ static ssize_t adf4350_read(struct iio_dev *indio_dev,
case ADF4350_PWRDOWN:
val = !!(st->regs[ADF4350_REG2] & ADF4350_REG2_POWER_DOWN_EN);
break;
+ default:
+ ret = -EINVAL;
}
mutex_unlock(&indio_dev->mlock);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch 1/2 -next] iio: frequency: adf4350: using an uninitialized variable
2012-06-08 6:54 [patch 1/2 -next] iio: frequency: adf4350: using an uninitialized variable Dan Carpenter
@ 2012-06-08 7:24 ` Michael Hennerich
0 siblings, 0 replies; 2+ messages in thread
From: Michael Hennerich @ 2012-06-08 7:24 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jonathan Cameron, Greg Kroah-Hartman, linux-iio@vger.kernel.org,
kernel-janitors@vger.kernel.org
On 06/08/2012 08:54 AM, Dan Carpenter wrote:
> GCC complains that we use an uninitialized variable if the user passes
> an invalid parameter to adf4350_read(). I decided that we should return
> -EINVAL instead in that case.
>
> However, when I looked up at adf4350_write() it returned -ENODEV for
> that condition. In the end, I decided the -EINVAL was the right thing
> and I change adf4350_write() to match.
Agreed.
>
> Signed-off-by: Dan Carpenter<dan.carpenter@oracle.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
>
> diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
> index fd4c850..4729bba 100644
> --- a/drivers/iio/frequency/adf4350.c
> +++ b/drivers/iio/frequency/adf4350.c
> @@ -272,7 +272,7 @@ static ssize_t adf4350_write(struct iio_dev *indio_dev,
> adf4350_sync_config(st);
> break;
> default:
> - ret = -ENODEV;
> + ret = -EINVAL;
> }
> mutex_unlock(&indio_dev->mlock);
>
> @@ -310,6 +310,8 @@ static ssize_t adf4350_read(struct iio_dev *indio_dev,
> case ADF4350_PWRDOWN:
> val = !!(st->regs[ADF4350_REG2]& ADF4350_REG2_POWER_DOWN_EN);
> break;
> + default:
> + ret = -EINVAL;
> }
> mutex_unlock(&indio_dev->mlock);
>
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-08 7:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-08 6:54 [patch 1/2 -next] iio: frequency: adf4350: using an uninitialized variable Dan Carpenter
2012-06-08 7:24 ` Michael Hennerich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).