Ticket #2988: remove unreachable code - Denys Vlasenko <vda.linux@googlemail.com> - 2012-10-22 1749.patch

File remove unreachable code - Denys Vlasenko <vda.linux@googlemail.com> - 2012-10-22 1749.patch, 1.6 KB (added by slavazanko, 7 years ago)
  • lib/tty/key.c

    From: Denys Vlasenko <vda.linux@googlemail.com>
    Date: Mon, 22 Oct 2012 16:49:43 +0200
    Subject: [PATCH 3/5] keyboard input: remove unreachable code
    
    With the recently rearranged code, it's easy to see that "this == NULL"
    can't be true here:
    
    note ->     if (!this->child)
                {   ...
                    return correct_key_code (code);
                }
                if (!push_char (c))
                {   ...
                    goto pend_send;
                }
                keylog (" push_char(%d) ok\n", c);
                parent = this;
    never NULL->this = this->child;
                if (parent->action == MCKEY_ESCAPE && old_esc_mode)
                {
                    if (no_delay)
                    {
                        GET_TIME (esctime);
    can't be true---->  if (this == NULL)
    
    This patch removes that if().
    
    Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
    ---
     lib/tty/key.c |    6 ------
     1 files changed, 0 insertions(+), 6 deletions(-)
    
    diff --git a/lib/tty/key.c b/lib/tty/key.c
    index 33732db..77185ce 100644
    a b get_key_code (int no_delay) 
    19991999                if (no_delay) 
    20002000                { 
    20012001                    GET_TIME (esctime); 
    2002                     if (this == NULL) 
    2003                     { 
    2004                         /* Shouldn't happen */ 
    2005                         fputs ("Internal error\n", stderr); 
    2006                         exit (EXIT_FAILURE); 
    2007                     } 
    20082002                    goto nodelay_try_again; 
    20092003                } 
    20102004                esctime.tv_sec = -1;