Compare commits

...

24 Commits

Author SHA1 Message Date
Mark Andrews
6c7e86aa51 suppress DOXYGEN 2020-02-03 17:44:15 +11:00
Mark Andrews
5c4917f66e remove unused label 2020-02-03 16:45:15 +11:00
Mark Andrews
b7f9192ff1 add --library=std.cfg 2020-02-03 16:38:39 +11:00
Mark Andrews
d9fa5d5a9a isc_mem_get cannot fail 2020-01-30 19:54:27 +11:00
Mark Andrews
6ab0b3d51a fixup! limit jobs when debugging cppcheck 2020-01-30 19:47:12 +11:00
Mark Andrews
8917d2f9b6 fixup! limit jobs when debugging cppcheck 2020-01-30 19:45:36 +11:00
Mark Andrews
1a8b581510 isc_mem_get cannot fail 2020-01-30 19:41:32 +11:00
Mark Andrews
2c823cc84f delay assignment until after REQUIRE 2020-01-30 19:38:47 +11:00
Mark Andrews
e4e753f46a fixup! limit jobs when debugging cppcheck 2020-01-30 19:14:27 +11:00
Mark Andrews
228e769d75 fixup! limit jobs when debugging cppcheck 2020-01-30 19:11:14 +11:00
Mark Andrews
3590a811a2 fixup! limit jobs when debugging cppcheck 2020-01-30 19:07:04 +11:00
Mark Andrews
4de0a36a42 fixup! limit jobs when debugging cppcheck 2020-01-30 19:00:24 +11:00
Mark Andrews
bbe83c3b2a delay assignment until after REQUIRE 2020-01-30 18:56:03 +11:00
Mark Andrews
fe745d238d skip if first is NULL 2020-01-30 18:55:36 +11:00
Mark Andrews
f1326c124a limit jobs when debugging cppcheck 2020-01-30 18:41:50 +11:00
Mark Andrews
05cb183b91 fixup! delay assignment until after REQUIRE 2020-01-30 18:24:22 +11:00
Mark Andrews
b7b62bf0b2 delay assignment until after REQUIRE 2020-01-30 18:19:11 +11:00
Mark Andrews
2c17edf417 make expression logical for cppcheck 2020-01-30 17:57:25 +11:00
Mark Andrews
feba3113c4 remove brackets 2020-01-30 17:49:15 +11:00
Mark Andrews
18194962f2 simplify ISC_LIKELY/ISC_UNLIKELY for CPPCHECK 2020-01-30 17:27:08 +11:00
Mark Andrews
d3786c0cf1 simplify RUNTIME_CHECK for cppcheck 2020-01-30 17:14:42 +11:00
Mark Andrews
1c2f8ab09f add untracked 2020-01-30 16:42:27 +11:00
Mark Andrews
2f7613333f fixup! add --dump 2020-01-30 16:15:47 +11:00
Mark Andrews
0ff879f145 add --dump 2020-01-30 16:13:21 +11:00
9 changed files with 83 additions and 49 deletions

View File

@@ -29,6 +29,9 @@ variables:
TARBALL_COMPRESSOR: xz
TARBALL_EXTENSION: xz
# limit jobs when debugging cppcheck
DEBUG_CPPCHECK: 1
stages:
- precheck
- build
@@ -209,6 +212,9 @@ stages:
artifacts:
untracked: true
expire_in: "1 day"
except:
variables:
- $DEBUG_CPPCHECK == "1"
.windows_build: &windows_build_job
stage: build
@@ -239,6 +245,9 @@ stages:
artifacts:
untracked: true
expire_in: "1 day"
except:
variables:
- $DEBUG_CPPCHECK == "1"
.setup_interfaces: &setup_interfaces |
if [ "$(id -u)" -eq "0" ]; then
@@ -263,6 +272,9 @@ stages:
untracked: true
expire_in: "1 day"
when: on_failure
except:
variables:
- $DEBUG_CPPCHECK == "1"
.kyua_report: &kyua_report_html |
kyua --logfile /dev/null report-html \
@@ -311,12 +323,17 @@ stages:
- kyua_html/
expire_in: "1 day"
when: on_failure
except:
variables:
- $DEBUG_CPPCHECK == "1"
.cppcheck_args: &run_cppcheck |
cppcheck --enable=warning,performance,portability,information,missingInclude \
--dump \
--include=config.h \
--quiet \
--std=c11 \
--library=std.cfg \
--language=c \
--project=compile_commands.json \
--error-exitcode=2 \
@@ -325,6 +342,7 @@ stages:
--output-file=cppcheck.results \
--relative-paths="$CI_PROJECT_DIR" \
--inline-suppr \
-U DOXYGEN \
--suppressions-list=util/suppressions.txt
.cppcheck_report: &cppcheck_report_html |
@@ -343,6 +361,7 @@ stages:
after_script:
- *cppcheck_report_html
artifacts:
untracked: true
paths:
- compile_commands.json
- cppcheck.results
@@ -426,6 +445,9 @@ docs:sid:amd64:
paths:
- doc/arm/
expire_in: "1 day"
except:
variables:
- $DEBUG_CPPCHECK == "1"
push:docs:sid:amd64:
<<: *debian_sid_amd64_image
@@ -634,6 +656,9 @@ scan-build:buster:amd64:
- scan-build.reports/
expire_in: "1 day"
when: on_failure
except:
variables:
- $DEBUG_CPPCHECK == "1"
# Jobs for regular GCC builds on Debian Sid (amd64)
@@ -644,6 +669,7 @@ gcc:sid:amd64:
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
RUN_MAKE_INSTALL: 1
MAKE: bear make
DEBUG_CPPCHECK: 0
<<: *debian_sid_amd64_image
<<: *build_job
@@ -1129,6 +1155,9 @@ system:msvc:windows:amd64:
dependencies:
- msvc:windows:amd64
needs: ["msvc:windows:amd64"]
except:
variables:
- $DEBUG_CPPCHECK == "1"
msvc-debug:windows:amd64:
<<: *windows_build_job
@@ -1146,6 +1175,9 @@ system:msvc-debug:windows:amd64:
dependencies:
- msvc-debug:windows:amd64
needs: ["msvc-debug:windows:amd64"]
except:
variables:
- $DEBUG_CPPCHECK == "1"
# Job producing a release tarball

