Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1735558 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-09-20 08:40 +0200 |
| Last post | 2017-09-20 08:40 +0200 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/3] [media] pvrusb2-ioread: Fine-tuning for eight function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-20 08:40 +0200
[PATCH 2/3] [media] pvrusb2-ioread: Delete an unnecessary check before kfree() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-20 08:40 +0200
[PATCH 1/3] [media] pvrusb2-ioread: Use common error handling code in pvr2_ioread_get_buffer() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-20 08:40 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-20 08:40 +0200 |
| Subject | [PATCH 0/3] [media] pvrusb2-ioread: Fine-tuning for eight function implementations |
| Message-ID | <urGPU-7L3-13@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Wed, 20 Sep 2017 08:28:48 +0200 Three update suggestions were taken into account from static source code analysis. Markus Elfring (3): Use common error handling code in pvr2_ioread_get_buffer() Delete an unnecessary check before kfree() in two functions Delete unnecessary braces in six functions drivers/media/usb/pvrusb2/pvrusb2-ioread.c | 60 +++++++++++++----------------- 1 file changed, 25 insertions(+), 35 deletions(-) -- 2.14.1
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-20 08:40 +0200 |
| Subject | [PATCH 2/3] [media] pvrusb2-ioread: Delete an unnecessary check before kfree() in two functions |
| Message-ID | <urGPU-7L3-21@gated-at.bofh.it> |
| In reply to | #1735558 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Sep 2017 22:12:49 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: kfree(NULL) is safe and this check is probably not required
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/pvrusb2/pvrusb2-ioread.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
index 0218614ce988..4349f9b5f838 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c
@@ -98,10 +98,8 @@ void pvr2_ioread_destroy(struct pvr2_ioread *cp)
if (!cp) return;
pvr2_ioread_done(cp);
pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp);
- if (cp->sync_key_ptr) {
- kfree(cp->sync_key_ptr);
- cp->sync_key_ptr = NULL;
- }
+ kfree(cp->sync_key_ptr);
+ cp->sync_key_ptr = NULL;
kfree(cp);
}
@@ -117,10 +115,8 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp,
(!memcmp(sync_key_ptr,cp->sync_key_ptr,sync_key_len)))) return;
if (sync_key_len != cp->sync_key_len) {
- if (cp->sync_key_ptr) {
- kfree(cp->sync_key_ptr);
- cp->sync_key_ptr = NULL;
- }
+ kfree(cp->sync_key_ptr);
+ cp->sync_key_ptr = NULL;
cp->sync_key_len = 0;
if (sync_key_len) {
cp->sync_key_ptr = kmalloc(sync_key_len,GFP_KERNEL);
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-20 08:40 +0200 |
| Subject | [PATCH 1/3] [media] pvrusb2-ioread: Use common error handling code in pvr2_ioread_get_buffer() |
| Message-ID | <urGPV-7L3-29@gated-at.bofh.it> |
| In reply to | #1735558 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Tue, 19 Sep 2017 21:50:05 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/media/usb/pvrusb2/pvrusb2-ioread.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c index 602097bdcf14..0218614ce988 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-ioread.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-ioread.c @@ -266,8 +266,7 @@ static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp) pvr2_trace(PVR2_TRACE_DATA_FLOW, "/*---TRACE_READ---*/ pvr2_ioread_read id=%p queue_error=%d", cp,stat); - pvr2_ioread_stop(cp); - return 0; + goto stop_read; } cp->c_buf = NULL; cp->c_data_ptr = NULL; @@ -286,9 +285,8 @@ static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp) pvr2_trace(PVR2_TRACE_DATA_FLOW, "/*---TRACE_READ---*/ pvr2_ioread_read id=%p buffer_error=%d", cp,stat); - pvr2_ioread_stop(cp); // Give up. - return 0; + goto stop_read; } // Start over... continue; @@ -298,6 +296,10 @@ static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp) pvr2_buffer_get_id(cp->c_buf)]; } return !0; + +stop_read: + pvr2_ioread_stop(cp); + return 0; } static void pvr2_ioread_filter(struct pvr2_ioread *cp) -- 2.14.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web