efi: mark input variables to funcs as const
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
@@ -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
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