From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH 7/7] iio: Adjust checks for null pointers in six functions
Date: Sat, 24 Sep 2016 08:31:19 +0200 [thread overview]
Message-ID: <8e0c9fdd-fc9a-0093-278f-00f3beb2a8f6@users.sourceforge.net> (raw)
In-Reply-To: <c11fbb47-1fd3-4e9e-042e-0f271cfef814@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 08:00:07 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script "checkpatch.pl" can point information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/iio/industrialio-buffer.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 57e201a..6893639 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -310,7 +310,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
sizeof(*trialmask),
GFP_KERNEL);
- if (trialmask == NULL)
+ if (!trialmask)
return -ENOMEM;
if (!indio_dev->masklength) {
WARN(1, "Trying to set scanmask prior to registering buffer\n");
@@ -711,7 +711,7 @@ static int iio_verify_update(struct iio_dev *indio_dev,
/* What scan mask do we actually have? */
compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
sizeof(long), GFP_KERNEL);
- if (compound_mask == NULL)
+ if (!compound_mask)
return -ENOMEM;
scan_timestamp = false;
@@ -736,7 +736,7 @@ static int iio_verify_update(struct iio_dev *indio_dev,
compound_mask,
strict_scanmask);
kfree(compound_mask);
- if (scan_mask == NULL)
+ if (!scan_mask)
return -EINVAL;
} else {
scan_mask = compound_mask;
@@ -940,7 +940,7 @@ int iio_update_buffers(struct iio_dev *indio_dev,
goto out_unlock;
}
- if (indio_dev->info == NULL) {
+ if (!indio_dev->info) {
ret = -ENODEV;
goto out_unlock;
}
@@ -1130,11 +1130,11 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
indio_dev->scan_index_timestamp =
channels[i].scan_index;
}
- if (indio_dev->masklength && buffer->scan_mask == NULL) {
+ if (indio_dev->masklength && !buffer->scan_mask) {
buffer->scan_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
sizeof(*buffer->scan_mask),
GFP_KERNEL);
- if (buffer->scan_mask == NULL) {
+ if (!buffer->scan_mask) {
ret = -ENOMEM;
goto error_cleanup_dynamic;
}
@@ -1146,7 +1146,7 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
buffer->scan_el_group.attrs = kcalloc(attrcount + 1,
sizeof(buffer->scan_el_group.attrs[0]),
GFP_KERNEL);
- if (buffer->scan_el_group.attrs == NULL) {
+ if (!buffer->scan_el_group.attrs) {
ret = -ENOMEM;
goto error_free_scan_mask;
}
@@ -1291,7 +1291,7 @@ static int iio_buffer_add_demux(struct iio_buffer *buffer,
(*p)->length += length;
} else {
*p = kmalloc(sizeof(**p), GFP_KERNEL);
- if (*p == NULL)
+ if (!*p)
return -ENOMEM;
(*p)->from = in_loc;
(*p)->to = out_loc;
@@ -1356,7 +1356,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
in_loc += length;
}
buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL);
- if (buffer->demux_bounce == NULL) {
+ if (!buffer->demux_bounce) {
ret = -ENOMEM;
goto error_clear_mux_table;
}
--
2.10.0
next prev parent reply other threads:[~2016-09-24 6:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-26 13:04 ` [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection SF Markus Elfring
2016-01-02 18:28 ` Jonathan Cameron
2016-09-24 6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
2016-09-24 6:24 ` [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set() SF Markus Elfring
2016-09-24 15:36 ` Jonathan Cameron
2016-09-24 16:18 ` SF Markus Elfring
2016-09-24 16:36 ` Jonathan Cameron
2016-09-24 6:25 ` [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark() SF Markus Elfring
2016-09-24 15:32 ` Jonathan Cameron
2016-09-24 19:21 ` SF Markus Elfring
2016-09-25 8:45 ` Jonathan Cameron
2016-09-25 13:00 ` SF Markus Elfring
2016-09-25 14:23 ` Jonathan Cameron
2016-09-25 15:17 ` SF Markus Elfring
2016-09-25 16:49 ` Jonathan Cameron
2016-09-25 17:31 ` SF Markus Elfring
2016-09-24 6:26 ` [PATCH 3/7] iio: Rename a jump label in iio_buffer_store_enable() SF Markus Elfring
2016-09-24 6:28 ` [PATCH 4/7] iio: Rename a jump label in iio_buffer_write_length() SF Markus Elfring
2016-09-24 6:29 ` [PATCH 5/7] iio: Rename a jump label in iio_scan_el_ts_store() SF Markus Elfring
2016-09-24 6:30 ` [PATCH 6/7] iio: Rename a jump label in iio_scan_el_store() SF Markus Elfring
2016-09-24 6:31 ` SF Markus Elfring [this message]
2016-09-25 14:24 ` [PATCH 7/7] iio: Adjust checks for null pointers in six functions Jonathan Cameron
2016-09-25 14:44 ` SF Markus Elfring
2016-09-25 16:51 ` Jonathan Cameron
2016-09-25 17:45 ` SF Markus Elfring
2016-09-25 18:15 ` Al Viro
2016-09-25 19:30 ` SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e0c9fdd-fc9a-0093-278f-00f3beb2a8f6@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=jic23@kernel.org \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).