Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Read errors
From: Mike Holden (rockbox_at_mikeholden.uklinux.net)
Date: 2003-03-13


Björn Stenberg said:
> Mike Holden wrote:
>> We sometimes return 0 for success,
>> sometimes for error, but often use "if (somefunction())" type
>> constructs, which can be misleading, since the value being tested may
>> not follow the usual tradition of 0=true, anything else=false.
>
> Maybe because it's actually the opposite. 0 == false, anything else ==
> true. :-)

Yes, that's what I meant! Read that comment in conjunction with what I was
saying - I've got 0 and 1 blindness after studying that code! What I was
trying to say is that sometimes 0 = success, sometimes 0 = failure
(false).

Maybe a better construct would be to define 2 macros, called success() and
failure() which do a bit of hidden "magic" to make the code more readable.
That way you can write "if (success(somefunction()))", which is way more
readable than "if(somefunction())" where somefunction() returns 0 for
success.

>
> But I think you may indeed have found something. 'ret' should be
> initialized at the top of the loop, not at the bottom.

I'll compile this tonight and report back, after I've been for a long walk!

-- 
Mike Holden



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa