Skip to contentSkip to conversation

serial: sccnxp: replace memcpy with struct assignment

PATCH In review Fengguang Wu 2 participants 3 messages Oct 1, 2013 – Oct 4, 2013 2 messages not in the archive TTY layer and serial drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 5244e22f.VLBQtuO7RvNh9dWF%[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 serial: sccnxp: replace memcpy with struct assignment

Generated by: coccinelle/misc/memcpy-assign.cocci

CC Alexander Shiyan <[email protected]>

---

 drivers/tty/serial/sccnxp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sccnxp.c +1 -1
@@ -907,7 +907,7 @@ static int sccnxp_probe(struct platform_
 	}
 
 	if (pdata)
-		memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata));
+		s->pdata = *pdata;
 
 	if (s->pdata.poll_time_us) {
 		dev_info(&pdev->dev, "Using poll mode, resolution %u usecs\n",
#3 lore raw
Quoted 12 lines · Fengguang Wu

Generated by: coccinelle/misc/memcpy-assign.cocci

CC Alexander Shiyan <[email protected]>

---

 drivers/tty/serial/sccnxp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/tty/serial/sccnxp.c static int sccnxp_probe(struct platform_ · line 910

Quoted 5 lines
drivers/tty/serial/sccnxp.c +1 -1
@@ -907,7 +907,7 @@ static int sccnxp_probe(struct platform_
 	}
 
 	if (pdata)
-		memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata));
+		s->pdata = *pdata;

I don't think you compiled this, as it breaks the build :(

#4 lore raw
Quoted 15 lines · Greg KH
Quoted 14 lines · Fengguang Wu

Generated by: coccinelle/misc/memcpy-assign.cocci

CC Alexander Shiyan <[email protected]>

---

 drivers/tty/serial/sccnxp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sccnxp.c +0 -0
@@ -907,7 +907,7 @@ static int sccnxp_probe(struct platform_
 	}
 
Quoted 5 lines

drivers/tty/serial/sccnxp.c static int sccnxp_probe(struct platform_ · line 910

Quoted 3 lines
drivers/tty/serial/sccnxp.c +1 -1
 	if (pdata)
-		memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata));
+		s->pdata = *pdata;

I don't think you compiled this, as it breaks the build :(

Yeah, sorry! I'll take care next time..

drivers/tty/serial/sccnxp.c: In function 'sccnxp_probe':

Quoted 1 line
Quoted 1 line

drivers/tty/serial/sccnxp.c:910:3: error: assignment of read-only member 'pdata'

      s->pdata = *pdata;                                                           
      ^                 

Thanks,
Fengguang