Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when loading both gnu.cfg and bsd.cfg #5956

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cfg/gnu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@
<not-null/>
</arg>
</function>
<!-- int timercmp(struct timeval *a, struct timeval *b, CMP)-->
<define name="timercmp(a,b,CMP)" value="(((a)-&gt;tv_sec == (b)-&gt;tv_sec) ? ((a)-&gt;tv_usec CMP (b)-&gt;tv_usec) : ((a)-&gt;tv_sec CMP (b)-&gt;tv_sec))"/>
<!-- int __builtin_types_compatible_p (type1, type2) -->
<function name="__builtin_types_compatible_p">
<noreturn>false</noreturn>
Expand Down
32 changes: 0 additions & 32 deletions test/cfg/gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,38 +183,6 @@ int uninitvar_getpw(uid_t uid, char *buf)
return getpw(someUid, buf);
}

// #9323, #9331
void syntaxError_timercmp(struct timeval t)
{
(void)timercmp(&t, &t, <);
(void)timercmp(&t, &t, <=);
(void)timercmp(&t, &t, ==);
(void)timercmp(&t, &t, !=);
(void)timercmp(&t, &t, >=);
(void)timercmp(&t, &t, >);
}

// False negative: #9346
void uninitvar_timercmp(struct timeval t)
{
struct timeval uninit;
(void)timercmp(&t, &uninit, <);
(void)timercmp(&uninit, &t, <=);
(void)timercmp(&uninit, &uninit, ==);
}

void nullPointer_timercmp(struct timeval t)
{
// cppcheck-suppress constVariablePointer
struct timeval *p=0;
// cppcheck-suppress nullPointer
(void)timercmp(&t, p, <);
// cppcheck-suppress nullPointer
(void)timercmp(p, &t, <=);
// cppcheck-suppress nullPointer
(void)timercmp(p, p, ==);
}

// Declaration necessary because there is no specific / portable header.
extern void *xcalloc(size_t nmemb, size_t size);
extern void *xmalloc(size_t size);
Expand Down
8 changes: 8 additions & 0 deletions test/testlibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class TestLibrary : public TestFixture {
TEST_CASE(container);
TEST_CASE(version);
TEST_CASE(loadLibErrors);
TEST_CASE(loadLibCombinations);
}

static bool loadxmldata(Library &lib, const char xmldata[], std::size_t len)
Expand Down Expand Up @@ -1065,6 +1066,13 @@ class TestLibrary : public TestFixture {
// comma followed by dot
LOADLIB_ERROR_INVALID_RANGE("-10:0,.5:");
}

void loadLibCombinations() const {
{
const Settings s = settingsBuilder().library("std.cfg").library("gnu.cfg").library("bsd.cfg").build();
ASSERT_EQUALS(s.library.defines.empty(), false);
}
}
};

REGISTER_TEST(TestLibrary)
Loading