In the spirit of the last two changes: Switch on length and use constcmp for parsing headers with restricted values. Signed-off-by: David Barr <david.barr@xxxxxxxxxxxx> Reviewed-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- vcs-svn/svndump.c | 40 ++++++++++++++++++++++++++++++---------- 1 files changed, 30 insertions(+), 10 deletions(-) diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 3ad48e5..7b5b5ec 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -343,25 +343,45 @@ void svndump_read(const char *url) } if (constcmp(t + strlen("Node-"), "kind")) continue; - if (!strcmp(val, "dir")) + switch (strlen(val) + 1) { + case sizeof("dir"): + if (constcmp(val, "dir")) + break; node_ctx.type = REPO_MODE_DIR; - else if (!strcmp(val, "file")) + break; + case sizeof("file"): + if (constcmp(val, "file")) + break; node_ctx.type = REPO_MODE_BLB; - else + break; + default: fprintf(stderr, "Unknown node-kind: %s\n", val); + } break; case sizeof("Node-action"): if (constcmp(t, "Node-action")) continue; - if (!strcmp(val, "delete")) { - node_ctx.action = NODEACT_DELETE; - } else if (!strcmp(val, "add")) { + switch (strlen(val) + 1) { + case sizeof("add"): + if (constcmp(val, "add")) + break; node_ctx.action = NODEACT_ADD; - } else if (!strcmp(val, "change")) { - node_ctx.action = NODEACT_CHANGE; - } else if (!strcmp(val, "replace")) { + break; + case sizeof("change"): + if (!constcmp(val, "change")) { + node_ctx.action = NODEACT_CHANGE; + break; + } + if (constcmp(val, "delete")) + break; + node_ctx.action = NODEACT_DELETE; + break; + case sizeof("replace"): + if (constcmp(val, "replace")) + break; node_ctx.action = NODEACT_REPLACE; - } else { + break; + default: fprintf(stderr, "Unknown node-action: %s\n", val); node_ctx.action = NODEACT_UNKNOWN; } -- 1.7.3.2.846.gf4b062 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html