lkml.org 
[lkml]   [2022]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v7 5/8] x86/e820: Refactor e820__range_remove
From
On 4/26/22 10:37, Martin Fernandez wrote:
>> Also, in general, the naming is a bit verbose. You might want to trim
>> some of those names down, like:
>>
>>> +static bool __init crypto_updater__should_update(const struct e820_entry
>>> *entry,
>>> + const void *data)
>>> +{
>>> + const struct e820_crypto_updater_data *crypto_updater_data =
>>> + (const struct e820_crypto_updater_data *)data;
> Yes I agree on this. Do you have any suggestions for these kind of
> functions? I want to explicitly state that these functions are in some of
> namespace and are different of the other ones.
>
> In the end I don't think this is very harmful since these functions are one-time
> used (in a single place), is not the case that you have to use them everywhere..

Let's just start with the fact that this is a pointer to a structure
containing an enum that represents a single bit. You could just pass
around an address to a bool:

bool crypto_capable = *(bool *)data;

or even just pass and use the 'void *data' pointer as a value directly:

bool crypto_capable = (bool)data;

That, for one, would get rid of some of the naming craziness.

If it were me, and I *really* wanted to keep the full types, I would
have just condensed that line down to:

struct e820_crypto_updater_data *crypto_data = data;

Yeah, it _can_ be const, but it buys you practically nothing in this
case and only hurts readability.

\
 
 \ /
  Last update: 2022-04-26 19:53    [W:0.485 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site