DMA-buf: Fine-tuning for four function implementations
cover DMA-buf: Fine-tuning for four function implementations
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 11:05:05 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (4):
Combine two function calls into one in dma_buf_debug_show() Improve a size determination in dma_buf_attach() Adjust a null pointer check in dma_buf_attach() Use seq_putc() in two functions
drivers/dma-buf/dma-buf.c | 8 +++----- drivers/dma-buf/sync_debug.c | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/4 dma-buf: Combine two function calls into one in dma_buf_debug_show()
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:32:44 +0200
A bit of data was put into a sequence by two separate function calls. Print the same data by a single function call instead.
This issue was detected by using the Coccinelle software.
--- drivers/dma-buf/dma-buf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma-buf/dma-buf.c +1 -3
@@ -1122,9 +1122,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) attach_count =0 ;list_for_each_entry (attach_obj, &buf_obj->attachments, node) { -seq_puts (s,"\t" ); - -seq_printf (s,"%s\n" ,dev_name (attach_obj->dev)); +seq_printf (s,"\t%s\n" ,dev_name (attach_obj->dev)); attach_count++; }
Signature · 1 line
2.12.2
Re: [PATCH 1/4] dma-buf: Combine two function calls into one in dma_buf_debug_show()
2017-05-08 SF Markus Elfring <[email protected]>:
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:32:44 +0200A bit of data was put into a sequence by two separate function calls. Print the same data by a single function call instead.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/dma-buf/dma-buf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Gustavo
PATCH 2/4 dma-buf: Improve a size determination in dma_buf_attach()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:50:09 +0200
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf.c +1 -1
@@ -558,7 +558,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,if (WARN_ON (!dmabuf || !dev))return ERR_PTR (-EINVAL ); - attach =kzalloc (sizeof (struct dma_buf_attachment ),GFP_KERNEL ); + attach =kzalloc (sizeof (*attach),GFP_KERNEL );if (attach =NULL )return ERR_PTR (-ENOMEM );
Signature · 1 line
2.12.2
Re: [PATCH 2/4] dma-buf: Improve a size determination in dma_buf_attach()
2017-05-08 SF Markus Elfring <[email protected]>:
Quoted 11 lines
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:50:09 +0200Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Gustavo
PATCH 3/4 dma-buf: Adjust a null pointer check in dma_buf_attach()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:54:17 +0200
The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written "!attach"
Thus adjust this expression.
--- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf.c +1 -1
@@ -559,7 +559,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,return ERR_PTR (-EINVAL ); attach =kzalloc (sizeof (*attach),GFP_KERNEL ); -if (attach =NULL ) +if (!attach)return ERR_PTR (-ENOMEM ); attach->dev = dev;
Signature · 1 line
2.12.2
Re: [PATCH 3/4] dma-buf: Adjust a null pointer check in dma_buf_attach()
2017-05-08 SF Markus Elfring <[email protected]>:
Quoted 5 lines
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:54:17 +0200The script "checkpatch.pl" pointed information out like the following.
Quoted 8 lines
Comparison to NULL could be written "!attach"
Thus adjust this expression.
Signed-off-by Markus Elfring <[email protected]>--- drivers/dma-buf/dma-buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Gustavo
PATCH 4/4 dma-buf: Use seq_putc() in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:55:42 +0200
Three single characters (line breaks) should be put into a sequence. Thus use the corresponding function "seq_putc".
This issue was detected by using the Coccinelle software.
--- drivers/dma-buf/sync_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma-buf/sync_debug.c +3 -3
@@ -110,7 +110,7 @@ static void sync_print_fence(struct seq_file *s, } } -seq_puts (s,"\n" ); +seq_putc (s,'\n' ); }static void sync_print_obj (struct seq_file *s,struct sync_timeline *obj)
@@ -161,7 +161,7 @@ static int sync_debugfs_show(struct seq_file *s, void *unused) sync_timeline_list);sync_print_obj (s, obj); -seq_puts (s,"\n" ); +seq_putc (s,'\n' ); }spin_unlock_irqrestore (&sync_timeline_list_lock, flags);
@@ -173,7 +173,7 @@ static int sync_debugfs_show(struct seq_file *s, void *unused) container_of(pos, struct sync_file, sync_file_list);sync_print_sync_file (s, sync_file); -seq_puts (s,"\n" ); +seq_putc (s,'\n' ); }spin_unlock_irqrestore (&sync_file_list_lock, flags);return 0 ;
Signature · 1 line
2.12.2
Re: [PATCH 4/4] dma-buf: Use seq_putc() in two functions
Hi Markus,
Thank for your patches.
2017-05-08 SF Markus Elfring <[email protected]>:
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 10:55:42 +0200Three single characters (line breaks) should be put into a sequence. Thus use the corresponding function "
seq_putc".
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/dma-buf/sync_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Gustavo
Sumit Semwal
maintainerHi Markus,
On May 8, 2017 14:40, "SF Markus Elfring" <[email protected]> wrote:
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 11:05:05 +0200
A few update suggestions were taken into account
from static source code analysis.
Thanks much for your patches; will where them up now.
Markus Elfring (4):
Combine two function calls into one in dma_buf_debug_show() Improve a size determination in dma_buf_attach() Adjust a null pointer check in dma_buf_attach() Use seq_putc() in two functions
drivers/dma-buf/dma-buf.c | 8 +++----- drivers/dma-buf/sync_debug.c | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-)
Best,
Sumit.
--
2.12.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sumit Semwal
maintainerHello Markus,
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 8 May 2017 11:05:05 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (4):
Combine two function calls into one indma_buf_debug_show()Improve a size determination indma_buf_attach()Adjust a null pointer check indma_buf_attach()Useseq_putc()in two functions
All queued up in drm-misc-next now. Thanks!
Quoted 8 lines
drivers/dma-buf/dma-buf.c | 8 +++----- drivers/dma-buf/sync_debug.c | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-)--
2.12.2
Best regards,
Sumit.