implements cppcheck test

- fixes #8
pull/42/head
Christian Krause 9 years ago
parent b07393c2f6
commit 35a2f67be9

@ -6,7 +6,7 @@ compiler:
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq asciidoc libarchive-dev liblzma-dev xz-utils
- sudo apt-get install -qq asciidoc cppcheck libarchive-dev liblzma-dev xz-utils
script:
- autoconf --version

@ -43,7 +43,7 @@ AC_SYS_LARGEFILE
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memchr memmove memset strtol])
AC_CHECK_FUNCS([memchr memmove memset strerror strtol])
AC_CONFIG_FILES([Makefile
src/Makefile

@ -1,5 +1,6 @@
#include "pixz.h"
#include <errno.h>
#include <stdarg.h>
#include <math.h>
@ -213,7 +214,15 @@ static void read_file_index_make_space(void) {
if (expand || gMoved >= gFIBSize) { // malloc more space
gStream.avail_out += gFIBSize;
gFIBSize *= 2;
gFileIndexBuf = realloc(gFileIndexBuf, gFIBSize);
uint8_t *new_gFileIndexBuf = realloc(gFileIndexBuf, gFIBSize);
if (new_gFileIndexBuf == NULL) {
// TODO is recovery possible? does it even make sense?
die("memory re-allocation failure: %s", strerror(errno));
} else {
gFileIndexBuf = new_gFileIndexBuf;
}
}
}

@ -1,4 +1,5 @@
TESTS = \
cppcheck-src.sh \
single-file-round-trip.sh \
xz-compatibility-c-option.sh

@ -0,0 +1,8 @@
#!/bin/bash
if which cppcheck &> /dev/null ; then
cppcheck --error-exitcode=1 $srcdir/../src
else
echo "no cppcheck, skipping test"
exit 77
fi
Loading…
Cancel
Save