On 26.06.2021 17:36, Rroach wrote:
> Hi, when I look the source code in Xen-4.15 source code, I found a type 
> mismatch.
> 
> 
> In detailed, in xen/arch/x86/msi.c:find_msi_entry, there is a comparison 
> between entry->msi_attrib.type and cap_id. However, according to the 
> definition, the type appears to be __u8, where is a char variable, and the 
> cap_id is defined as int variable, hence it seems to be.a type mismatch.

unsigned char, uint8_t, and alike promote to int when used in an
expression. All callers pass values known to fit in 8 bits. Plus
the hardware field where the ID is coming from is also an 8-bit
one. So while I would welcome a change of the function parameters
from plain int to unsigned int, changing them to uint<NN>_t would
actually make the code worse imo, not the least because of it
then violating ./CODING_STYLE (section "Types"). And using a type
wider than what's needed to hold any valid values in a structure
with perhaps many instances is not a good use of resources.

> Despite this error do not affect system operation by far, it still affect the 
> code's quality, as such error could result in potential bugs in the future.

In this case I'm having a hard time seeing any such happen, for
the reasons above.

Jan


Reply via email to