Skip to content

Comparison for strings is always false (changed) #43

Description

@ralphlange

When comparing old and new value (to decide if a change needs to be logged), the comparison for strings in the non-array case (where the value is actually a char[]) does not compare the strings, but their addresses and will always return false.

SINGLE_TYPE_COMPARE(string, MAX_STRING_SIZE);

with
#define SINGLE_TYPE_COMPARE(_t, _s) \
if (pLogData->is_array) \
return memcmp(pa->a_##_t, pb->a_##_t, size * _s) == 0; \
return pa->v_##_t == pb->v_##_t;

This is not serious, as it only leads to string puts always triggering a log, i.e. additional log messages.

There is no test that would catch the faulty behavior. (Tests only check that changing data triggers log messages. )

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsonJSON format logging

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions