diff options
author | Mike Maslenkin <mike.maslenkin@gmail.com> | 2023-08-26 04:57:59 +0300 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-10-16 22:49:33 +0000 |
commit | e07948255cfafb75fa9cbe4555bfe3421488dd9a (patch) | |
tree | 0d99fec699fdc184399453839f4de0514f6307f6 /MdeModulePkg/Include | |
parent | 326b9e1d815c4ae4b0b207fcb0bfa16864af5400 (diff) | |
download | edk2-e07948255cfafb75fa9cbe4555bfe3421488dd9a.zip edk2-e07948255cfafb75fa9cbe4555bfe3421488dd9a.tar.gz edk2-e07948255cfafb75fa9cbe4555bfe3421488dd9a.tar.bz2 |
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>
Diffstat (limited to 'MdeModulePkg/Include')
-rw-r--r-- | MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h b/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h index 800945d..7b9896a 100644 --- a/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h +++ b/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h @@ -42,6 +42,8 @@ typedef struct _EDKII_USB_ETHERNET_PROTOCOL EDKII_USB_ETHERNET_PROTOCOL; #define NETWORK_CONNECTED 0x01
#define NETWORK_DISCONNECT 0x00
+#define MAC_FILTERS_MASK 0x7FFF
+
// USB Header functional Descriptor
typedef struct {
UINT8 FunctionLength;
|