-
Notifications
You must be signed in to change notification settings - Fork 270
Description
Hi
I'm going through the code in order to educate myself on how these parsers work, and I think I've noticed some dead code in is_complete function:
picohttpparser/picohttpparser.c
Lines 221 to 223 in 81fe3d9
| *ret = -2; | |
| return NULL; | |
| } |
The while loop above can only terminate from:
CHECK_EOFin line 206:picohttpparser/picohttpparser.c
Lines 55 to 59 in 81fe3d9
#define CHECK_EOF() \ if (buf == buf_end) { \ *ret = -2; \ return NULL; \ } EXPECT_CHAR, one line below, in line 207:
picohttpparser/picohttpparser.c
Lines 61 to 69 in 81fe3d9
#define EXPECT_CHAR_NO_CHECK(ch) \ if (*buf++ != ch) { \ *ret = -1; \ return NULL; \ } #define EXPECT_CHAR(ch) \ CHECK_EOF(); \ EXPECT_CHAR_NO_CHECK(ch); - Return statement in line 217:
picohttpparser/picohttpparser.c
Line 217 in 81fe3d9
return buf;
Is this really unreachable or am I missing something? Is there a reason for this code to be there?
Also, given that EXPECT_CHAR already contains CHECK_EOF, and CHECK_EOF doesn't mutate any state, line 207 duplicates line 206, making the routine check for EOF twice in a row, when *buf == '<CR>'.