Skip to contentSkip to conversation

drivers/char/vt.c: remove unnecessary code

PATCH [email protected] 3 participants 5 messages Feb 28, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines
Quoted 6 lines

- for(npar = 0 ; npar < NPAR ; npar++)
+ for(npar = NPAR - 1; npar >= 0; npar--)
par[npar] = 0;

if you really want to clean this up..

Well, actually, I was not myself entirely convinced about it... This is the reason for I wrote "please _don't_ apply this, but tell me what you think about it.".

Quoted 1 line

why not use memset() instead ?

Because I simply didn't thought to it :-) .

Hey, that makes fully sense! So far I know, memset() is quicker than (or as quick as) a loop, and it remains fully readable (in my opinion :).

Well, such a patch would be :

char/vt2.c 2005-02-28 15:55:11.782717810 +0100 renamed from char/vt.c 2004-12-24 22:35:25.000000000 +0100 +2 -2
@@ -1655,8 +1655,8 @@
                        vc_state = ESnormal;
                return;
        case ESsquare:
-               for(npar = 0 ; npar < NPAR ; npar++)
-                       par[npar] = 0;
+               /* Setting par[]'s elems at 0.  */
+               memset(par, 0, NPAR*sizeof(unsigned int));
                npar = 0;
                vc_state = ESgetpars;
                if (c == '[') { /* Function key */

Thank you for the suggestion.
What do you think of this one?

(Please note that I'm not trying to get a patch for it _by force_ into the kernel. If it's a bad idea, let's let thing like they currently are, the current loop just works.)

cu

--
Emmanuel Colbus
Club GNU/Linux
ENSIMAG - Departement telecoms

-------------------------------------------------
envoyé via Webmail/IMAG !

#1 lore raw

char/vt2.c 2005-02-28 15:55:11.782717810 +0100 line 1659

Quoted 2 lines · On Mon, Feb 28, 2005 at 04:06:14PM +0100, [email protected] wrote:
char/vt2.c 2005-02-28 15:55:11.782717810 +0100 renamed from char/vt.c 2004-12-24 22:35:25.000000000 +0100 +2 -0
+               /* Setting par[]'s elems at 0.  */
+               memset(par, 0, NPAR*sizeof(unsigned int));

No need for the comment here, everybody understands C.

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>    
#2 lore raw
Quoted 6 lines · Stelian Pop

Review

Quoted 2 lines · On Mon, Feb 28, 2005 at 04:06:14PM +0100, [email protected] wrote:
(quoted diff) +2 -0
+               /* Setting par[]'s elems at 0.  */
+               memset(par, 0, NPAR*sizeof(unsigned int));

No need for the comment here, everybody understands C.

I knew this code would be understood, but I like comments :-) .

Well, without it, it gives :

drivers/char/vt.c 2005-02-28 18:19:11.782717810 +0100 renamed from drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100 +0 -0
@@ -1655,8 +1655,8 @@

vc_state = ESnormal;
return;
case ESsquare:
- for(npar = 0 ; npar < NPAR ; npar++)
- par[npar] = 0;
+ memset(par, 0, NPAR*sizeof(unsigned int));
npar = 0;
vc_state = ESgetpars;
if (c == '[') { /* Function key */

Any other comments/remarks, or is _this_ patch version acceptable?

--
Emmanuel Colbus
Club GNU/Linux
ENSIMAG - Departement telecoms

#3 lore raw
Quoted 20 lines · On Mon, Feb 28, 2005 at 06:29:39PM +0100, [email protected] wrote:

Well, without it, it gives :

drivers/char/vt.c 2005-02-28 18:19:11.782717810 +0100 renamed from drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100 +0 -0
@@ -1655,8 +1655,8 @@
 vc_state = ESnormal;
 return;

case ESsquare:
- for(npar = 0 ; npar < NPAR ; npar++)
- par[npar] = 0;
+ memset(par, 0, NPAR*sizeof(unsigned int));
npar = 0;
vc_state = ESgetpars;
if (c == '[') { /* Function key */

Quoted 1 line

Any other comments/remarks, or is _this_ patch version acceptable?

A not whitespace-mangled version of it could be.

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>    
#4 lore raw
In reply to [email protected]
Quoted 23 lines · On Mon, Feb 28, 2005 at 06:29:39PM +0100, [email protected] wrote:
Quoted 6 lines · Stelian Pop

Review

Quoted 2 lines · On Mon, Feb 28, 2005 at 04:06:14PM +0100, [email protected] wrote:
(quoted diff) +2 -0
+               /* Setting par[]'s elems at 0.  */
+               memset(par, 0, NPAR*sizeof(unsigned int));

No need for the comment here, everybody understands C.

I knew this code would be understood, but I like comments :-) .

Well, without it, it gives :

drivers/char/vt.c 2005-02-28 18:19:11.782717810 +0100 renamed from drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100 +0 -0
@@ -1655,8 +1655,8 @@
 vc_state = ESnormal;
 return;
Quoted 6 lines

case ESsquare:
- for(npar = 0 ; npar < NPAR ; npar++)
- par[npar] = 0;
+ memset(par, 0, NPAR*sizeof(unsigned int));
...
Any other comments/remarks, or is _this_ patch version acceptable?

- whitespace damage
- your sizeof is extremely fragile
why don't you run sizeof on the array?
- please do any development against -mm
you'll note that the code you are working against has significantely changed in -mm

Quoted 1 line

Emmanuel Colbus

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed