]> granicus.if.org Git - strace/blobdiff - term.c
tests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c
[strace] / term.c
diff --git a/term.c b/term.c
index 530ffc4cadc35e28ba31503e4a86ffce00f13f77..cfb878b0fa561e8974b4369441ac2cfdbb5867b6 100644 (file)
--- a/term.c
+++ b/term.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 1996-2018 The strace developers.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "xlat/modem_flags.h"
 
 static void
-decode_termios(struct tcb *tcp, const long addr)
+decode_termios(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct termios tios;
-       int i;
-
-       if (!verbose(tcp))
-               return;
 
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &tios))
@@ -67,21 +64,17 @@ decode_termios(struct tcb *tcp, const long addr)
        if (!(tios.c_lflag & ICANON))
                tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
                        tios.c_cc[VMIN], tios.c_cc[VTIME]);
-       tprintf("c_cc=\"");
-       for (i = 0; i < NCCS; i++)
-               tprintf("\\x%02x", tios.c_cc[i]);
-       tprintf("\"}");
+       tprints("c_cc=");
+       print_quoted_string((char *) tios.c_cc, NCCS, QUOTE_FORCE_HEX);
+       tprints("}");
 }
 
 static void
-decode_termio(struct tcb *tcp, const long addr)
+decode_termio(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct termio tio;
        int i;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &tio))
                return;
@@ -109,20 +102,17 @@ decode_termio(struct tcb *tcp, const long addr)
                tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
                        tio.c_cc[VMIN], tio.c_cc[VTIME]);
 #endif /* !_VMIN */
-       tprintf("c_cc=\"");
+       tprints("c_cc=\"");
        for (i = 0; i < NCC; i++)
                tprintf("\\x%02x", tio.c_cc[i]);
-       tprintf("\"}");
+       tprints("\"}");
 }
 
 static void
-decode_winsize(struct tcb *tcp, const long addr)
+decode_winsize(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct winsize ws;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &ws))
                return;
@@ -132,13 +122,10 @@ decode_winsize(struct tcb *tcp, const long addr)
 
 #ifdef TIOCGSIZE
 static void
-decode_ttysize(struct tcb *tcp, const long addr)
+decode_ttysize(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct ttysize ts;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &ts))
                return;
@@ -148,13 +135,10 @@ decode_ttysize(struct tcb *tcp, const long addr)
 #endif
 
 static void
-decode_modem_flags(struct tcb *tcp, const long addr)
+decode_modem_flags(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        int i;
 
-       if (!verbose(tcp))
-               return;
-
        tprints(", ");
        if (umove_or_printaddr(tcp, addr, &i))
                return;
@@ -164,7 +148,8 @@ decode_modem_flags(struct tcb *tcp, const long addr)
 }
 
 int
-term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
+term_ioctl(struct tcb *const tcp, const unsigned int code,
+          const kernel_ulong_t arg)
 {
        switch (code) {
        /* struct termios */
@@ -175,6 +160,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        case TIOCGLCKTRMIOS:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TCSETS:
 #ifdef TCSETS2
        case TCSETS2:
@@ -195,6 +181,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        case TCGETA:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TCSETA:
        case TCSETAW:
        case TCSETAF:
@@ -205,6 +192,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        case TIOCGWINSZ:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSWINSZ:
                decode_winsize(tcp, arg);
                break;
@@ -214,6 +202,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        case TIOCGSIZE:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSSIZE:
                decode_ttysize(tcp, arg);
                break;
@@ -222,11 +211,11 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        /* ioctls with a direct decodable arg */
        case TCXONC:
                tprints(", ");
-               printxval_long(tcxonc_options, arg, "TC???");
+               printxval64(tcxonc_options, arg, "TC???");
                break;
        case TCFLSH:
                tprints(", ");
-               printxval_long(tcflsh_options, arg, "TC???");
+               printxval64(tcflsh_options, arg, "TC???");
                break;
        case TCSBRK:
        case TCSBRKP:
@@ -238,6 +227,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        case TIOCMGET:
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
@@ -260,6 +250,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
 #endif
                if (entering(tcp))
                        return 0;
+               ATTRIBUTE_FALLTHROUGH;
        case TIOCSPGRP:
        case TIOCSETD:
        case FIONBIO:
@@ -274,7 +265,7 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        /* ioctls with an indirect parameter displayed as a char */
        case TIOCSTI:
                tprints(", ");
-               printstr(tcp, arg, 1);
+               printstrn(tcp, arg, 1);
                break;
 
        /* ioctls with no parameters */
@@ -301,5 +292,5 @@ term_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
                return RVAL_DECODED;
        }
 
-       return RVAL_DECODED | 1;
+       return RVAL_IOCTL_DECODED;
 }