Skip to contentSkip to conversation

DMA-buf: Fine-tuning for four function implementations

PATCH In review SF Markus Elfring 3 participants 11 messages May 8, 2017 – May 9, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 512bdbc23bbb..53257c166f4d 100644
@@ -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
Reviewed-by on v1 1/4
#2 lore raw

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 +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.

Quoted 6 lines

This issue was detected by using the Coccinelle software.

---
 drivers/dma-buf/dma-buf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Gustavo

#3 lore raw

PATCH 2/4 dma-buf: Improve a size determination in dma_buf_attach()

In reply to SF Markus Elfring

From: 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
index 53257c166f4d..9887d72cf804 100644
@@ -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
Reviewed-by on v1 2/4
#4 lore raw

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 +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(-)

Gustavo

#5 lore raw

PATCH 3/4 dma-buf: Adjust a null pointer check in dma_buf_attach()

In reply to SF Markus Elfring

From: 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
index 9887d72cf804..4a038dcf5361 100644
@@ -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
Reviewed-by on v1 3/4
#6 lore raw

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 +0200

The script "checkpatch.pl" pointed information out like the following.

Quoted 8 lines

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(-)

Gustavo

#7 lore raw

PATCH 4/4 dma-buf: Use seq_putc() in two functions

In reply to SF Markus Elfring

From: 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
index c769dc653b34..a0d780ab68c3 100644
@@ -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
Reviewed-by on v1 4/4
#8 lore raw

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 +0200

Three 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.

---
 drivers/dma-buf/sync_debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Gustavo

maintainer
#9 lore raw
In reply to SF Markus Elfring

Hi 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

maintainer
#10 lore raw
In reply to SF Markus Elfring

Hello Markus,

Quoted 11 lines · SF Markus Elfring

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

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.