View File

@@ -97,7 +97,7 @@ int main(int argc, char **argv)
UNUSED(argc);
UNUSED(argv);
target = target ? target + 1 : argv[0];
target = (target != NULL) ? target + 1 : argv[0];
if (strncmp(target, "lt-", 3) == 0) {
target += 3;
}

View File

@@ -1340,13 +1340,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
ISC_LIST_INIT(event->answerlist);
rctx = isc_mem_get(mctx, sizeof(*rctx));
if (rctx == NULL)
result = ISC_R_NOMEMORY;
else {
isc_mutex_init(&rctx->lock);
}
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_mutex_init(&rctx->lock);
result = getrdataset(mctx, &rdataset);
if (result != ISC_R_SUCCESS)
@@ -1748,13 +1742,7 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
action, arg, sizeof(*event));
ctx = isc_mem_get(client->mctx, sizeof(*ctx));
if (ctx == NULL)
result = ISC_R_NOMEMORY;
else {
isc_mutex_init(&ctx->lock);
}
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_mutex_init(&ctx->lock);
ctx->client = client;
ISC_LINK_INIT(ctx, link);
@@ -1787,14 +1775,11 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
isc_refcount_decrement(&client->references);
cleanup:
if (ctx != NULL) {
LOCK(&client->lock);
ISC_LIST_UNLINK(client->reqctxs, ctx, link);
UNLOCK(&client->lock);
isc_mutex_destroy(&ctx->lock);
isc_mem_put(client->mctx, ctx, sizeof(*ctx));
}
LOCK(&client->lock);
ISC_LIST_UNLINK(client->reqctxs, ctx, link);
UNLOCK(&client->lock);
isc_mutex_destroy(&ctx->lock);
isc_mem_put(client->mctx, ctx, sizeof(*ctx));
if (event != NULL)
isc_event_free(ISC_EVENT_PTR(&event));
isc_task_detach(&tclone);

View File

@@ -130,7 +130,7 @@ static isc_result_t
write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
isc_result_t result;
size_t ret = 0;
data_holder_t *data = (data_holder_t *)datap;
data_holder_t *data;
data_holder_t temp;
off_t where;
@@ -138,7 +138,8 @@ write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
REQUIRE(file != NULL);
REQUIRE(crc != NULL);
REQUIRE(data != NULL);
REQUIRE(datap != NULL);
data = (data_holder_t *)datap;
REQUIRE((data->len == 0 && data->data == NULL) ||
(data->len != 0 && data->data != NULL));

View File

@@ -1215,15 +1215,15 @@ verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) {
result = ISC_R_FAILURE;
}
if (first == NULL || newchain(first, e)) {
if (prev != NULL) {
if (!checknext(vctx, prev, first)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
}
if (first != NULL) {
if (prev != NULL) {
if (!checknext(vctx, prev, first)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
}
free_element(mctx, first);
}
prev = first = e;

View File

@@ -15,6 +15,10 @@
/*%
* Performance
*/
#ifdef CPPCHECK
#define ISC_LIKELY(x) (x)
#define ISC_UNLIKELY(x) (x)
#else
#ifdef HAVE_BUILTIN_EXPECT
#define ISC_LIKELY(x) __builtin_expect(!!(x), 1)
#define ISC_UNLIKELY(x) __builtin_expect(!!(x), 0)
@@ -22,5 +26,6 @@
#define ISC_LIKELY(x) (x)
#define ISC_UNLIKELY(x) (x)
#endif
#endif
#endif /* ISC_LIKELY_H */

View File

@@ -285,12 +285,17 @@ extern void mock_assert(const int result, const char* const expression,
#ifdef UNIT_TESTING
#define RUNTIME_CHECK(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
((!(expression)) ? \
(mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
#else /* UNIT_TESTING */
#ifndef CPPCHECK
/*% Runtime Check */
#define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond)
#else
#define RUNTIME_CHECK(e) if (!(e)) abort()
#endif
#endif /* UNIT_TESTING */

View File

@@ -103,10 +103,10 @@ void isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line);
#if ISC_MUTEX_PROFILE
#define isc_mutex_destroy(mp) \
(RUNTIME_CHECK(pthread_mutex_destroy((&(mp)->mutex)) == 0))
RUNTIME_CHECK(pthread_mutex_destroy((&(mp)->mutex)) == 0)
#else
#define isc_mutex_destroy(mp) \
(RUNTIME_CHECK(pthread_mutex_destroy((mp)) == 0))
RUNTIME_CHECK(pthread_mutex_destroy((mp)) == 0)
#endif
#if ISC_MUTEX_PROFILE

View File

@@ -239,7 +239,7 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp)
{
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
isc__timermgr_t *manager;
isc__timer_t *timer;
isc_result_t result;
isc_time_t now;
@@ -252,7 +252,8 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
* in 'timerp'.
*/
REQUIRE(VALID_MANAGER(manager));
REQUIRE(VALID_MANAGER(manager0));
manager = (isc__timermgr_t *)manager0;
REQUIRE(task != NULL);
REQUIRE(action != NULL);
if (expires == NULL)
@@ -352,7 +353,7 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
bool purge)
{
isc__timer_t *timer = (isc__timer_t *)timer0;
isc__timer_t *timer;
isc_time_t now;
isc__timermgr_t *manager;
isc_result_t result;
@@ -363,7 +364,8 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
* are purged from its task's event queue.
*/
REQUIRE(VALID_TIMER(timer));
REQUIRE(VALID_TIMER(timer0));
timer = (isc__timer_t *)timer0;
manager = timer->manager;
REQUIRE(VALID_MANAGER(manager));
@@ -425,10 +427,11 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
isc_timertype_t
isc_timer_gettype(isc_timer_t *timer0) {
isc__timer_t *timer = (isc__timer_t *)timer0;
isc__timer_t *timer;
isc_timertype_t t;
REQUIRE(VALID_TIMER(timer));
REQUIRE(VALID_TIMER(timer0));
timer = (isc__timer_t *)timer0;
LOCK(&timer->lock);
t = timer->type;
@@ -439,7 +442,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
isc_result_t
isc_timer_touch(isc_timer_t *timer0) {
isc__timer_t *timer = (isc__timer_t *)timer0;
isc__timer_t *timer;
isc_result_t result;
isc_time_t now;
@@ -447,7 +450,8 @@ isc_timer_touch(isc_timer_t *timer0) {
* Set the last-touched time of 'timer' to the current time.
*/
REQUIRE(VALID_TIMER(timer));
REQUIRE(VALID_TIMER(timer0));
timer = (isc__timer_t *)timer0;
LOCK(&timer->lock);
@@ -470,13 +474,14 @@ isc_timer_touch(isc_timer_t *timer0) {
void
isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
isc__timer_t *timer = (isc__timer_t *)timer0;
isc__timer_t *timer;
/*
* Attach *timerp to timer.
*/
REQUIRE(VALID_TIMER(timer));
REQUIRE(VALID_TIMER(timer0));
timer = (isc__timer_t *)timer0;
REQUIRE(timerp != NULL && *timerp == NULL);
isc_refcount_increment(&timer->references);
@@ -661,8 +666,8 @@ static void
set_index(void *what, unsigned int index) {
isc__timer_t *timer;
REQUIRE(VALID_TIMER(what));
timer = what;
REQUIRE(VALID_TIMER(timer));
timer->index = index;
}
@@ -707,9 +712,10 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
void
isc_timermgr_poke(isc_timermgr_t *manager0) {
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
isc__timermgr_t *manager;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(VALID_MANAGER(manager0));
manager = (isc__timermgr_t *)manager0;
SIGNAL(&manager->wakeup);
}