edk2/MdeModulePkg/Include
Mike Maslenkin e07948255c MdeModulePkg: UsbNetwork: fix Ethernet functional descriptor processing
This patch fixes wrong condition because of UINT16 value to integer
promotion. NumberMcFilters is UINT16 value, so when bitwise shift operator
applied to small integer type, the operation is preceded by integral
promotion. This is described in MISRA-C:2004 guideline as Rule 10.5:
"If the bitwise operators ~ and << are applied to an operand of underlying
type unsigned char or unsigned short, the result shall be immediately cast
to the underlying type of the operand."

A simple fix for this issue would be the following:
  if ((UINT16)(UsbEthFunDescriptor.NumberMcFilters << 1) == 0)

But this patch proposes to use bitwise AND operation with a proper bit mask
rather than shifting to prevent similar mistakes in future.

Cc: Richard Ho <richardho@ami.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2023-10-16 22:49:33 +00:00
..
Guid MdeModulePkg/Rng: Add GUID to describe unsafe Rng algorithms 2023-09-08 09:48:55 +00:00
Library MdeModulePkg/Include: Add IpmiCommandLib header file 2023-01-19 03:57:32 +00:00
Pi MdeModulePkg: Correct memory type in PrePiDxeCis.h 2023-01-30 13:52:27 +00:00
Ppi MdeModulePkg: Define memory attribute PPI 2023-06-26 09:11:53 +00:00
Protocol MdeModulePkg: UsbNetwork: fix Ethernet functional descriptor processing 2023-10-16 22:49:33 +00:00
UniversalPayload MdeModulePkg/UniversalPayload: Align Identifier value with UPL spec 2022-05-27 16:15:26 +00:00