Skip to contentSkip to conversation

is_err checking

DISCUSSION Julia Lawall 2 participants 3 messages Jul 23, 2016 – Jul 24, 2016 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Code like the following looks a bit clunky to me:

if (IS_ERR(data->clk) && PTR_ERR(data->clk) != -EPROBE_DEFER)

Is there any reason not to always use eg

data->clk = ERR_PTR(-EPROBE_DEFER)

Code of the latter form is a bit more popular. Perhaps one could want something like:

IS_ERR_VALUE(data->clk, -EPROBE_DEFER)

but IS_ERR_VALUE is laready used for something else.

julia

#1 lore raw

Am 23.07.2016 16:56, schrieb Julia Lawall:

Quoted 6 lines

Code like the following looks a bit clunky to me:

if (IS_ERR(data->clk) && PTR_ERR(data->clk) != -EPROBE_DEFER)

Is there any reason not to always use eg

Quoted 9 lines

data->clk = ERR_PTR(-EPROBE_DEFER)

Code of the latter form is a bit more popular. Perhaps one could want something like:

IS_ERR_VALUE(data->clk, -EPROBE_DEFER)

but IS_ERR_VALUE is laready used for something else.

note: i do not like hiding behind #defines

did you actually see code like IS_ERR_VALUE(data->clk, -EPROBE_DEFER) in the current kernel ?
because there is no second argument:

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

or is this a misunderstanding ?

re,
wh

Quoted 6 lines

julia
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 16 lines · walter harms

Am 23.07.2016 16:56, schrieb Julia Lawall:

Quoted 13 lines

Code like the following looks a bit clunky to me:

if (IS_ERR(data->clk) && PTR_ERR(data->clk) != -EPROBE_DEFER)

Is there any reason not to always use eg

data->clk = ERR_PTR(-EPROBE_DEFER)

Code of the latter form is a bit more popular. Perhaps one could want something like:

IS_ERR_VALUE(data->clk, -EPROBE_DEFER)

Quoted 7 lines
Quoted 2 lines

but IS_ERR_VALUE is laready used for something else.

note: i do not like hiding behind #defines

did you actually see code like IS_ERR_VALUE(data->clk, -EPROBE_DEFER) in the current kernel ?

No, no. It's the combination of English words I thought would be useful for expressing the concept. But it's already used for something else.

julia

Quoted 16 lines

because there is no second argument:

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

or is this a misunderstanding ?

re,
wh

Quoted 6 lines

julia
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html