Skip to content

Commit 73867d4

Browse files
committed
Use oscap_streq instead of oscap_strcmp
We are interested in checking if the strings are equal or not equal. We are not interested in lexicographical comparison of the strings. We should use type compatible functions because calling incompatible functions is undefined behavior in C. Addressing: /home/jcerny/openscap/src/XCCDF/resolve.c: In function ‘xccdf_resolve_group’: /home/jcerny/openscap/src/XCCDF/resolve.c:289:85: warning: cast between incompatible function types from ‘int (*)(const char *, const char *)’ to ‘_Bool (*)(void *, void *)’ [-Wcast-function-type] 289 | xccdf_resolve_appendlist(&child->sub.group.conflicts, parent->sub.group.conflicts, (oscap_cmp_func)oscap_strcmp, (oscap_clone_func)oscap_strdup, false); | ^ /home/jcerny/openscap/src/XCCDF/resolve.c: In function ‘xccdf_resolve_rule’: /home/jcerny/openscap/src/XCCDF/resolve.c:317:83: warning: cast between incompatible function types from ‘int (*)(const char *, const char *)’ to ‘_Bool (*)(void *, void *)’ [-Wcast-function-type] 317 | xccdf_resolve_appendlist(&child->sub.rule.conflicts, parent->sub.rule.conflicts, (oscap_cmp_func)oscap_strcmp, (oscap_clone_func)oscap_strdup, false); |
1 parent 872f41c commit 73867d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/XCCDF/resolve.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static void xccdf_resolve_group(struct xccdf_item *child, struct xccdf_item *par
286286
{
287287
// TODO: resolve requires properly (how?)
288288
//xccdf_resolve_appendlist(&child->sub.group.requires, parent->sub.group.requires, xccdf_incomparable, xccdf_strlist_clone, false);
289-
xccdf_resolve_appendlist(&child->sub.group.conflicts, parent->sub.group.conflicts, (oscap_cmp_func)oscap_strcmp, (oscap_clone_func)oscap_strdup, false);
289+
xccdf_resolve_appendlist(&child->sub.group.conflicts, parent->sub.group.conflicts, (oscap_cmp_func)oscap_streq, (oscap_clone_func)oscap_strdup, false);
290290

291291
OSCAP_FOR(xccdf_item, item, xccdf_group_get_content(XGROUP(parent)))
292292
xccdf_group_add_content(XGROUP(child), xccdf_resolve_copy_item(item));
@@ -314,7 +314,7 @@ static void xccdf_resolve_rule(struct xccdf_item *child, struct xccdf_item *pare
314314
{
315315
// TODO: resolve requires properly (how?)
316316
//xccdf_resolve_appendlist(&child->sub.rule.requires, parent->sub.rule.requires, xccdf_incomparable, xccdf_strlist_clone);
317-
xccdf_resolve_appendlist(&child->sub.rule.conflicts, parent->sub.rule.conflicts, (oscap_cmp_func)oscap_strcmp, (oscap_clone_func)oscap_strdup, false);
317+
xccdf_resolve_appendlist(&child->sub.rule.conflicts, parent->sub.rule.conflicts, (oscap_cmp_func)oscap_streq, (oscap_clone_func)oscap_strdup, false);
318318
xccdf_resolve_appendlist(&child->sub.rule.idents, parent->sub.rule.idents, (oscap_cmp_func)xccdf_ident_idcmp, (oscap_clone_func)xccdf_ident_clone, false);
319319
xccdf_resolve_appendlist(&child->sub.rule.fixes, parent->sub.rule.fixes, (oscap_cmp_func)xccdf_incomparable, (oscap_clone_func)xccdf_fix_clone, false);
320320

0 commit comments

Comments
 (0)