Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1643475

[PATCH 2/2] spidev: Adjust five checks for null pointers

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 2/2] spidev: Adjust five checks for null pointers
Date 2017-05-17 17:50 +0200
Message-ID <tI9n3-4Ud-1@gated-at.bofh.it> (permalink)
References <tI9n3-4Ud-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 17 May 2017 17:30:28 +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>
---
 drivers/spi/spidev.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e6dc37fbea4e..846c54129744 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -106,8 +106,7 @@ spidev_sync(struct spidev_data *spidev, struct spi_message *message)
 	spin_lock_irq(&spidev->spi_lock);
 	spi = spidev->spi;
 	spin_unlock_irq(&spidev->spi_lock);
-
-	if (spi == NULL)
+	if (!spi)
 		status = -ESHUTDOWN;
 	else
 		status = spi_sync(spi, message);
@@ -218,7 +217,7 @@ static int spidev_message(struct spidev_data *spidev,
 
 	spi_message_init(&msg);
 	k_xfers = kcalloc(n_xfers, sizeof(*k_tmp), GFP_KERNEL);
-	if (k_xfers == NULL)
+	if (!k_xfers)
 		return -ENOMEM;
 
 	/* Construct spi_message, copying any tx data to bounce buffer.
@@ -387,8 +386,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	spin_lock_irq(&spidev->spi_lock);
 	spi = spi_dev_get(spidev->spi);
 	spin_unlock_irq(&spidev->spi_lock);
-
-	if (spi == NULL)
+	if (!spi)
 		return -ESHUTDOWN;
 
 	/* use the buffer lock here for triple duty:
@@ -535,8 +533,7 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd,
 	spin_lock_irq(&spidev->spi_lock);
 	spi = spi_dev_get(spidev->spi);
 	spin_unlock_irq(&spidev->spi_lock);
-
-	if (spi == NULL)
+	if (!spi)
 		return -ESHUTDOWN;
 
 	/* SPI_IOC_MESSAGE needs the buffer locked "normally" */
@@ -655,7 +652,7 @@ static int spidev_release(struct inode *inode, struct file *filp)
 			spidev->speed_hz = spidev->spi->max_speed_hz;
 
 		/* ... after we unbound from the underlying device? */
-		dofree = (spidev->spi == NULL);
+		dofree = !spidev->spi;
 		spin_unlock_irq(&spidev->spi_lock);
 
 		if (dofree)
-- 
2.13.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] spidev: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-17 17:50 +0200
  Re: [PATCH 2/2] spidev: Adjust five checks for null pointers Mark Brown <broonie@kernel.org> - 2017-05-18 13:30 +0200
    Re: spidev: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-18 16:40 +0200
      Re: spidev: Adjust five checks for null pointers Mark Brown <broonie@kernel.org> - 2017-05-22 14:40 +0200

csiph-web