Messages in this thread | | | Date | Thu, 06 May 1999 11:04:12 +0200 | From | Martin Tessun <> | Subject | Re: fork() Problem? |
| |
> Lint _clearly_ states that it's an error.
Lint can't say it's an Error. Read K&R and you find out it's perfectly right. How else could expresiions like this work in C:
a=b=c=0 ??
If c=0 returns tru because the assignment worked (like in Pascal e.g.) then b would be 1 So you would have instead:
a=1 b=1 c=0
But in "reality you get:
a=0 b=0 c=0
And if you read K&R then you see that the code
if (i=fork()) { /* Do something */ } else { /* Do something */ } is perfectly right C.
If you don't need the return-value anymore you can also write:
if (fork()) { /* Do something */ } else { /* Do something */ }
This is perfect standard C as well.
The difference between the two statements is that i got assigned the return-value of fork an the result of this assignment is the right side of the =-assignment so this means the return-value of fork. So you see the can be every value you like.
If you don't believe it, I assume you begin learning C. There is a damn good book written by K&R. (I hope you know K&R the developer of the C-programming-language).
> Further, previous text states why. Any time I point out these things > I get a bunch of fanatical "tool gurus" responding that I don't > know what I'm talking about.
No the answers aren't fanatical. Perhaps you should learn the basics before you build up such a mind which IS definatly wrong. You could even learn from the answers you get instead of saying "These idiots don't know what they are speaking about. I know everything so they can't be right. I am God!!!"
Think about it.
> The 'C' language is just a tool. It is not a religion. It is also > not a means unto itself. In the "real world", I don't give a damn > about what you can get away with while using such a tool.
Yes, but you have to know the standards, what is allowed and what not. You can't write Pascal-Code and hope the C-Compiler gets it right.
> I'll bet a dollar that there are few that have even seen Commercial > Software that was reviewed by the FDA or DOD. If you want to pass > the muster, take a lesson.
Well you can believe me that I have seen many commercial C-Compilers and ALL work that way, because it's STANDARD-C-BEHAVIOUR.
> The ONLY reason why the 'C' Language is now allowed instead of ADA > in Government end-user applications is because of persons like me > who specified and signed up to some minimum standards. These standards > say nothing about style, but make damn certain that the compiler(s) > to be used generate the code specified. This means that some sloppy > constructs are simply not allowed.
Read the standard from K&R (this is really the minimum ALL C-Compilers know about).
> That said, the problem with: > > if(a=b) > > is that the value of a is not tested. 'a' got assigned the value of > 'b', but only the assignment was tested, not the resulting value.
Right, but the assignment returns the RHS-value so the value of b.
> This, as I explained over and over again, is called a > "boolean test of assignment error". It is a real error because, > unless the machine crashed, it is always TRUE. This is what > Lint is complaining about. One needs to test the result. You > can do this by adding a sequence-point.
Clearly wrong. Read my mail.
Bye Martin
P.S.: I said nothing till now, because I thought you will learn the right way. So I will say nothing more after this. If you can't write C leave it.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |