The usual reason for doing this, is so if the code is mistakenly written as
if(NULL = Ptr){
//Some code
}
It will be a compile error, rather than just a semantic error.
As ouah and Bo Persson point out, this is largely unnecessary, as modern compilers have reintegrated much of the semantic checking that historically was delegated to a separate lint
program.
gcc -Wall -Wextra
will tell you the line looks fishy:
test.c:3:2: warning: suggest parentheses around assignment used as truth value
I don't consider it semantically wrong as ouah does, comparison being commutative (even when implemented by subtraction and test for non-zero). But it does make the code less readable, if you intend to read it aloud, perhaps to a review group.
If NULL is-equal-to pointer then
Block comment (some code) end-Block
It reads funny this way. Whereas
If pointer is-equal-to NULL ...
is smoother to the ear.