qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3 V3] s390: implement pci instructions


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 2/3 V3] s390: implement pci instructions
Date: Tue, 20 Jan 2015 10:45:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

This patch makes Coverity unhappy:

*** CID 1264326:  Unintended sign extension  (SIGN_EXTENSION)
/hw/s390x/s390-pci-inst.c: 787 in stpcifc_service_call()
781         stq_p(&fib.pal, pbdev->pal);
782         stq_p(&fib.iota, pbdev->g_iota);
783         stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
784         stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
785         stq_p(&fib.fmb_addr, pbdev->fmb_addr);
786     
>>>     CID 1264326:  Unintended sign extension  (SIGN_EXTENSION)
>>>     Suspicious implicit sign extension: "pbdev->isc" with type
>>> "unsigned char" (8 bits, unsigned) is promoted in "(pbdev->isc <<
>>> 28) | (pbdev->noi << 16)" to type "int" (32 bits, signed), then
>>> sign-extended to type "unsigned long" (64 bits, unsigned).  If
>>> "(pbdev->isc << 28) | (pbdev->noi << 16)" is greater than
>>> 0x7FFFFFFF, the upper bits of the result will all be 1.
787         data = (pbdev->isc << 28) | (pbdev->noi << 16) |
788                (pbdev->routes.adapter.ind_offset << 8) | (pbdev->sum << 7) |
789                pbdev->routes.adapter.summary_offset;
790         stw_p(&fib.data, data);
791     
792         if (pbdev->fh >> ENABLE_BIT_OFFSET) {

________________________________________________________________________________________________________
*** CID 1264324:  Unintended sign extension  (SIGN_EXTENSION)
/hw/s390x/s390-pci-inst.c: 787 in stpcifc_service_call()
781         stq_p(&fib.pal, pbdev->pal);
782         stq_p(&fib.iota, pbdev->g_iota);
783         stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
784         stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
785         stq_p(&fib.fmb_addr, pbdev->fmb_addr);
786     
>>>     CID 1264324:  Unintended sign extension  (SIGN_EXTENSION)
>>>     Suspicious implicit sign extension: "pbdev->noi" with type
>>> "unsigned short" (16 bits, unsigned) is promoted in "(pbdev->isc
>>> << 28) | (pbdev->noi << 16)" to type "int" (32 bits, signed), then
>>> sign-extended to type "unsigned long" (64 bits, unsigned).  If
>>> "(pbdev->isc << 28) | (pbdev->noi << 16)" is greater than
>>> 0x7FFFFFFF, the upper bits of the result will all be 1.
787         data = (pbdev->isc << 28) | (pbdev->noi << 16) |
788                (pbdev->routes.adapter.ind_offset << 8) | (pbdev->sum << 7) |
789                pbdev->routes.adapter.summary_offset;
790         stw_p(&fib.data, data);
791     
792         if (pbdev->fh >> ENABLE_BIT_OFFSET) {

Does this code work as intended?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]