mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-mips@linux-mips.org, "Ingo Molnar" <mingo@kernel.org>,
	"James Hogan" <james.hogan@imgtec.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Marcin Nowakowski" <marcin.nowakowski@imgtec.com>,
	"Masahiro Yamada" <yamada.masahiro@socionext.com>,
	"Matt Redfearn" <matt.redfearn@imgtec.com>,
	"Paul Burton" <paul.burton@imgtec.com>,
	"Ralf Bächle" <ralf@linux-mips.org>,
	"Thomas Gleixner" <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 5/5] MIPS: VPE: Adjust 13 checks for null pointers
Date: Tue, 23 May 2017 22:55:04 +0200	[thread overview]
Message-ID: <44ff74fa-07c9-3f9c-6cda-050296400c72@users.sourceforge.net> (raw)
In-Reply-To: <e866716c-5ce4-3658-f944-e310007db127@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 23 May 2017 22:16:24 +0200
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>
---
 arch/mips/kernel/vpe.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index ed019218496b..0ef7654e67e4 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -97,4 +97,4 @@ struct vpe *alloc_vpe(int minor)
-	if (v == NULL)
+	if (!v)
 		goto out;
 
 	INIT_LIST_HEAD(&v->tc);
@@ -118,4 +118,4 @@ struct tc *alloc_tc(int index)
-	if (tc == NULL)
+	if (!tc)
 		goto out;
 
 	INIT_LIST_HEAD(&tc->tc);
@@ -340,10 +340,9 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,
 	/* Sign extend the addend we extract from the lo insn.	*/
 	vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000;
 
-	if (mips_hi16_list != NULL) {
-
+	if (mips_hi16_list) {
 		l = mips_hi16_list;
-		while (l != NULL) {
+		while (l) {
 			unsigned long insn;
 
 			/*
@@ -391,7 +390,7 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,
 	return 0;
 
 out_free:
-	while (l != NULL) {
+	while (l) {
 		next = l->next;
 		kfree(l);
 		l = next;
@@ -562,7 +561,7 @@ static int find_vpe_symbols(struct vpe *v, Elf_Shdr *sechdrs,
 			v->shared_ptr = (void *)sym[i].st_value;
 	}
 
-	if ((v->__start == 0) || (v->shared_ptr == NULL))
+	if ((v->__start == 0) || !v->shared_ptr)
 		return -1;
 
 	return 0;
@@ -737,7 +736,7 @@ static int vpe_elfload(struct vpe *v)
 			return -ENOEXEC;
 		}
 
-		if (v->shared_ptr == NULL)
+		if (!v->shared_ptr)
 			pr_warn("VPE loader: program does not contain vpe_shared symbol.\n"
 				" Unable to use AMVP (AP/SP) facilities.\n");
 	}
@@ -777,7 +776,7 @@ static int vpe_open(struct inode *inode, struct file *filp)
 	}
 
 	v = get_vpe(aprp_cpu_index());
-	if (v == NULL) {
+	if (!v) {
 		pr_warn("VPE loader: unable to get vpe\n");
 
 		return -ENODEV;
@@ -822,7 +821,7 @@ static int vpe_release(struct inode *inode, struct file *filp)
 	int ret = 0;
 
 	v = get_vpe(aprp_cpu_index());
-	if (v == NULL)
+	if (!v)
 		return -ENODEV;
 
 	hdr = (Elf_Ehdr *) v->pbuffer;
@@ -866,8 +865,7 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,
 		return -ENODEV;
 
 	v = get_vpe(aprp_cpu_index());
-
-	if (v == NULL)
+	if (!v)
 		return -ENODEV;
 
 	if ((count + v->len) > v->plen) {
@@ -895,7 +893,7 @@ void *vpe_get_shared(int index)
 {
 	struct vpe *v = get_vpe(index);
 
-	if (v == NULL)
+	if (!v)
 		return NULL;
 
 	return v->shared_ptr;
@@ -906,7 +904,7 @@ int vpe_notify(int index, struct vpe_notifications *notify)
 {
 	struct vpe *v = get_vpe(index);
 
-	if (v == NULL)
+	if (!v)
 		return -1;
 
 	list_add(&notify->list, &v->notify);
@@ -918,7 +916,7 @@ char *vpe_getcwd(int index)
 {
 	struct vpe *v = get_vpe(index);
 
-	if (v == NULL)
+	if (!v)
 		return NULL;
 
 	return v->cwd;
-- 
2.13.0

  parent reply	other threads:[~2017-05-23 20:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23 20:50 [PATCH 0/5] MIPS-kernel: Adjustments for some function implementations SF Markus Elfring
2017-05-23 20:51 ` [PATCH 1/5] MIPS: pm-cps: Delete an error message for a failed memory allocation in cps_pm_online_cpu() SF Markus Elfring
2017-05-23 20:52 ` [PATCH 2/5] MIPS: smp-cps: Delete error messages for failed memory allocations in cps_prepare_cpus() SF Markus Elfring
2017-05-23 20:53 ` [PATCH 3/5] MIPS: VPE: Delete an error message for a failed memory allocation in vpe_open() SF Markus Elfring
2017-05-23 20:54 ` [PATCH 4/5] MIPS: VPE: Improve a size determination in two functions SF Markus Elfring
2017-05-23 20:55 ` SF Markus Elfring [this message]
2017-05-23 21:11 ` [PATCH 0/5] MIPS-kernel: Adjustments for some function implementations Joe Perches

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=44ff74fa-07c9-3f9c-6cda-050296400c72@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=james.hogan@imgtec.com \
    --cc=keescook@chromium.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=marcin.nowakowski@imgtec.com \
    --cc=matt.redfearn@imgtec.com \
    --cc=mingo@kernel.org \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    --cc=yamada.masahiro@socionext.com \
    /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

Powered by JetHome