* [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
[not found] <CGME20170615103911epcas1p2300931e1dc457870558520c69015f0d2@epcas1p2.samsung.com>
@ 2017-06-15 10:40 ` Amit Kumar
2017-06-15 17:17 ` Kinney, Michael D
0 siblings, 1 reply; 2+ messages in thread
From: Amit Kumar @ 2017-06-15 10:40 UTC (permalink / raw)
To: edk2-devel; +Cc: feng.tian, akamit9, Amit Kumar
Change since v1:
1) Fixed typo protocal to protocol
2) Fixed coding style
Modified source code to update Interface as per spec.
1) In case of Protocol is un-supported, interface should be returned NULL.
2) In case of any error, interface should not be modified.
3) In case of Test Protocol, interface is optional.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Amit Kumar <amit.ak@samsung.com>
---
MdeModulePkg/Core/Dxe/Hand/Handle.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index 1c25521..db23170 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -1004,12 +1004,8 @@ CoreOpenProtocol (
//
// Check for invalid Interface
//
- if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
- if (Interface == NULL) {
- return EFI_INVALID_PARAMETER;
- } else {
- *Interface = NULL;
- }
+ if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == NULL)) {
+ return EFI_INVALID_PARAMETER;
}
//
@@ -1073,15 +1069,11 @@ CoreOpenProtocol (
Prot = CoreGetProtocolInterface (UserHandle, Protocol);
if (Prot == NULL) {
Status = EFI_UNSUPPORTED;
+ // Return NULL Interface if Unsupported Protocol
+ *Interface = NULL;
goto Done;
}
- //
- // This is the protocol interface entry for this protocol
- //
- if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
- *Interface = Prot->Interface;
- }
Status = EFI_SUCCESS;
ByDriver = FALSE;
@@ -1175,6 +1167,15 @@ CoreOpenProtocol (
}
Done:
+
+ //
+ // This is the protocol interface entry for this protocol.
+ // In case of any Error, Interface should not be updated as per spec.
+ //
+ if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL)
+ && (Status == EFI_SUCCESS)) {
+ *Interface = Prot->Interface;
+ }
//
// Done. Release the database lock are return
//
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
2017-06-15 10:40 ` [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol Amit Kumar
@ 2017-06-15 17:17 ` Kinney, Michael D
0 siblings, 0 replies; 2+ messages in thread
From: Kinney, Michael D @ 2017-06-15 17:17 UTC (permalink / raw)
To: Amit Kumar, edk2-devel@lists.01.org, Kinney, Michael D
Cc: akamit9@hotmail.com, Tian, Feng
Hi Kumar,
One other minor comment.
+ //
+ // This is the protocol interface entry for this protocol.
+ // In case of any Error, Interface should not be updated as per spec.
+ //
+ if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL)
+ && (Status == EFI_SUCCESS)) {
+ *Interface = Prot->Interface;
+ }
I think it is better to use the EFI_ERROR() macro here instead of
direct compare against a specific status code value.
//
// This is the protocol interface entry for this protocol.
// Only update *Interface if the protocol was found and the request
// is not the test to see if the protocol is present.
//
if (!EFI_ERROR (Status) && Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
*Interface = Prot->Interface;
}
Mike
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Amit Kumar
Sent: Thursday, June 15, 2017 3:40 AM
To: edk2-devel@lists.01.org
Cc: akamit9@hotmail.com; Tian, Feng <feng.tian@intel.com>
Subject: [edk2] [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
Change since v1:
1) Fixed typo protocal to protocol
2) Fixed coding style
Modified source code to update Interface as per spec.
1) In case of Protocol is un-supported, interface should be returned NULL.
2) In case of any error, interface should not be modified.
3) In case of Test Protocol, interface is optional.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Amit Kumar <amit.ak@samsung.com>
---
MdeModulePkg/Core/Dxe/Hand/Handle.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index 1c25521..db23170 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -1004,12 +1004,8 @@ CoreOpenProtocol (
//
// Check for invalid Interface
//
- if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
- if (Interface == NULL) {
- return EFI_INVALID_PARAMETER;
- } else {
- *Interface = NULL;
- }
+ if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == NULL)) {
+ return EFI_INVALID_PARAMETER;
}
//
@@ -1073,15 +1069,11 @@ CoreOpenProtocol (
Prot = CoreGetProtocolInterface (UserHandle, Protocol);
if (Prot == NULL) {
Status = EFI_UNSUPPORTED;
+ // Return NULL Interface if Unsupported Protocol
+ *Interface = NULL;
goto Done;
}
- //
- // This is the protocol interface entry for this protocol
- //
- if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
- *Interface = Prot->Interface;
- }
Status = EFI_SUCCESS;
ByDriver = FALSE;
@@ -1175,6 +1167,15 @@ CoreOpenProtocol (
}
Done:
+
+ //
+ // This is the protocol interface entry for this protocol.
+ // In case of any Error, Interface should not be updated as per spec.
+ //
+ if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL)
+ && (Status == EFI_SUCCESS)) {
+ *Interface = Prot->Interface;
+ } //
// Done. Release the database lock are return
//
--
1.9.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-15 17:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20170615103911epcas1p2300931e1dc457870558520c69015f0d2@epcas1p2.samsung.com>
2017-06-15 10:40 ` [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol Amit Kumar
2017-06-15 17:17 ` Kinney, Michael D
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox