From 36b4003118fe4412e7ef8b0b2a1a59e73b22b6da Mon Sep 17 00:00:00 2001 From: "Nicola Spanti (RyDroid)" Date: Mon, 8 Aug 2016 15:23:27 +0200 Subject: [PATCH] Adding a test with cppcheck for Travis CI --- .travis.yml | 6 ++++++ tests/test_util_file.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 70e20eb1..2aa2eeff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,11 @@ compiler: - gcc - clang +addons: + apt: + packages: + - cppcheck + os: - linux - osx @@ -23,3 +28,4 @@ script: after_success: - make check + - cppcheck --quiet *.h *.c tests/ diff --git a/tests/test_util_file.c b/tests/test_util_file.c index 77639337..8a4b67a9 100644 --- a/tests/test_util_file.c +++ b/tests/test_util_file.c @@ -70,11 +70,13 @@ static void stat_and_cat(const char *file) if (read(d, buf, sb.st_size) < sb.st_size) { printf("FAIL: unable to read all of %s: %s\n", file, strerror(errno)); + free(buf); close(d); return; } buf[sb.st_size] = '\0'; printf("file[%s], size=%d, contents=%s\n", file, (int)sb.st_size, buf); + free(buf); } int main(int argc, char **argv) -- 2.39.5