tCast isprint() argument to unsigned char - spoon - dwm status utility (2f30 fork)
 (HTM) git clone git://src.adamsgaard.dk/spoon
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 38c784dbf87e6629ec50c4c80c5ee16c834d1f42
 (DIR) parent 6d810a050344c349a02eeeba238ba47f57e2e987
 (HTM) Author: sin <sin@2f30.org>
       Date:   Mon, 29 May 2017 15:34:12 +0100
       
       Cast isprint() argument to unsigned char
       
       The type of buf[i] is char.  On systems where char is signed it is
       possible that a negative value other than EOF is passed to isprint().
       This in turn invokes undefined behaviour.
       
       Diffstat:
         M file.c                              |       2 +-
       
       1 file changed, 1 insertion(+), 1 deletion(-)
       ---
 (DIR) diff --git a/file.c b/file.c
       t@@ -42,7 +42,7 @@ fileread(void *arg, char *buf, size_t len)
                        buf[n - 1] = '\0';
                /* stop at the first non-printable character */
                for (i = 0; i < len; i++)
       -                if (!isprint(buf[i]))
       +                if (!isprint((unsigned char)buf[i]))
                                buf[i] = '\0';
                return 0;
        }