Author: mjordan Date: Sat Apr 11 10:26:45 2015 New Revision: 434706 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=434706 Log: clang compiler warnings: Fix various warnings for tests
This patch fixes a variety of clang compiler warnings for unit tests. This includes autological comparison issues, ignored return values, and interestingly enough, one embedded function. Fun! Review: https://reviewboard.asterisk.org/r/4555 ASTERISK-24917 Reported by: dkdegroot patches: rb4555.patch submitted by dkdegroot (License 6600) ........ Merged revisions 434705 from http://svn.asterisk.org/svn/asterisk/branches/11 Modified: branches/13/ (props changed) branches/13/tests/test_acl.c branches/13/tests/test_sched.c branches/13/tests/test_stringfields.c branches/13/tests/test_strings.c Propchange: branches/13/ ------------------------------------------------------------------------------ --- branch-11-merged (original) +++ branch-11-merged Sat Apr 11 10:26:45 2015 @@ -1,1 +1,1 @@ -/branches/11:1-429672,429674-431296,431299-431471,431473-431581,431583-431619,431621-433085,433087-433918,433920-434259,434261-434333,434335-434614 +/branches/11:1-429672,429674-431296,431299-431471,431473-431581,431583-431619,431621-433085,433087-433918,433920-434259,434261-434333,434335-434614,434705 Modified: branches/13/tests/test_acl.c URL: http://svnview.digium.com/svn/asterisk/branches/13/tests/test_acl.c?view=diff&rev=434706&r1=434705&r2=434706 ============================================================================== --- branches/13/tests/test_acl.c (original) +++ branches/13/tests/test_acl.c Sat Apr 11 10:26:45 2015 @@ -122,6 +122,22 @@ #define TACL_A AST_SENSE_ALLOW #define TACL_D AST_SENSE_DENY +static int build_ha(const struct acl *acl, size_t len, struct ast_ha **ha, const char *acl_name, int *err, struct ast_test *test, enum ast_test_result_state *res) +{ + size_t i; + + for (i = 0; i < len; ++i) { + if (!(*ha = ast_append_ha(acl[i].access, acl[i].host, *ha, err))) { + ast_test_status_update(test, "Failed to add rule %s with access %s to %s\n", + acl[i].host, acl[i].access, acl_name); + *res = AST_TEST_FAIL; + return -1; + } + } + + return 0; +} + AST_TEST_DEFINE(acl) { struct acl permitallv4 = { "0.0.0.0/0", "permit" }; @@ -211,21 +227,6 @@ int err = 0; int i; - auto int build_ha(const struct acl *acl, size_t len, struct ast_ha **ha, const char *acl_name); - auto int build_ha(const struct acl *acl, size_t len, struct ast_ha **ha, const char *acl_name) { - size_t i; - - for (i = 0; i < len; ++i) { - if (!(*ha = ast_append_ha(acl[i].access, acl[i].host, *ha, &err))) { - ast_test_status_update(test, "Failed to add rule %s with access %s to %s\n", - acl[i].host, acl[i].access, acl_name); - res = AST_TEST_FAIL; - return -1; - } - } - - return 0; - } switch (cmd) { case TEST_INIT: @@ -263,31 +264,31 @@ goto acl_cleanup; } - if (build_ha(acl1, ARRAY_LEN(acl1), &ha1, "ha1") != 0) { - goto acl_cleanup; - } - - if (build_ha(acl2, ARRAY_LEN(acl2), &ha2, "ha2") != 0) { - goto acl_cleanup; - } - - if (build_ha(acl3, ARRAY_LEN(acl3), &ha3, "ha3") != 0) { - goto acl_cleanup; - } - - if (build_ha(acl4, ARRAY_LEN(acl4), &ha4, "ha4") != 0) { - goto acl_cleanup; - } - - if (build_ha(acl5, ARRAY_LEN(acl5), &ha5, "ha5") != 0) { - goto acl_cleanup; - } - - if (build_ha(acl6, ARRAY_LEN(acl6), &ha6, "ha6") != 0) { - goto acl_cleanup; - } - - if (build_ha(acl7, ARRAY_LEN(acl7), &ha7, "ha7") != 0) { + if (build_ha(acl1, ARRAY_LEN(acl1), &ha1, "ha1", &err, test, &res) != 0) { + goto acl_cleanup; + } + + if (build_ha(acl2, ARRAY_LEN(acl2), &ha2, "ha2", &err, test, &res) != 0) { + goto acl_cleanup; + } + + if (build_ha(acl3, ARRAY_LEN(acl3), &ha3, "ha3", &err, test, &res) != 0) { + goto acl_cleanup; + } + + if (build_ha(acl4, ARRAY_LEN(acl4), &ha4, "ha4", &err, test, &res) != 0) { + goto acl_cleanup; + } + + if (build_ha(acl5, ARRAY_LEN(acl5), &ha5, "ha5", &err, test, &res) != 0) { + goto acl_cleanup; + } + + if (build_ha(acl6, ARRAY_LEN(acl6), &ha6, "ha6", &err, test, &res) != 0) { + goto acl_cleanup; + } + + if (build_ha(acl7, ARRAY_LEN(acl7), &ha7, "ha7", &err, test, &res) != 0) { goto acl_cleanup; } Modified: branches/13/tests/test_sched.c URL: http://svnview.digium.com/svn/asterisk/branches/13/tests/test_sched.c?view=diff&rev=434706&r1=434705&r2=434706 ============================================================================== --- branches/13/tests/test_sched.c (original) +++ branches/13/tests/test_sched.c Sat Apr 11 10:26:45 2015 @@ -202,7 +202,7 @@ start = ast_tvnow(); for (i = 0; i < num; i++) { - int when = abs(ast_random()) % 60000; + long when = labs(ast_random()) % 60000; if ((sched_ids[i] = ast_sched_add(con, when, sched_cb, NULL)) == -1) { ast_cli(a->fd, "Test failed - sched_add returned -1\n"); goto return_cleanup; Modified: branches/13/tests/test_stringfields.c URL: http://svnview.digium.com/svn/asterisk/branches/13/tests/test_stringfields.c?view=diff&rev=434706&r1=434705&r2=434706 ============================================================================== --- branches/13/tests/test_stringfields.c (original) +++ branches/13/tests/test_stringfields.c Sat Apr 11 10:26:45 2015 @@ -212,7 +212,7 @@ } if (AST_STRING_FIELD_ALLOCATION(test_struct.string2) != strlen("hippopotamus face") + 1) { - ast_test_status_update(test, "The allocation amount is incorrect for string2. We expect %lu but it has %hu\n", + ast_test_status_update(test, "The allocation amount is incorrect for string2. We expect %lu but it has %d\n", (unsigned long) strlen("hippopotamus face"), AST_STRING_FIELD_ALLOCATION(test_struct.string2) + 1); goto error; } else { Modified: branches/13/tests/test_strings.c URL: http://svnview.digium.com/svn/asterisk/branches/13/tests/test_strings.c?view=diff&rev=434706&r1=434705&r2=434706 ============================================================================== --- branches/13/tests/test_strings.c (original) +++ branches/13/tests/test_strings.c Sat Apr 11 10:26:45 2015 @@ -390,9 +390,12 @@ static int test_semi(char *string1, char *string2, int test_len) { char *test2 = NULL; - if (test_len >= 0) { + + if (test_len > 0) { test2 = ast_alloca(test_len); *test2 = '\0'; + } else if (test_len == 0) { + test2 = ""; } ast_escape_semicolons(string1, test2, test_len); if (test2 != NULL && strcmp(string2, test2) == 0) { -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits