Skip to content

Commit 05da696

Browse files
Fix error when loading both gnu.cfg and bsd.cfg (#5956)
I'm not sure all libraries must work together (some legitimate clashes are to be expected), but we could test some likely combinations.
1 parent c9c55c9 commit 05da696

3 files changed

Lines changed: 8 additions & 34 deletions

File tree

cfg/gnu.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@
245245
<not-null/>
246246
</arg>
247247
</function>
248-
<!-- int timercmp(struct timeval *a, struct timeval *b, CMP)-->
249-
<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))"/>
250248
<!-- int __builtin_types_compatible_p (type1, type2) -->
251249
<function name="__builtin_types_compatible_p">
252250
<noreturn>false</noreturn>

test/cfg/gnu.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -183,38 +183,6 @@ int uninitvar_getpw(uid_t uid, char *buf)
183183
return getpw(someUid, buf);
184184
}
185185

186-
// #9323, #9331
187-
void syntaxError_timercmp(struct timeval t)
188-
{
189-
(void)timercmp(&t, &t, <);
190-
(void)timercmp(&t, &t, <=);
191-
(void)timercmp(&t, &t, ==);
192-
(void)timercmp(&t, &t, !=);
193-
(void)timercmp(&t, &t, >=);
194-
(void)timercmp(&t, &t, >);
195-
}
196-
197-
// False negative: #9346
198-
void uninitvar_timercmp(struct timeval t)
199-
{
200-
struct timeval uninit;
201-
(void)timercmp(&t, &uninit, <);
202-
(void)timercmp(&uninit, &t, <=);
203-
(void)timercmp(&uninit, &uninit, ==);
204-
}
205-
206-
void nullPointer_timercmp(struct timeval t)
207-
{
208-
// cppcheck-suppress constVariablePointer
209-
struct timeval *p=0;
210-
// cppcheck-suppress nullPointer
211-
(void)timercmp(&t, p, <);
212-
// cppcheck-suppress nullPointer
213-
(void)timercmp(p, &t, <=);
214-
// cppcheck-suppress nullPointer
215-
(void)timercmp(p, p, ==);
216-
}
217-
218186
// Declaration necessary because there is no specific / portable header.
219187
extern void *xcalloc(size_t nmemb, size_t size);
220188
extern void *xmalloc(size_t size);

test/testlibrary.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class TestLibrary : public TestFixture {
7070
TEST_CASE(container);
7171
TEST_CASE(version);
7272
TEST_CASE(loadLibErrors);
73+
TEST_CASE(loadLibCombinations);
7374
}
7475

7576
static bool loadxmldata(Library &lib, const char xmldata[], std::size_t len)
@@ -1065,6 +1066,13 @@ class TestLibrary : public TestFixture {
10651066
// comma followed by dot
10661067
LOADLIB_ERROR_INVALID_RANGE("-10:0,.5:");
10671068
}
1069+
1070+
void loadLibCombinations() const {
1071+
{
1072+
const Settings s = settingsBuilder().library("std.cfg").library("gnu.cfg").library("bsd.cfg").build();
1073+
ASSERT_EQUALS(s.library.defines.empty(), false);
1074+
}
1075+
}
10681076
};
10691077

10701078
REGISTER_TEST(TestLibrary)

0 commit comments

Comments
 (0)