Ticket #3547: mc-3547-cons.saver.c-fix-Wformat-nonliteral-warning.patch

File mc-3547-cons.saver.c-fix-Wformat-nonliteral-warning.patch, 2.0 KB (added by and, 7 years ago)
  • src/consaver/cons.saver.c

    From d69b4d8b9b06ab1467903d82d105ff21505f392e Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Fri, 27 Nov 2015 18:07:31 +0000
    Subject: [PATCH] cons.saver.c: fix -Wformat-nonliteral warning
    
    Let's decide about fix warning over more fashionable code concept at this single section
    
    cons.saver.c:213:52: warning: format string is not a string literal [-Wformat-nonliteral]
    cons.saver.c:220:46: warning: format string is not a string literal [-Wformat-nonliteral]
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/consaver/cons.saver.c | 11 ++++-------
     1 file changed, 4 insertions(+), 7 deletions(-)
    
    diff --git a/src/consaver/cons.saver.c b/src/consaver/cons.saver.c
    index 372fc55..4cfb4dc 100644
    a b main (int argc, char **argv) 
    163163    struct stat st; 
    164164    uid_t uid, euid; 
    165165    char *buffer, *tty_name, console_name[16], vcsa_name[16]; 
    166     const char *p, *q; 
    167166    struct winsize winsz; 
    168167 
    169168    close (STDERR_FILENO); 
    main (int argc, char **argv) 
    198197    { 
    199198        /* devfs */ 
    200199    case 'v': 
    201         p = "/dev/vc/%d"; 
    202         q = "/dev/vcc/a%d"; 
     200        snprintf (console_name, sizeof (console_name), "/dev/vc/%d", console_minor); 
     201        snprintf (vcsa_name, sizeof (vcsa_name), "/dev/vcc/a%d", console_minor); 
    203202        break; 
    204203        /* /dev/ttyN */ 
    205204    case 't': 
    206         p = "/dev/tty%d"; 
    207         q = "/dev/vcsa%d"; 
     205        snprintf (console_name, sizeof (console_name), "/dev/tty%d", console_minor); 
     206        snprintf (vcsa_name, sizeof (vcsa_name), "/dev/vcsa%d", console_minor); 
    208207        break; 
    209208    default: 
    210209        die (); 
    211210    } 
    212211 
    213     snprintf (console_name, sizeof (console_name), p, console_minor); 
    214212    if (strncmp (console_name, tty_name, sizeof (console_name)) != 0) 
    215213        die (); 
    216214 
    217215    if (seteuid (euid) < 0) 
    218216        die (); 
    219217 
    220     snprintf (vcsa_name, sizeof (vcsa_name), q, console_minor); 
    221218    vcsa_fd = open (vcsa_name, O_RDWR); 
    222219    if (vcsa_fd < 0) 
    223220        die ();