]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Silence cppcheck reports of function call in sizeof()
authorMark Andrews <marka@isc.org>
Fri, 29 Oct 2021 11:30:51 +0000 (22:30 +1100)
committerMark Andrews <marka@isc.org>
Mon, 1 Nov 2021 06:42:37 +0000 (17:42 +1100)
cmocka macros call sizeof() on arguments that are function calls
reimplement to remove warning

lib/irs/tests/resconf_test.c
lib/isc/tests/file_test.c
lib/isc/tests/hmac_test.c
lib/isc/tests/md_test.c

index 4befe01f15be673b4221bb00216ca1380da648f2..9d0c9751bbbe128f4df8388e1f33be281136db20 100644 (file)
@@ -32,6 +32,8 @@ static isc_mem_t *mctx = NULL;
 
 static void
 setup_test(void) {
+       int n;
+
        isc_mem_create(&mctx);
 
        /*
@@ -39,7 +41,8 @@ setup_test(void) {
         * that access test data files must first chdir to the proper
         * location.
         */
-       assert_return_code(chdir(TESTS_DIR), 0);
+       n = chdir(TESTS_DIR);
+       assert_return_code(n, 0);
 }
 
 static isc_result_t
index d1d6a956e74a86567f27670b8e9722f48ed033a8..18e02d467e1f9aaacb22533900424cf34d652aec 100644 (file)
@@ -54,10 +54,12 @@ static void
 isc_file_sanitize_test(void **state) {
        isc_result_t result;
        char buf[1024];
+       int n;
 
        UNUSED(state);
 
-       assert_return_code(chdir(TESTS_DIR), 0);
+       n = chdir(TESTS_DIR);
+       assert_return_code(n, 0);
 
        result = isc_file_sanitize("testdata/file", NAME, "test", buf, 1024);
        assert_int_equal(result, ISC_R_SUCCESS);
@@ -90,10 +92,12 @@ static void
 isc_file_template_test(void **state) {
        isc_result_t result;
        char buf[1024];
+       int n;
 
        UNUSED(state);
 
-       assert_return_code(chdir(TESTS_DIR), 0);
+       n = chdir(TESTS_DIR);
+       assert_return_code(n, 0);
 
        result = isc_file_template("/absolute/path", "file-XXXXXXXX", buf,
                                   sizeof(buf));
index cfd3ae3c9b5b5196d12c2a508d57b2ae9cc27f1a..4a9629d6a23f91a53bc8ff105dceb0089dcbeb0d 100644 (file)
@@ -86,6 +86,8 @@ static void
 isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen,
              const isc_md_type_t *type, const char *buf, size_t buflen,
              const char *result, const int repeats) {
+       isc_result_t result;
+
        assert_non_null(hmac);
        assert_int_equal(isc_hmac_init(hmac, key, keylen, type), ISC_R_SUCCESS);
 
@@ -108,7 +110,8 @@ isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen,
        isc_buffer_t b;
        isc_buffer_init(&b, hexdigest, sizeof(hexdigest));
 
-       assert_return_code(isc_hex_totext(&r, 0, "", &b), ISC_R_SUCCESS);
+       result = isc_hex_totext(&r, 0, "", &b);
+       assert_return_code(result, ISC_R_SUCCESS);
 
        assert_memory_equal(hexdigest, result, (result ? strlen(result) : 0));
        assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS);
index 260fda861e0533704a21c83088060ceffe87b330..8c651fda764287f231ea0671edda872d4b867eef 100644 (file)
@@ -84,6 +84,8 @@ isc_md_free_test(void **state) {
 static void
 isc_md_test(isc_md_t *md, const isc_md_type_t *type, const char *buf,
            size_t buflen, const char *result, const int repeats) {
+       isc_result_t result;
+
        assert_non_null(md);
        assert_int_equal(isc_md_init(md, type), ISC_R_SUCCESS);
 
@@ -104,7 +106,8 @@ isc_md_test(isc_md_t *md, const isc_md_type_t *type, const char *buf,
        isc_buffer_t b;
        isc_buffer_init(&b, hexdigest, sizeof(hexdigest));
 
-       assert_return_code(isc_hex_totext(&r, 0, "", &b), ISC_R_SUCCESS);
+       result = isc_hex_totext(&r, 0, "", &b),
+       assert_return_code(result, ISC_R_SUCCESS);
 
        assert_memory_equal(hexdigest, result, (result ? strlen(result) : 0));
        assert_int_equal(isc_md_reset(md), ISC_R_SUCCESS);