* [PATCH 0/2] FireWire-nosy: Adjustments for three function implementations
@ 2018-02-13 18:32 SF Markus Elfring
2018-02-13 18:33 ` [PATCH 1/2] firewire: nosy: Delete an error message for a failed memory allocation in add_card() SF Markus Elfring
2018-02-13 18:34 ` [PATCH 2/2] firewire: nosy: Adjust eight checks for null pointers SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2018-02-13 18:32 UTC (permalink / raw)
To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Feb 2018 19:30:19 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an error message for a failed memory allocation in add_card()
Adjust eight checks for null pointers
drivers/firewire/nosy.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
--
2.16.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] firewire: nosy: Delete an error message for a failed memory allocation in add_card()
2018-02-13 18:32 [PATCH 0/2] FireWire-nosy: Adjustments for three function implementations SF Markus Elfring
@ 2018-02-13 18:33 ` SF Markus Elfring
2018-02-13 18:34 ` [PATCH 2/2] firewire: nosy: Adjust eight checks for null pointers SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2018-02-13 18:33 UTC (permalink / raw)
To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Feb 2018 18:33:45 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/firewire/nosy.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index fee2e9e7ea20..6192f0718bf2 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -553,7 +553,6 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
lynx = kzalloc(sizeof *lynx, GFP_KERNEL);
if (lynx = NULL) {
- dev_err(&dev->dev, "Failed to allocate control structure\n");
ret = -ENOMEM;
goto fail_disable;
}
--
2.16.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] firewire: nosy: Adjust eight checks for null pointers
2018-02-13 18:32 [PATCH 0/2] FireWire-nosy: Adjustments for three function implementations SF Markus Elfring
2018-02-13 18:33 ` [PATCH 1/2] firewire: nosy: Delete an error message for a failed memory allocation in add_card() SF Markus Elfring
@ 2018-02-13 18:34 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2018-02-13 18:34 UTC (permalink / raw)
To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Feb 2018 19:20:26 +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/firewire/nosy.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 6192f0718bf2..0eaf79c625c6 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -128,7 +128,7 @@ static int
packet_buffer_init(struct packet_buffer *buffer, size_t capacity)
{
buffer->data = kmalloc(capacity, GFP_KERNEL);
- if (buffer->data = NULL)
+ if (!buffer->data)
return -ENOMEM;
buffer->head = (struct packet *) buffer->data;
buffer->tail = (struct packet *) buffer->data;
@@ -287,11 +287,11 @@ nosy_open(struct inode *inode, struct file *file)
break;
}
mutex_unlock(&card_mutex);
- if (lynx = NULL)
+ if (!lynx)
return -ENODEV;
client = kmalloc(sizeof *client, GFP_KERNEL);
- if (client = NULL)
+ if (!client)
goto fail;
client->tcode_mask = ~0;
@@ -552,7 +552,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
pci_set_master(dev);
lynx = kzalloc(sizeof *lynx, GFP_KERNEL);
- if (lynx = NULL) {
+ if (!lynx) {
ret = -ENOMEM;
goto fail_disable;
}
@@ -565,7 +565,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
lynx->registers = ioremap_nocache(pci_resource_start(dev, 0),
PCILYNX_MAX_REGISTER);
- if (lynx->registers = NULL) {
+ if (!lynx->registers) {
dev_err(&dev->dev, "Failed to map registers\n");
ret = -ENOMEM;
goto fail_deallocate_lynx;
@@ -577,9 +577,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
sizeof(struct pcl), &lynx->rcv_pcl_bus);
lynx->rcv_buffer = pci_alloc_consistent(lynx->pci_device,
RCV_BUFFER_SIZE, &lynx->rcv_buffer_bus);
- if (lynx->rcv_start_pcl = NULL ||
- lynx->rcv_pcl = NULL ||
- lynx->rcv_buffer = NULL) {
+ if (!lynx->rcv_start_pcl || !lynx->rcv_pcl || !lynx->rcv_buffer) {
dev_err(&dev->dev, "Failed to allocate receive buffer\n");
ret = -ENOMEM;
goto fail_deallocate_buffers;
--
2.16.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-13 18:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-13 18:32 [PATCH 0/2] FireWire-nosy: Adjustments for three function implementations SF Markus Elfring
2018-02-13 18:33 ` [PATCH 1/2] firewire: nosy: Delete an error message for a failed memory allocation in add_card() SF Markus Elfring
2018-02-13 18:34 ` [PATCH 2/2] firewire: nosy: Adjust eight checks for null pointers SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox