From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kernel-janitors@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/5] misc/pti: Adjust 11 checks for null pointers
Date: Tue, 09 Jan 2018 18:32:29 +0000 [thread overview]
Message-ID: <a558f623-724f-6c7b-0cdd-0de3ea41256a@users.sourceforge.net> (raw)
In-Reply-To: <bd359852-a809-280d-3d52-89216edc2058@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 9 Jan 2018 18:48:10 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed 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/misc/pti.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 8ae79b286573..11d92c3f43ba 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -246,7 +246,7 @@ static struct pti_masterchannel *get_id(u8 *id_array,
int i, j, mask;
struct pti_masterchannel *mc = kmalloc(sizeof(*mc), GFP_KERNEL);
- if (mc = NULL)
+ if (!mc)
return NULL;
/* look for a byte with a free bit */
@@ -386,5 +386,5 @@ void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count)
* API function, thus, all parameters should
* be checked for validity.
*/
- if ((mc != NULL) && (buf != NULL) && (count > 0))
+ if (mc && buf && count > 0)
pti_write_to_aperture(mc, buf, count);
@@ -465,7 +465,7 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
if (ret = 0) {
pti_tty_data = kmalloc(sizeof(*pti_tty_data), GFP_KERNEL);
- if (pti_tty_data = NULL)
+ if (!pti_tty_data)
return -ENOMEM;
if (idx = PTITTY_MINOR_START)
@@ -473,7 +473,7 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
else
pti_tty_data->mc = pti_request_masterchannel(2, NULL);
- if (pti_tty_data->mc = NULL) {
+ if (!pti_tty_data->mc) {
kfree(pti_tty_data);
return -ENXIO;
}
@@ -492,7 +492,8 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
static void pti_tty_cleanup(struct tty_struct *tty)
{
struct pti_tty *pti_tty_data = tty->driver_data;
- if (pti_tty_data = NULL)
+
+ if (!pti_tty_data)
return;
pti_release_masterchannel(pti_tty_data->mc);
kfree(pti_tty_data);
@@ -516,7 +517,8 @@ static int pti_tty_driver_write(struct tty_struct *tty,
const unsigned char *buf, int len)
{
struct pti_tty *pti_tty_data = tty->driver_data;
- if ((pti_tty_data != NULL) && (pti_tty_data->mc != NULL)) {
+
+ if (pti_tty_data && pti_tty_data->mc) {
pti_write_to_aperture(pti_tty_data->mc, (u8 *)buf, len);
return len;
}
@@ -561,7 +563,7 @@ static int pti_char_open(struct inode *inode, struct file *filp)
* Slightly easier to debug if this driver needs debugging.
*/
mc = pti_request_masterchannel(0, NULL);
- if (mc = NULL)
+ if (!mc)
return -ENOMEM;
filp->private_data = mc;
return 0;
@@ -820,7 +822,7 @@ static int pti_pci_probe(struct pci_dev *pdev,
}
drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
- if (drv_data = NULL) {
+ if (!drv_data) {
retval = -ENOMEM;
goto err_disable_pci;
}
@@ -916,7 +918,7 @@ static int __init pti_init(void)
/* First register module as tty device */
pti_tty_driver = alloc_tty_driver(PTITTY_MINOR_NUM);
- if (pti_tty_driver = NULL) {
+ if (!pti_tty_driver) {
pr_err("%s(%d): Memory allocation failed for ptiTTY driver\n",
__func__, __LINE__);
return -ENOMEM;
--
2.15.1
next prev parent reply other threads:[~2018-01-09 18:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 18:27 [PATCH 0/5] misc-PTI: Adjustments for some function implementations SF Markus Elfring
2018-01-09 18:28 ` [PATCH 1/5] misc/pti: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2018-01-09 18:29 ` [PATCH 2/5] misc/pti: Fix a typo in five comment lines SF Markus Elfring
2018-01-09 18:31 ` [PATCH 3/5] misc/pti: Improve a size determination in two functions SF Markus Elfring
2018-01-09 18:32 ` SF Markus Elfring [this message]
2018-01-09 18:33 ` [PATCH 5/5] misc/pti: Delete an unnecessary return statement " 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=a558f623-724f-6c7b-0cdd-0de3ea41256a@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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