Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: e07948255cfafb75fa9cbe4555bfe3421488dd9a
      
https://github.com/tianocore/edk2/commit/e07948255cfafb75fa9cbe4555bfe3421488dd9a
  Author: Mike Maslenkin <[email protected]>
  Date:   2023-10-16 (Mon, 16 Oct 2023)

  Changed paths:
    M MdeModulePkg/Bus/Usb/UsbNetwork/NetworkCommon/PxeFunction.c
    M MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c
    M MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c
    M MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c
    M MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h

  Log Message:
  -----------
  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 <[email protected]>
Cc: Rebecca Cran <[email protected]>
Signed-off-by: Mike Maslenkin <[email protected]>


  Commit: 03d6569f70939d2a1653265367121212459a6b89
      
https://github.com/tianocore/edk2/commit/03d6569f70939d2a1653265367121212459a6b89
  Author: Mike Maslenkin <[email protected]>
  Date:   2023-10-16 (Mon, 16 Oct 2023)

  Changed paths:
    M MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c
    M MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h

  Log Message:
  -----------
  MdeModulePkg: UsbRndis: get rid of magic values

Replace magic values used for checking Base Class, SubClass and Protocol
fields of USB Interface Descriptor.
Add definitions for Base Class EFh (Miscellaneous) and RNDIS subclass.
These definitions were taken from https://www.usb.org/defined-class-codes

Cc: Richard Ho <[email protected]>
Cc: Rebecca Cran <[email protected]>
Signed-off-by: Mike Maslenkin <[email protected]>


Compare: https://github.com/tianocore/edk2/compare/326b9e1d815c...03d6569f7093


_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to