lkml.org 
[lkml]   [2011]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] arch/arm/mach-at91/clock.c: Add missing IS_ERR test


Am 25.01.2011 11:43, schrieb Russell King - ARM Linux:
> On Tue, Jan 25, 2011 at 11:33:16AM +0100, walter harms wrote:
>> Would it be more easy to return NULL in the error case of clk_get() instead
>> of ERR_PTR(-ENOENT) ?
>>
>> So the default could be return NULL and an architecture depending solution
>> replacing that.
>
> That's not how the API is defined. The API defines error-pointers to be
> errors, everything should be considered valid. Please don't go down the
> route of doing something architecturally different from that.
>
> What if, say, you couldn't return the struct clk because maybe it could
> only be controlled by one user? Returning an EBUSY error pointer would
> indicate this condition. What if the module providing the struct clk
> hasn't finished initializing - that's another reason for EBUSY rather
> than ENOENT.
>
> Error codes are useful to describe why something failed. NULL pointers
> can't do that.
>

On Mon, 24 Jan 2011, Vasiliy Kulikov wrote:
>
...
> clk_get() is defined per-architecture, sometimes it is NULL only.
>

So these is a bug ? They should return -ENOENT ?

The interessting question is: what to do with an error ?

Obviously some architecture can live with NULL, so it is not an critical
error. An the patch shows a code that is simply a return, not even the
user is informed that something did not work as expected.

From that point of view i would like question if it is useful to have
a "detailed" error instead of just returning NULL.

just my 2 cents,
re,
wh


\
 
 \ /
  Last update: 2011-01-25 12:21    [W:0.054 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site