Re: [PATCH v3 2/2] fsck.c: Rewrite fsck_commit() to use skip_prefix()

2014-03-13 Thread Junio C Hamano
Junio C Hamano writes: >> -if (memcmp(buffer, "tree ", 5)) >> +buffer = skip_prefix(buffer, "tree "); >> +if (buffer == NULL) > > We encourage people to write this as: > > if (!buffer) > > The same comment applies to other new lines in this patch. I also see a lot of repetition

Re: [PATCH v3 2/2] fsck.c: Rewrite fsck_commit() to use skip_prefix()

2014-03-13 Thread Junio C Hamano
Yuxuan Shui writes: > Currently we use memcmp() in fsck_commit() to check if buffer start > with a certain prefix, and skip the prefix if it does. This is exactly > what skip_prefix() does. And since skip_prefix() has a self-explaintory > name, this could make the code more readable. > > Signed-o

[PATCH v3 2/2] fsck.c: Rewrite fsck_commit() to use skip_prefix()

2014-03-12 Thread Yuxuan Shui
Currently we use memcmp() in fsck_commit() to check if buffer start with a certain prefix, and skip the prefix if it does. This is exactly what skip_prefix() does. And since skip_prefix() has a self-explaintory name, this could make the code more readable. Signed-off-by: Yuxuan Shui --- fsck.c |