Re: [patch 3/2] drivers/char/vt.c: remove unnecessary code

colbuse_at_ensisun.imag.fr
Date: 02/28/05

  • Next message: jamal: "Re: [Lse-tech] Re: A common layer for Accounting packages"
    Date:	Mon, 28 Feb 2005 15:01:15 +0100
    To: Russell King <rmk+lkml@arm.linux.org.uk>, linux-kernel@vger.kernel.org
    
    

    Surlignage Russell King <rmk+lkml@arm.linux.org.uk>:

    > On Mon, Feb 28, 2005 at 02:13:57PM +0100, colbuse@ensisun.imag.fr wrote:
    > > NPAR times :-). As I stated, npar is unsigned.
    >
    > I think that's disgusting then - it isn't obvious what's going on, which
    > leads to mistakes.
    >
    > For the sake of a micro-optimisation such as this, it's far more important
    > that the code be readable and easily understandable.
    >
    > Others may disagree.
    >

    I agree :) . But, if we look to the code, we can notice that there is actually
    no reason for npar to be unsigned. What do you think of this version?

    --- old/drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100
    +++ new/drivers/char/vt.c 2005-02-28 12:53:57.933256631 +0100
    @@ -1655,9 +1655,9 @@
                            vc_state = ESnormal;
                    return;
            case ESsquare:
    - for(npar = 0 ; npar < NPAR ; npar++)
    + for(npar = NPAR - 1; npar >= 0; npar--)
                            par[npar] = 0;
    + npar++;
    - npar = 0;
                    vc_state = ESgetpars;
                    if (c == '[') { /* Function key */
                            vc_state=ESfunckey;

    --- old/include/linux/console_struct.h 2004-12-24 22:33:48.000000000 +0100
    +++ old/include/linux/console_struct.h 2005-02-28 14:49:53.653616335 +0100
    @@ -44,7 +44,8 @@
            unsigned short vc_video_erase_char; /* Background erase character */
            /* VT terminal data */
            unsigned int vc_state; /* Escape sequence parser state */
    - unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape
    sequence */
    + unsigned int vc_par[NPAR]; /* Parameters of current escape
    sequence */
    + int vc_npar; /* Current position in vc_par */
            struct tty_struct *vc_tty; /* TTY we are attached to */
            /* mode flags */
            unsigned int vc_charset : 1; /* Character set G0 / G1 */

    --
    Emmanuel Colbus
    Club GNU/Linux
    ENSIMAG - Departement telecoms
    -------------------------------------------------
    envoyé via Webmail/IMAG !
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: jamal: "Re: [Lse-tech] Re: A common layer for Accounting packages"

    Relevant Pages

    • Re: [patch 3/2] drivers/char/vt.c: remove unnecessary code
      ... leads to mistakes. ... For the sake of a micro-optimisation such as this, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Semaphore assembly-code bug
      ... > The sequence ... In contrast, the three moves and an add is 15 bytes. ... with profile feedback] ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] Add kallsyms_lookup() result cache
      ... kernel modules may be loaded or unloaded at any time ... I like the sequence number suggestion better. ... Supply the raw task_struct and the needed debug info ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] VGA arbitration: draft of kernel side
      ... > How do I do the 'disable all, post, renable last active' sequence in ... > this scheme? ... I have a draft of the userland API. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [BUG] Race with iput and umount
      ... > iputpast the unlocking the parent for the sake of contention if a wunch ... "When there is a continuous streaming write to the same disk, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)