* [PATCH 0/2] spidev: Adjustments for six function implementations @ 2017-05-17 15:43 SF Markus Elfring [not found] ` <c5452d8c-d123-d5e9-b2cc-a386d1325aec-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-05-17 15:43 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> Date: Wed, 17 May 2017 17:41:23 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (2): Delete error messages for failed memory allocations in spidev_open() Adjust five checks for null pointers drivers/spi/spidev.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <c5452d8c-d123-d5e9-b2cc-a386d1325aec-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>]
* [PATCH 1/2] spidev: Delete error messages for failed memory allocations in spidev_open() [not found] ` <c5452d8c-d123-d5e9-b2cc-a386d1325aec-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> @ 2017-05-17 15:45 ` SF Markus Elfring 2017-05-17 15:47 ` [PATCH 2/2] spidev: Adjust five checks for null pointers SF Markus Elfring 1 sibling, 0 replies; 6+ messages in thread From: SF Markus Elfring @ 2017-05-17 15:45 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> Date: Wed, 17 May 2017 17:17:49 +0200 Omit two extra messages for memory allocation failures in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> --- drivers/spi/spidev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 9a2a79a871ba..e6dc37fbea4e 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -603,7 +603,6 @@ static int spidev_open(struct inode *inode, struct file *filp) if (!spidev->tx_buffer) { spidev->tx_buffer = kmalloc(bufsiz, GFP_KERNEL); if (!spidev->tx_buffer) { - dev_dbg(&spidev->spi->dev, "open/ENOMEM\n"); status = -ENOMEM; goto err_find_dev; } @@ -612,7 +611,6 @@ static int spidev_open(struct inode *inode, struct file *filp) if (!spidev->rx_buffer) { spidev->rx_buffer = kmalloc(bufsiz, GFP_KERNEL); if (!spidev->rx_buffer) { - dev_dbg(&spidev->spi->dev, "open/ENOMEM\n"); status = -ENOMEM; goto err_alloc_rx_buf; } -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] spidev: Adjust five checks for null pointers [not found] ` <c5452d8c-d123-d5e9-b2cc-a386d1325aec-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 2017-05-17 15:45 ` [PATCH 1/2] spidev: Delete error messages for failed memory allocations in spidev_open() SF Markus Elfring @ 2017-05-17 15:47 ` SF Markus Elfring [not found] ` <df3e58c6-f70d-a5d3-102e-4fab2f7df126-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 1 sibling, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-05-17 15:47 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 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-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <df3e58c6-f70d-a5d3-102e-4fab2f7df126-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>]
* Re: [PATCH 2/2] spidev: Adjust five checks for null pointers [not found] ` <df3e58c6-f70d-a5d3-102e-4fab2f7df126-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> @ 2017-05-18 11:28 ` Mark Brown 2017-05-18 14:34 ` SF Markus Elfring 0 siblings, 1 reply; 6+ messages in thread From: Mark Brown @ 2017-05-18 11:28 UTC (permalink / raw) To: SF Markus Elfring Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 680 bytes --] On Wed, May 17, 2017 at 05:47:29PM +0200, SF Markus Elfring wrote: > From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> > Date: Wed, 17 May 2017 17:30:28 +0200 > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit Please fix however you're sending things out to avoid this noise. > The script “checkpatch.pl” pointed information out like the following. > > Comparison to NULL could be written !… > > Thus fix the affected source code places. This changelog does not describe any purpose in making this change, we could equally well say the exact opposite. Why should we do this? [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: spidev: Adjust five checks for null pointers 2017-05-18 11:28 ` Mark Brown @ 2017-05-18 14:34 ` SF Markus Elfring [not found] ` <5d9f71d4-2f0d-7083-fd28-fb505841b502-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-05-18 14:34 UTC (permalink / raw) To: Mark Brown; +Cc: linux-spi, LKML, kernel-janitors >> MIME-Version: 1.0 >> Content-Type: text/plain; charset=UTF-8 >> Content-Transfer-Encoding: 8bit > > Please fix however you're sending things out to avoid this noise. The Git software generated such extra information because my commit message contained a few special characters. >> The script “checkpatch.pl” pointed information out like the following. >> >> Comparison to NULL could be written !… >> >> Thus fix the affected source code places. > > This changelog does not describe any purpose in making this change, > we could equally well say the exact opposite. Why should we do this? How do you think about to reduce the usage of the preprocessor symbol “NULL”? Can it help if the source code is a little bit shorter after the proposed adjustment? Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <5d9f71d4-2f0d-7083-fd28-fb505841b502-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>]
* Re: spidev: Adjust five checks for null pointers [not found] ` <5d9f71d4-2f0d-7083-fd28-fb505841b502-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> @ 2017-05-22 12:33 ` Mark Brown 0 siblings, 0 replies; 6+ messages in thread From: Mark Brown @ 2017-05-22 12:33 UTC (permalink / raw) To: SF Markus Elfring Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1188 bytes --] On Thu, May 18, 2017 at 04:34:45PM +0200, SF Markus Elfring wrote: > >> The script “checkpatch.pl” pointed information out like the following. > >> Comparison to NULL could be written !… > >> Thus fix the affected source code places. > > This changelog does not describe any purpose in making this change, > > we could equally well say the exact opposite. Why should we do this? > How do you think about to reduce the usage of the preprocessor symbol “NULL”? Why would that matter? > Can it help if the source code is a little bit shorter after the > proposed adjustment? Not really - clarity is important but the size of code isn't too meaningful in and of itself. Please if you don't really understand what you're sending try to understand it first, don't throw things out without that. I know a number of other maintainers have already raised concerns about the quality of what's being sent and the effort required to review them in relation to their value. There's nothing wrong with doing small cleanups but if that's all you're sending and there's often problems then it becomes more trouble than it's worth to review your changes. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-22 12:33 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-17 15:43 [PATCH 0/2] spidev: Adjustments for six function implementations SF Markus Elfring [not found] ` <c5452d8c-d123-d5e9-b2cc-a386d1325aec-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 2017-05-17 15:45 ` [PATCH 1/2] spidev: Delete error messages for failed memory allocations in spidev_open() SF Markus Elfring 2017-05-17 15:47 ` [PATCH 2/2] spidev: Adjust five checks for null pointers SF Markus Elfring [not found] ` <df3e58c6-f70d-a5d3-102e-4fab2f7df126-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 2017-05-18 11:28 ` Mark Brown 2017-05-18 14:34 ` SF Markus Elfring [not found] ` <5d9f71d4-2f0d-7083-fd28-fb505841b502-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> 2017-05-22 12:33 ` Mark Brown
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).