Commit d796588b authored by Markus Armbruster's avatar Markus Armbruster Committed by Thomas Huth
Browse files

pc-bios/s390-ccw: Clean up harmless misuse of isdigit()



atoui() and get_index() pass char values to isdigit().  With a
standard isdigit(), we'd get undefined behavior when the value is
negative.  Can't happen as char is unsigned on s390x.  Even if it
ould, we're actually using isdigit() from pc-bios/s390-ccw/libc.h
here, which works fine for negative values.  Clean up anyway, just
to avoid setting a bad example.

Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Message-Id: <20190418145355.21100-6-armbru@redhat.com>
[thuth: updated the commit message]
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent a6f6d247
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ uint64_t atoui(const char *str)
    }

    while (*str) {
        if (!isdigit(*str)) {
        if (!isdigit(*(unsigned char *)str)) {
            break;
        }
        val = val * 10 + *str - '0';
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ static int get_index(void)

    /* Check for erroneous input */
    for (i = 0; i < len; i++) {
        if (!isdigit(buf[i])) {
        if (!isdigit((unsigned char)buf[i])) {
            return -1;
        }
    }