Saturday, January 19, 2008

Seriously?

I have been perusing the chntpw code tonight because I would like to start a small GUI for it in C# (or standalone would be best). It isn't very pretty code. At all. Take using #if 0 #endif to keep a block of code from executing rather than just commenting it out. A) That is more typing than just commenting it out and B) it creates unnecessary byte-code. This is used 16 times in ntreg.c. I understand the debugging purposes behind this _before_ releasing the final source, but this is a final release.

Also, they original author doesn't like spaces or common sense.

int dirty=0,to,from,l,i,j,wlen,cofs = 0;

He declares dirty and gives it a value of zero, then declares 7 more ints and gives them a value of zero.

int dirty, to, from, l, i, j, wlen, cofs = 0;

Whitespace in C doesn't matter, so make you stuff easier to read please?

I know this is just a preferences thing, but when he had only one line following an if/for/while loop, he just put the following line of code on the same line:


int find_in_buf(char *buf, char *what, int sz, int len, int start)
{
int i;

for (; start < sz; start++) {
for (i = 0; i < len; i++) {
if (*(buf+start+i) != *(what+i)) break;
}
if (i == len) return(start);
}
return(0);
}


Don't do this, it is bad for your health.

No comments:

Post a Comment