Commit 85ede33a authored by Rosen Penev's avatar Rosen Penev Committed by Nikias Bassen

Improve code readability by using explicit != 0 compare when using strncmp

[clang-tidy] Found with bugprone-suspicious-string-compare
Signed-off-by: 's avatarRosen Penev <rosenp@gmail.com>
parent 9f60cdd7
...@@ -749,7 +749,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le ...@@ -749,7 +749,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le
} }
} while (1); } while (1);
ctx->pos++; ctx->pos++;
if (ctx->pos >= ctx->end-tag_len || strncmp(ctx->pos, tag, tag_len)) { if (ctx->pos >= ctx->end-tag_len || strncmp(ctx->pos, tag, tag_len) != 0) {
PLIST_XML_ERR("EOF or end tag mismatch\n"); PLIST_XML_ERR("EOF or end tag mismatch\n");
ctx->err++; ctx->err++;
return NULL; return NULL;
...@@ -965,7 +965,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist) ...@@ -965,7 +965,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
ctx->err++; ctx->err++;
goto err_out; goto err_out;
} }
if (strncmp(ctx->pos, "?>", 2)) { if (strncmp(ctx->pos, "?>", 2) != 0) {
PLIST_XML_ERR("Couldn't find <? tag closing marker\n"); PLIST_XML_ERR("Couldn't find <? tag closing marker\n");
ctx->err++; ctx->err++;
goto err_out; goto err_out;
...@@ -977,7 +977,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist) ...@@ -977,7 +977,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
if (((ctx->end - ctx->pos) > 3) && !strncmp(ctx->pos, "!--", 3)) { if (((ctx->end - ctx->pos) > 3) && !strncmp(ctx->pos, "!--", 3)) {
ctx->pos += 3; ctx->pos += 3;
find_str(ctx,"-->", 3, 0); find_str(ctx,"-->", 3, 0);
if (ctx->pos > ctx->end-3 || strncmp(ctx->pos, "-->", 3)) { if (ctx->pos > ctx->end-3 || strncmp(ctx->pos, "-->", 3) != 0) {
PLIST_XML_ERR("Couldn't find end of comment\n"); PLIST_XML_ERR("Couldn't find end of comment\n");
ctx->err++; ctx->err++;
goto err_out; goto err_out;
...@@ -1006,7 +1006,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist) ...@@ -1006,7 +1006,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
} }
if (embedded_dtd) { if (embedded_dtd) {
find_str(ctx, "]>", 2, 1); find_str(ctx, "]>", 2, 1);
if (ctx->pos > ctx->end-2 || strncmp(ctx->pos, "]>", 2)) { if (ctx->pos > ctx->end-2 || strncmp(ctx->pos, "]>", 2) != 0) {
PLIST_XML_ERR("Couldn't find end of DOCTYPE\n"); PLIST_XML_ERR("Couldn't find end of DOCTYPE\n");
ctx->err++; ctx->err++;
goto err_out; goto err_out;
......
...@@ -274,7 +274,7 @@ int main(int argc, char *argv[]) ...@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
if (plist_out) if (plist_out)
{ {
if (options->out_file != NULL && strcmp(options->out_file, "-")) if (options->out_file != NULL && strcmp(options->out_file, "-") != 0)
{ {
FILE *oplist = fopen(options->out_file, "wb"); FILE *oplist = fopen(options->out_file, "wb");
if (!oplist) { if (!oplist) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment