.../PlatformVTdSampleDxe/PlatformVTdSampleDxe.c | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-)
In this sample driver, if (0) {...} else {...} statements were used to
illustrate two different using scenarios.
This comment refines the coding style by substituting the 'if (0)'
statement with comments to select sample codes for different cases.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
.../PlatformVTdSampleDxe/PlatformVTdSampleDxe.c | 38 ++++++++++++++--------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c
index 07499c7da8..3587fa3c83 100644
--- a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c
+++ b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c
@@ -339,23 +339,33 @@ PlatformVTdGetExceptionDeviceList (
return EFI_INVALID_PARAMETER;
}
- if (0) {
- *DeviceInfo = AllocateZeroPool (sizeof(mExceptionDeviceScopeList));
- if (*DeviceInfo == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (*DeviceInfo, mExceptionDeviceScopeList, sizeof(mExceptionDeviceScopeList));
+ //
+ // Sample codes for device scope based exception list.
+ // Uncomment to take affect and comment the sample codes for PCI vendor id
+ // based exception list.
+ //
+ /*
+ *DeviceInfo = AllocateZeroPool (sizeof(mExceptionDeviceScopeList));
+ if (*DeviceInfo == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (*DeviceInfo, mExceptionDeviceScopeList, sizeof(mExceptionDeviceScopeList));
- *DeviceInfoCount = ARRAY_SIZE(mExceptionDeviceScopeList);
- } else {
- *DeviceInfo = AllocateZeroPool (sizeof(mExceptionPciDeviceIdList));
- if (*DeviceInfo == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, sizeof(mExceptionPciDeviceIdList));
+ *DeviceInfoCount = ARRAY_SIZE(mExceptionDeviceScopeList);
+ */
- *DeviceInfoCount = ARRAY_SIZE(mExceptionPciDeviceIdList);
+ //
+ // Sample codes for PCI vendor id based exception list.
+ // Uncomment to take affect and comment the sample codes for device scope
+ // based exception list.
+ //
+ *DeviceInfo = AllocateZeroPool (sizeof(mExceptionPciDeviceIdList));
+ if (*DeviceInfo == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
+ CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, sizeof(mExceptionPciDeviceIdList));
+
+ *DeviceInfoCount = ARRAY_SIZE(mExceptionPciDeviceIdList);
return EFI_SUCCESS;
}
--
2.12.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Jiewen.yao@Intel.com > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, August 29, 2017 7:44 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [PATCH] IntelSiliconPkg/PlatformVTdSample: Avoid using constant result > 'if' > > In this sample driver, if (0) {...} else {...} statements were used to > illustrate two different using scenarios. > > This comment refines the coding style by substituting the 'if (0)' > statement with comments to select sample codes for different cases. > > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu <hao.a.wu@intel.com> > --- > .../PlatformVTdSampleDxe/PlatformVTdSampleDxe.c | 38 > ++++++++++++++-------- > 1 file changed, 24 insertions(+), 14 deletions(-) > > diff --git a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c > b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c > index 07499c7da8..3587fa3c83 100644 > --- a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c > +++ b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c > @@ -339,23 +339,33 @@ PlatformVTdGetExceptionDeviceList ( > return EFI_INVALID_PARAMETER; > } > > - if (0) { > - *DeviceInfo = AllocateZeroPool (sizeof(mExceptionDeviceScopeList)); > - if (*DeviceInfo == NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - CopyMem (*DeviceInfo, mExceptionDeviceScopeList, > sizeof(mExceptionDeviceScopeList)); > + // > + // Sample codes for device scope based exception list. > + // Uncomment to take affect and comment the sample codes for PCI vendor > id > + // based exception list. > + // > + /* > + *DeviceInfo = AllocateZeroPool (sizeof(mExceptionDeviceScopeList)); > + if (*DeviceInfo == NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + CopyMem (*DeviceInfo, mExceptionDeviceScopeList, > sizeof(mExceptionDeviceScopeList)); > > - *DeviceInfoCount = ARRAY_SIZE(mExceptionDeviceScopeList); > - } else { > - *DeviceInfo = AllocateZeroPool (sizeof(mExceptionPciDeviceIdList)); > - if (*DeviceInfo == NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, > sizeof(mExceptionPciDeviceIdList)); > + *DeviceInfoCount = ARRAY_SIZE(mExceptionDeviceScopeList); > + */ > > - *DeviceInfoCount = ARRAY_SIZE(mExceptionPciDeviceIdList); > + // > + // Sample codes for PCI vendor id based exception list. > + // Uncomment to take affect and comment the sample codes for device > scope > + // based exception list. > + // > + *DeviceInfo = AllocateZeroPool (sizeof(mExceptionPciDeviceIdList)); > + if (*DeviceInfo == NULL) { > + return EFI_OUT_OF_RESOURCES; > } > + CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, > sizeof(mExceptionPciDeviceIdList)); > + > + *DeviceInfoCount = ARRAY_SIZE(mExceptionPciDeviceIdList); > > return EFI_SUCCESS; > } > -- > 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.