staging: cxt1e1: remove unneeded a value
PATCH 7/7 staging: cxt1e1: remove unneeded a value
It doesn't need to assign name array address to np pointer.
--- drivers/staging/cxt1e1/linux.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/cxt1e1/linux.c +2 -3
@@ -205,15 +205,14 @@ status_t c4_wq_port_init(mpi_t *pi) { -char name[16 ], *np;/* NOTE: name of the queue limited by system +char name[16 ];/* NOTE: name of the queue limited by system * to 10 characters */ if (pi->wq_port)return 0 ;/* already initialized */ - np = name;memset (name,0 ,16 ); -sprintf (np,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ +sprintf (name,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ #ifdef RLD_RESTART_DEBUG pr_info(">> %s: creating workqueue <%s> for Port %d.\n",
Signature · 1 line
1.7.4.4
Quoted 15 lines · Daeseok Youn
It doesn't need to assign name array address to np pointer.
Signed-off-by Daeseok Youn <[email protected]>--- drivers/staging/cxt1e1/linux.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/staging/cxt1e1/linux.c +0
-0@@ -205,15 +205,14 @@ status_t c4_wq_port_init(mpi_t *pi) {
drivers/staging/cxt1e1/linux.c status_t · line 214
Quoted 10 lines
drivers/staging/cxt1e1/linux.c +1
-2-char name[16 ], *np;/* NOTE: name of the queue limited by system +char name[16 ];/* NOTE: name of the queue limited by system * to 10 characters */ if (pi->wq_port)return 0 ;/* already initialized */ - np = name;memset (name,0 ,16 );
This isn't necessary since s{,n}printf() adds a terminating '\0'.
drivers/staging/cxt1e1/linux.c status_t · line 215
Quoted 2 lines
drivers/staging/cxt1e1/linux.c +1
-1-sprintf (np,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ +sprintf (name,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */
Better use snprintf() here, even if the comment above claims the name never to be no longer than 10 characters.
Cheers
Tobias
2014-03-05 19:13 GMT+09:00 Tobias Klauser <[email protected]>:
Quoted 21 lines · Daeseok Youn
Quoted 20 lines
It doesn't need to assign name array address to np pointer.
Signed-off-by Daeseok Youn <[email protected]>--- drivers/staging/cxt1e1/linux.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/staging/cxt1e1/linux.c +1
-1@@ -205,15 +205,14 @@ status_t c4_wq_port_init(mpi_t *pi) { -char name[16 ], *np;/* NOTE: name of the queue limited by system +char name[16 ];/* NOTE: name of the queue limited by system * to 10 characters */
Quoted 7 lines
drivers/staging/cxt1e1/linux.c status_t · line 214
Quoted 5 lines
drivers/staging/cxt1e1/linux.c +0
-1if (pi->wq_port)return 0 ;/* already initialized */ - np = name;memset (name,0 ,16 );This isn't necessary since s{,n}printf() adds a terminating '\0'.
Yes, I have looked at lib/vsprintf.c. I found it adds null to a string in the end of vsnprintf() function.
I will remove memset() line.
Quoted 6 lines
drivers/staging/cxt1e1/linux.c status_t · line 215
Quoted 3 lines
drivers/staging/cxt1e1/linux.c +1
-1-sprintf (np,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ +sprintf (name,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ Better use
snprintf()here, even if the comment above claims the name never to be no longer than 10 characters.
OK. I will replace sprintf with snprintf() and set a string length to "10".
Thanks for review.
Daeseok Youn.
Quoted 3 lines
Cheers
Tobias
Quoted 34 lines · DaeSeok Youn
2014-03-05 19:13 GMT+09:00 Tobias Klauser <[email protected]>:
Quoted 21 lines · Daeseok Youn
Quoted 20 lines
It doesn't need to assign name array address to np pointer.
Signed-off-by Daeseok Youn <[email protected]>--- drivers/staging/cxt1e1/linux.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/staging/cxt1e1/linux.c +1
-1@@ -205,15 +205,14 @@ status_t c4_wq_port_init(mpi_t *pi) { -char name[16 ], *np;/* NOTE: name of the queue limited by system +char name[16 ];/* NOTE: name of the queue limited by system * to 10 characters */ Quoted 7 lines
drivers/staging/cxt1e1/linux.c status_t · line 214
Quoted 5 lines
drivers/staging/cxt1e1/linux.c +0
-1if (pi->wq_port)return 0 ;/* already initialized */ - np = name;memset (name,0 ,16 );This isn't necessary since s{,n}printf() adds a terminating '\0'.
Yes, I have looked at
lib/vsprintf.c. I found it adds null to a string in the end ofvsnprintf()function.
I will removememset()line.Quoted 1 line
Quoted 6 lines
Quoted 5 lines
drivers/staging/cxt1e1/linux.c status_t · line 215
Quoted 2 lines
drivers/staging/cxt1e1/linux.c +1
-1-sprintf (np,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ +sprintf (name,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ Better use
snprintf()here, even if the comment above claims the name never to be no longer than 10 characters.OK. I will replace sprintf with
snprintf()and set a string length to "10".
It's probably fine to leave the string at length 16 (since there's also a number appended to it) and the use sizeof(name) for the snprintf call.
Cheers
Tobias
Ok.
I will use sizeof(name) for snprintf() call.
Thanks.
Daeseok Youn.
2014-03-06 16:33 GMT+09:00 Tobias Klauser <[email protected]>:
Quoted 47 lines · DaeSeok Youn
Quoted 34 lines
2014-03-05 19:13 GMT+09:00 Tobias Klauser <[email protected]>:
Quoted 21 lines · Daeseok Youn
Quoted 20 lines
It doesn't need to assign name array address to np pointer.
Signed-off-by Daeseok Youn <[email protected]>--- drivers/staging/cxt1e1/linux.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/staging/cxt1e1/linux.c +1
-1@@ -205,15 +205,14 @@ status_t c4_wq_port_init(mpi_t *pi) { -char name[16 ], *np;/* NOTE: name of the queue limited by system +char name[16 ];/* NOTE: name of the queue limited by system * to 10 characters */ Quoted 7 lines
drivers/staging/cxt1e1/linux.c status_t · line 214
Quoted 5 lines
drivers/staging/cxt1e1/linux.c +0
-1if (pi->wq_port)return 0 ;/* already initialized */ - np = name;memset (name,0 ,16 );This isn't necessary since s{,n}printf() adds a terminating '\0'.
Yes, I have looked at
lib/vsprintf.c. I found it adds null to a string in the end ofvsnprintf()function.
I will removememset()line.Quoted 1 line
Quoted 6 lines
Quoted 5 lines
drivers/staging/cxt1e1/linux.c status_t · line 215
Quoted 2 lines
drivers/staging/cxt1e1/linux.c +1
-1-sprintf (np,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ +sprintf (name,"%s%d" , pi->up->devname, pi->portnum);/* IE pmcc4-01) */ Better use
snprintf()here, even if the comment above claims the name never to be no longer than 10 characters.OK. I will replace sprintf with
snprintf()and set a string length to "10".It's probably fine to leave the string at length 16 (since there's also a number appended to it) and the use sizeof(name) for the snprintf call.
Cheers
Tobias