2 style questions
From: Sander (i_at_bleat.nospam.com)
Date: 12/21/03
- Next message: Ben Pfaff: "Re: 2 style questions"
- Previous message: glen herrmannsfeldt: "Re: Hidden read of indeterminate memory"
- Next in thread: Ben Pfaff: "Re: 2 style questions"
- Reply: Ben Pfaff: "Re: 2 style questions"
- Reply: Richard Heathfield: "Re: 2 style questions"
- Reply: Wolfgang Kaufmann: "Re: 2 style questions"
- Reply: Mark McIntyre: "Re: 2 style questions"
- Reply: Malcolm: "Re: 2 style questions"
- Reply: CBFalconer: "Re: 2 style questions"
- Reply: The Real OS/2 Guy: "Re: 2 style questions"
- Reply: Jens Prüfer: "Re: 2 style questions"
- Reply: Mac: "Re: 2 style questions"
- Reply: Martin Ambuhl: "Re: 2 style questions"
- Reply: Kevin Goodsell: "Re: 2 style questions"
- Reply: Paul Hsieh: "Re: 2 style questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 21 Dec 2003 08:48:45 +0100
1.
I was having a discussion with somebody and I think it's just religious.
We are developing some software and he was looking through my code.
I use if (pointer) to test a pointer for NULL. He says it must be if
(p!=NULL).
The arguments are that it's more readable and that if (p) is not portable.
I said the first is a style issue and that I think if(p) is more readable
and that the second is plain wrong.
So, is he right about the portability issue? is if (p) not strictly correct
C code?
2.
Then I started looking through his code and what I noticed that he very
often does things like this:
char *func(char **out)
{
*out = malloc(100);
return malloc(10);
}
This might also be a style issue, but it's a style where it's very easy to
introduce bugs (and indeed I found a few)
and even more easy to introduce bugs if you don't know the internals of the
function. So, what do you think about this style?
- Next message: Ben Pfaff: "Re: 2 style questions"
- Previous message: glen herrmannsfeldt: "Re: Hidden read of indeterminate memory"
- Next in thread: Ben Pfaff: "Re: 2 style questions"
- Reply: Ben Pfaff: "Re: 2 style questions"
- Reply: Richard Heathfield: "Re: 2 style questions"
- Reply: Wolfgang Kaufmann: "Re: 2 style questions"
- Reply: Mark McIntyre: "Re: 2 style questions"
- Reply: Malcolm: "Re: 2 style questions"
- Reply: CBFalconer: "Re: 2 style questions"
- Reply: The Real OS/2 Guy: "Re: 2 style questions"
- Reply: Jens Prüfer: "Re: 2 style questions"
- Reply: Mac: "Re: 2 style questions"
- Reply: Martin Ambuhl: "Re: 2 style questions"
- Reply: Kevin Goodsell: "Re: 2 style questions"
- Reply: Paul Hsieh: "Re: 2 style questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|