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:19:44 +0000
- From: Botond Botyanszki <tlug@example.com>
- Subject: Re: [tlug] logic error with code hosted on your servers
- References: <Pine.LNX.4.58.0403140148020.5297@example.com>
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.
- Follow-Ups:
- Re: [tlug] logic error with code hosted on your servers
- From: Michael
- References:
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] video installation trouble
- Next by Date: Re: [tlug] logic error with code hosted on your servers
- Previous by thread: Re: [tlug] logic error with code hosted on your servers
- Next by thread: Re: [tlug] logic error with code hosted on your servers
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links