[PATCH 2/4] efi_runtime: Refactor ioctl code into helper functions
Matt Fleming
matt at console-pimps.org
Fri Apr 4 07:52:49 UTC 2014
On Fri, 04 Apr, at 09:34:56AM, Borislav Petkov wrote:
>
> This #if thing is once here and also around
> efi_runtime_query_variableinfo(). Wouldn't it be cleaner to put inside
> the function?
>
> In this case, even for older kernels, the function will be there
> but return immediately, maybe even return an error code to say "not
> implemented/supported" or so...
Yeah, I see your point and I thought of doing that but I'm not a huge
fan of that style, which I'm assuming would look something like,
static long efi_get_foobar(unsigned long arg)
{
#if LINUX_KERNEL_VERSION > KERNEL_VERSION(3,1,0)
do_some_awesome_stuff();
#else
return -ENOTTY;
#endif
}
static long efi_get_raboof(unsigned long arg)
{
#if LINUX_KERNEL_VERSION > KERNEL_VERSION(3,1,0)
do_some_more_awesome_things();
#else
return -ENOTTY;
#endif
}
....
case EFI_GET_FOOBAR:
return efi_get_foobar(arg);
case EFI_GET_RABOOF:
return efi_get_raboof(arg);
....
However, if there were more lines of code in efi_runtime.c or the
implementation was split across multipe files I think that would be
stronger case for doing something like the above because there's a
higher risk of forgetting to keep the code in sync when making
modifications.
Having said that, I don't have a super strong opinion either way.
--
Matt Fleming, Intel Open Source Technology Center
More information about the fwts-devel
mailing list