Skip to contentSkip to conversation

efi: mark input variables to funcs as const

PATCH In review Doug Goldstein 2 participants 2 messages Dec 5, 2015 – Dec 7, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: mark input variables to funcs as const

Variables that are input (IN) variables to EFI functions should be marked as const. Just avoid potential problems of changing data that shouldn't be changed.

---

So I find myself constantly doing something similar to this when troubleshooting EFI because I like to put print statements to see data and figure out where problems are. The EFI print functions all take const data but much of the data is not marked as const. If you don't like this that's fine but I was looking at the 3 different EFI branches I have locally and this change is in all 3 in one shape or another.

---
 xen/include/efi/efidef.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/efi/efidef.h +1 -1
index 86a7e11..1d1c779 100644
@@ -50,7 +50,7 @@ typedef VOID            *EFI_EVENT;
 //
 
 #ifndef IN
-    #define IN
+    #define IN const
     #define OUT
     #define OPTIONAL
 #endif
Signature · 1 line
2.4.10
#1 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 05.12.15 at 21:25, <[email protected]> wrote:

Variables that are input (IN) variables to EFI functions should be marked as const. Just avoid potential problems of changing data that shouldn't be changed.

I don't think this is correct (there's no reason for a function to not use its input arguments as variables), and it certainly should come from upstream (i.e. UEFI -> gnu-efi -> Xen) if really meant to be done this way. Also I think if you want this for debugging purposes, overriding IN, OUT, and OPTIONAL in the source file(s) as intended by the surrounding #ifdef would be the way to go.

Jan