2015-12-13 15:15:35

by Bhaktipriya Shridhar

[permalink] [raw]
Subject: [PATCH v3] Staging: iio: accel: Fixed NULL comparison style

The variable u8 **rx_p, is a pointer-to-pointer and hence the check
should
be "if (!*rx_p)" and not "if (!rx_p)".
In the earlier version, checkpatch.pl gave the following check, which
was incorrect:
CHECK: Comparison to NULL could be written "!rx_p"
+ if (*rx_p == NULL) {

Signed-off-by: Bhaktipriya Shridhar <[email protected]>
---
Changes in v3:
- Replaced "if (!rx_p)" with "if (!*rx_p)"
- Changes are made on the original code

drivers/staging/iio/accel/sca3000_ring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
index 20b878d..1920dc60 100644
--- a/drivers/staging/iio/accel/sca3000_ring.c
+++ b/drivers/staging/iio/accel/sca3000_ring.c
@@ -48,7 +48,7 @@ static int sca3000_read_data(struct sca3000_state *st,
}
};
*rx_p = kmalloc(len, GFP_KERNEL);
- if (*rx_p == NULL) {
+ if (!*rx_p) {
ret = -ENOMEM;
goto error_ret;
}
--
2.1.4


2015-12-19 16:41:29

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v3] Staging: iio: accel: Fixed NULL comparison style

On 13/12/15 15:15, Bhaktipriya Shridhar wrote:
> The variable u8 **rx_p, is a pointer-to-pointer and hence the check
> should
> be "if (!*rx_p)" and not "if (!rx_p)".
> In the earlier version, checkpatch.pl gave the following check, which
> was incorrect:
> CHECK: Comparison to NULL could be written "!rx_p"
> + if (*rx_p == NULL) {
>
> Signed-off-by: Bhaktipriya Shridhar <[email protected]>
Applied to the togreg branch of iio.git with the addition of the driver name
in the patch title.

Thanks

Jonathan
> ---
> Changes in v3:
> - Replaced "if (!rx_p)" with "if (!*rx_p)"
> - Changes are made on the original code
>
> drivers/staging/iio/accel/sca3000_ring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
> index 20b878d..1920dc60 100644
> --- a/drivers/staging/iio/accel/sca3000_ring.c
> +++ b/drivers/staging/iio/accel/sca3000_ring.c
> @@ -48,7 +48,7 @@ static int sca3000_read_data(struct sca3000_state *st,
> }
> };
> *rx_p = kmalloc(len, GFP_KERNEL);
> - if (*rx_p == NULL) {
> + if (!*rx_p) {
> ret = -ENOMEM;
> goto error_ret;
> }
>