Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] logic error with code hosted on your servers
- Date: Sun, 14 Mar 2004 11:32:42 -0800 (PST)
- From: Michael <mohr@example.com>
- Subject: Re: [tlug] logic error with code hosted on your servers
- References: <Pine.LNX.4.58.0403140148020.5297@example.com><20040314111944.5e5e7e45.tlug@example.com>
Okay, thanks for your corrections. I retried compiling the original code and it seems to work now. Strangely enough, the exact same code yesterday completely failed to work. It gave a nondescript error saying "Initialization failed" and refused to start up. I searched until I found this error status (there were 2 places) and after disabling the check the program would start. Strange that it works today. I'll replace the binary on my system, since I was quite obviously mistaken :) -Mike On Sun, 14 Mar 2004, Botond Botyanszki wrote: > On Sun, 14 Mar 2004 02:00:54 -0800 (PST) > mohr@example.com wrote: > > > if ((context = RkwInitialize( (char *)ddname )) < 0) > > > > As you can see, this comparison will always fail, > That's not true, you should review the C grammar. > > > causing the program to > > exit prematurely (giving an extremely nondescript error). This line > > should read: > > > > if ((context == RkwInitialize( (char *)ddname )) < 0) > While the RkInitialize function returns either 0 or -1 according to the > manage, RkwInitialize might return something more complex, otherwise using > a comparison against context wouldn't make much sense. And the above == is > a boolean comparison that is either TRUE or FALSE and there is no reason > you would want to use '<' to compare that value. > > Here is an example that will help you understand the scenario: > > int returns_zero() { > return 0; > } > int returns_one() { > return 1; > } > > int main (int argc, char **argv) { > int retval; > if ((retval = returns_zero()) == 0) printf("OK\n"); > if ((retval = returns_one()) == 1) printf("OK\n"); > if ((retval = returns_zero()) == 1) printf("NG\n"); > if ((retval = returns_one()) == 0) printf("NG\n"); > } > > > > Which will perform the comparison correctly and allow the server to run. > I'm not the author but I think the error is somewhere else. > > -- > TLUG server is hosted by Open Source Development Lab Japan > http://www.osdl.jp/ > > To unsubscribe from this mailing list, > please see the instructions at <http://www.tlug.jp/list.html> >
- Follow-Ups:
- [tlug] Top-Posting (was: logic error with code hosted on your servers)
- From: Josh Glover
- References:
- [tlug] logic error with code hosted on your servers
- From: mohr
- Re: [tlug] logic error with code hosted on your servers
- From: Botond Botyanszki
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] logic error with code hosted on your servers
- Next by Date: [tlug] Top-Posting (was: logic error with code hosted on your servers)
- Previous by thread: Re: [tlug] logic error with code hosted on your servers
- Next by thread: [tlug] Top-Posting (was: logic error with code hosted on your servers)
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links