Skip to contentSkip to conversation

serial_core: fix sizeof(pointer)

PATCH In review Fengguang Wu 3 participants 4 messages Sep 6, 2012 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial_core: fix sizeof(pointer)

sizeof when applied to a pointer typed expression gives the size of the pointer.

Generated by: scripts/coccinelle/misc/noderef.cocci

---

 cocci-output-38612-39d907-serial_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +1 -1
@@ -640,7 +640,7 @@ static void uart_get_info(struct tty_por
 {
 	struct uart_port *uport = state->uart_port;
 
-	memset(retinfo, 0, sizeof(retinfo));
+	memset(retinfo, 0, sizeof(*retinfo));
 
 	retinfo->type	    = uport->type;
 	retinfo->line	    = uport->line;
#1 lore raw
Quoted 14 lines · Fengguang Wu

sizeof when applied to a pointer typed expression gives the size of the pointer.

Generated by: scripts/coccinelle/misc/noderef.cocci

---

 cocci-output-38612-39d907-serial_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/tty/serial/serial_core.c static void uart_get_info(struct tty_por · line 643

Quoted 5 lines
drivers/tty/serial/serial_core.c +1 -1
@@ -640,7 +640,7 @@ static void uart_get_info(struct tty_por
 {
 	struct uart_port *uport = state->uart_port;
 
-	memset(retinfo, 0, sizeof(retinfo));
+	memset(retinfo, 0, sizeof(*retinfo));

Hmm, what tree is this against? I have:

memset(&tmp, 0, sizeof(tmp));

thanks,

Signature · 2 lines
js
suse labs
#2 lore raw
Quoted 18 lines · Jiri Slaby
Quoted 17 lines · Fengguang Wu

sizeof when applied to a pointer typed expression gives the size of the pointer.

Generated by: scripts/coccinelle/misc/noderef.cocci

---

 cocci-output-38612-39d907-serial_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +0 -0
@@ -640,7 +640,7 @@ static void uart_get_info(struct tty_por
 {
 	struct uart_port *uport = state->uart_port;
 
Quoted 4 lines

drivers/tty/serial/serial_core.c static void uart_get_info(struct tty_por · line 643

Quoted 2 lines
drivers/tty/serial/serial_core.c +1 -1
-	memset(retinfo, 0, sizeof(retinfo));
+	memset(retinfo, 0, sizeof(*retinfo));

Hmm, what tree is this against? I have:

It's the tty:tty-next tree.

git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-next

Quoted 1 line

memset(&tmp, 0, sizeof(tmp));

Oh I didn't know it's a new bug introduced by commit

commit 7ba2e769825fef035a943ed74d90379245508764
Author: Alan Cox <[email protected]>
AuthorDate: Tue Sep 4 16:34:45 2012 +0100
Commit: Greg Kroah-Hartman <[email protected]>
CommitDate: Wed Sep 5 13:11:03 2012 -0700

tty: Split the serial_core helpers for setserial into two

Thanks,
Fengguang