From: Detlev Zundel Date: Fri, 16 Nov 2007 17:27:53 +0100 Subject: [U-Boot-Users] What if eth_init() fails? In-Reply-To: (Detlev Zundel's message of "Fri\, 16 Nov 2007 13\:29\:04 +0100") References: <13740586.post@talk.nabble.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, >> --- u-boot-1.2.0_orig/net/net.c 2007-01-07 04:43:11.000000000 +0530 >> +++ u-boot-1.2.0/net/net.c 2007-11-14 18:03:03.000000000 +0530 >> @@ -305,7 +305,7 @@ >> #ifdef CONFIG_NET_MULTI >> eth_set_current(); >> #endif >> - if (eth_init(bd) < 0) { >> + if (eth_init(bd) > 0) { >> eth_halt(); >> return(-1); >> } > > Secondly and more important, did you test this? I'd say your test is > the wrong way round, i.e. eth_init returns true in the C sense (!=0) > if it was able to initialize an interface. (This also chimes with the > naming of the function by the way). So I'd propose to go for > "!eth_init(..)". Thinking about this somemore, I am now convinced that the problem should not be fixed at the caller but in eth_init. Testing for <0 is a pretty idiomatic test for errors, so we should rather adjust eth_init to fit this idiom than spreading "aberrant" behaviour. Cheers Detlev -- Computers are useless. They can only give you answers. -- Pablo Picasso -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu@denx.de