]> xenbits.xensource.com Git - xen.git/commitdiff
APEI: pull a signedness check ahead for Coverity's sake
authorJan Beulich <jbeulich@suse.com>
Fri, 17 Jun 2016 08:22:22 +0000 (10:22 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 17 Jun 2016 08:22:22 +0000 (10:22 +0200)
On 64-bit architectures (which is all we care about right now in ACPI
code), the value coming from a __u32 field makes "len" positive anyway,
but since from an abstract pov the tool is right, let's just re-order
things.

Coverity ID: 1204965

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/drivers/acpi/apei/erst.c

index 8d721d05e68b28a9e96643bfe909cb47d10133d9..14acf5d7738155eccc8b30c454e37c08824f2920 100644 (file)
@@ -672,9 +672,11 @@ static ssize_t __erst_read(u64 record_id, struct cper_record_header *record,
        if (rcd_tmp->record_length > buflen)
                return -ENOBUFS;
        len = rcd_tmp->record_length;
+       if (len < 0)
+               return -ERANGE;
        memcpy(record, rcd_tmp, len);
 
-       return len >= 0 ? len : -ERANGE;
+       return len;
 }
 
 /*