* [PATCH 0/3] [media] Siano: Adjustments for some function implementations
@ 2017-08-28 11:13 SF Markus Elfring
2017-08-28 11:14 ` [PATCH 1/3] [media] Siano: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-28 11:13 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Sakari Ailus; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Aug 2017 12:55:43 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in three functions
Improve a size determination in six functions
Adjust five checks for null pointers
drivers/media/common/siano/smscoreapi.c | 39 ++++++++++++++-------------------
1 file changed, 16 insertions(+), 23 deletions(-)
--
2.14.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] [media] Siano: Delete an error message for a failed memory allocation in three functions
2017-08-28 11:13 [PATCH 0/3] [media] Siano: Adjustments for some function implementations SF Markus Elfring
@ 2017-08-28 11:14 ` SF Markus Elfring
2017-08-28 11:15 ` [PATCH 2/3] [media] Siano: Improve a size determination in six functions SF Markus Elfring
2017-08-28 11:16 ` [PATCH 3/3] [media] Siano: Adjust five checks for null pointers SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-28 11:14 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Sakari Ailus; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Aug 2017 12:30:11 +0200
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/common/siano/smscoreapi.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index e7a0d7798d5b..889b486fbc72 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -1304,7 +1304,5 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode)
- if (!buffer) {
- pr_err("Could not allocate buffer for init device message.\n");
+ if (!buffer)
return -ENOMEM;
- }
msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
@@ -1690,7 +1688,6 @@ static int smscore_validate_client(struct smscore_device_t *coredev,
- if (!listentry) {
- pr_err("Can't allocate memory for client id.\n");
+ if (!listentry)
return -ENOMEM;
- }
+
listentry->id = id;
listentry->data_type = data_type;
list_add_locked(&listentry->entry, &client->idlist,
@@ -1728,7 +1725,5 @@ int smscore_register_client(struct smscore_device_t *coredev,
- if (!newclient) {
- pr_err("Failed to allocate memory for client.\n");
+ if (!newclient)
return -ENOMEM;
- }
INIT_LIST_HEAD(&newclient->idlist);
newclient->coredev = coredev;
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] [media] Siano: Improve a size determination in six functions
2017-08-28 11:13 [PATCH 0/3] [media] Siano: Adjustments for some function implementations SF Markus Elfring
2017-08-28 11:14 ` [PATCH 1/3] [media] Siano: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-08-28 11:15 ` SF Markus Elfring
2017-08-28 11:16 ` [PATCH 3/3] [media] Siano: Adjust five checks for null pointers SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-28 11:15 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Sakari Ailus; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Aug 2017 12:38:39 +0200
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/common/siano/smscoreapi.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 889b486fbc72..ad1c41f727b1 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -447,5 +447,5 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
return entry;
}
}
- entry = kmalloc(sizeof(struct smscore_registry_entry_t), GFP_KERNEL);
+ entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry) {
@@ -536,7 +536,5 @@ int smscore_register_hotplug(hotplug_t hotplug)
int rc = 0;
kmutex_lock(&g_smscore_deviceslock);
-
- notifyee = kmalloc(sizeof(struct smscore_device_notifyee_t),
- GFP_KERNEL);
+ notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
if (notifyee) {
@@ -627,5 +625,5 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
{
struct smscore_buffer_t *cb;
- cb = kzalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
+ cb = kzalloc(sizeof(*cb), GFP_KERNEL);
if (!cb)
@@ -655,5 +653,5 @@ int smscore_register_device(struct smsdevice_params_t *params,
struct smscore_device_t *dev;
u8 *buffer;
- dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL);
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
@@ -1684,5 +1682,5 @@ static int smscore_validate_client(struct smscore_device_t *coredev,
pr_err("The msg ID already registered to another client.\n");
return -EEXIST;
}
- listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
+ listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
if (!listentry)
@@ -1721,5 +1719,5 @@ int smscore_register_client(struct smscore_device_t *coredev,
return -EEXIST;
}
- newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
+ newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
if (!newclient)
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] [media] Siano: Adjust five checks for null pointers
2017-08-28 11:13 [PATCH 0/3] [media] Siano: Adjustments for some function implementations SF Markus Elfring
2017-08-28 11:14 ` [PATCH 1/3] [media] Siano: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-08-28 11:15 ` [PATCH 2/3] [media] Siano: Improve a size determination in six functions SF Markus Elfring
@ 2017-08-28 11:16 ` SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-28 11:16 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Sakari Ailus; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Aug 2017 12:50: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/media/common/siano/smscoreapi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index ad1c41f727b1..e4ea2a0c7a24 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -749,7 +749,7 @@ static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
void *buffer, size_t size, struct completion *completion) {
int rc;
- if (completion == NULL)
+ if (!completion)
return -EINVAL;
init_completion(completion);
@@ -1151,8 +1151,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
}
pr_debug("Firmware name: %s\n", fw_filename);
- if (loadfirmware_handler == NULL && !(coredev->device_flags
- & SMS_DEVICE_FAMILY2))
+ if (!loadfirmware_handler &&
+ !(coredev->device_flags & SMS_DEVICE_FAMILY2))
return -EINVAL;
rc = request_firmware(&fw, fw_filename, coredev->device);
@@ -1789,7 +1789,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer;
int rc;
- if (client == NULL) {
+ if (!client) {
pr_err("Got NULL client\n");
return -EINVAL;
}
@@ -1797,7 +1797,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
coredev = client->coredev;
/* check that no other channel with same id exists */
- if (coredev == NULL) {
+ if (!coredev) {
pr_err("Got NULL coredev\n");
return -EINVAL;
}
@@ -1954,7 +1954,7 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 pin_num,
if (pin_num > MAX_GPIO_PIN_NUMBER)
return -EINVAL;
- if (p_gpio_config == NULL)
+ if (!p_gpio_config)
return -EINVAL;
total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6);
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-28 11:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-28 11:13 [PATCH 0/3] [media] Siano: Adjustments for some function implementations SF Markus Elfring
2017-08-28 11:14 ` [PATCH 1/3] [media] Siano: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-08-28 11:15 ` [PATCH 2/3] [media] Siano: Improve a size determination in six functions SF Markus Elfring
2017-08-28 11:16 ` [PATCH 3/3] [media] Siano: Adjust five 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;
as well as URLs for NNTP newsgroup(s).