fixed minor warnings issued by scan-build
This commit is contained in:
@@ -351,7 +351,7 @@ bmi32build: clean
|
|||||||
$(CC) -v
|
$(CC) -v
|
||||||
CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test
|
CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test
|
||||||
|
|
||||||
staticAnalyze: clean
|
staticAnalyze:
|
||||||
$(CC) -v
|
$(CC) -v
|
||||||
CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all
|
CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <stdio.h> /* FILE* */
|
#include <stdio.h> /* FILE* */
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#define XXH_STATIC_LINKING_ONLY
|
#define XXH_STATIC_LINKING_ONLY
|
||||||
#define XXH_NAMESPACE ZSTD_
|
#define XXH_NAMESPACE ZSTD_
|
||||||
@@ -112,7 +113,7 @@ static int ZSTD_seekable_read_buff(void* opaque, void* buffer, size_t n)
|
|||||||
|
|
||||||
static int ZSTD_seekable_seek_buff(void* opaque, long long offset, int origin)
|
static int ZSTD_seekable_seek_buff(void* opaque, long long offset, int origin)
|
||||||
{
|
{
|
||||||
buffWrapper_t* buff = (buffWrapper_t*) opaque;
|
buffWrapper_t* const buff = (buffWrapper_t*) opaque;
|
||||||
unsigned long long newOffset;
|
unsigned long long newOffset;
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
@@ -124,6 +125,8 @@ static int ZSTD_seekable_seek_buff(void* opaque, long long offset, int origin)
|
|||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
newOffset = (unsigned long long)buff->size - offset;
|
newOffset = (unsigned long long)buff->size - offset;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert(0); /* not possible */
|
||||||
}
|
}
|
||||||
if (newOffset > buff->size) {
|
if (newOffset > buff->size) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, s
|
|||||||
const BYTE* ip = (const BYTE*)src;
|
const BYTE* ip = (const BYTE*)src;
|
||||||
size_t const minInputSize = ZSTD_startingInputLength(format);
|
size_t const minInputSize = ZSTD_startingInputLength(format);
|
||||||
|
|
||||||
|
memset(zfhPtr, 0, sizeof(*zfhPtr)); /* not strictly necessary, but static analyzer do not understand that zfhPtr is only going to be read only if return value is zero, since they are 2 different signals */
|
||||||
if (srcSize < minInputSize) return minInputSize;
|
if (srcSize < minInputSize) return minInputSize;
|
||||||
if (src==NULL) return ERROR(GENERIC); /* invalid parameter */
|
if (src==NULL) return ERROR(GENERIC); /* invalid parameter */
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -27,6 +27,7 @@
|
|||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "mem.h" /* read */
|
#include "mem.h" /* read */
|
||||||
#include "error_private.h"
|
#include "error_private.h"
|
||||||
@@ -165,6 +166,7 @@ static U32 DiB_rand(U32* src)
|
|||||||
static void DiB_shuffle(const char** fileNamesTable, unsigned nbFiles) {
|
static void DiB_shuffle(const char** fileNamesTable, unsigned nbFiles) {
|
||||||
U32 seed = 0xFD2FB528;
|
U32 seed = 0xFD2FB528;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
assert(nbFiles >= 1);
|
||||||
for (i = nbFiles - 1; i > 0; --i) {
|
for (i = nbFiles - 1; i > 0; --i) {
|
||||||
unsigned const j = DiB_rand(&seed) % (i + 1);
|
unsigned const j = DiB_rand(&seed) % (i + 1);
|
||||||
const char* const tmp = fileNamesTable[j];
|
const char* const tmp = fileNamesTable[j];
|
||||||
@@ -310,7 +312,7 @@ int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
|
|||||||
/* Load input buffer */
|
/* Load input buffer */
|
||||||
DISPLAYLEVEL(3, "Shuffling input files\n");
|
DISPLAYLEVEL(3, "Shuffling input files\n");
|
||||||
DiB_shuffle(fileNamesTable, nbFiles);
|
DiB_shuffle(fileNamesTable, nbFiles);
|
||||||
nbFiles = DiB_loadFiles(srcBuffer, &loadedSize, sampleSizes, fs.nbSamples, fileNamesTable, nbFiles, chunkSize, displayLevel);
|
DiB_loadFiles(srcBuffer, &loadedSize, sampleSizes, fs.nbSamples, fileNamesTable, nbFiles, chunkSize, displayLevel);
|
||||||
|
|
||||||
{ size_t dictSize;
|
{ size_t dictSize;
|
||||||
if (params) {
|
if (params) {
|
||||||
@@ -319,6 +321,7 @@ int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
|
|||||||
srcBuffer, sampleSizes, fs.nbSamples,
|
srcBuffer, sampleSizes, fs.nbSamples,
|
||||||
*params);
|
*params);
|
||||||
} else if (optimizeCover) {
|
} else if (optimizeCover) {
|
||||||
|
assert(coverParams != NULL);
|
||||||
dictSize = ZDICT_optimizeTrainFromBuffer_cover(dictBuffer, maxDictSize,
|
dictSize = ZDICT_optimizeTrainFromBuffer_cover(dictBuffer, maxDictSize,
|
||||||
srcBuffer, sampleSizes, fs.nbSamples,
|
srcBuffer, sampleSizes, fs.nbSamples,
|
||||||
coverParams);
|
coverParams);
|
||||||
@@ -327,6 +330,7 @@ int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
|
|||||||
DISPLAYLEVEL(2, "k=%u\nd=%u\nsteps=%u\nsplit=%u\n", coverParams->k, coverParams->d, coverParams->steps, splitPercentage);
|
DISPLAYLEVEL(2, "k=%u\nd=%u\nsteps=%u\nsplit=%u\n", coverParams->k, coverParams->d, coverParams->steps, splitPercentage);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
assert(coverParams != NULL);
|
||||||
dictSize = ZDICT_trainFromBuffer_cover(dictBuffer, maxDictSize, srcBuffer,
|
dictSize = ZDICT_trainFromBuffer_cover(dictBuffer, maxDictSize, srcBuffer,
|
||||||
sampleSizes, fs.nbSamples, *coverParams);
|
sampleSizes, fs.nbSamples, *coverParams);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
|
int DiB_trainFromFiles(const char* dictFileName, unsigned maxDictSize,
|
||||||
const char** fileNamesTable, unsigned nbFiles, size_t chunkSize,
|
const char** fileNamesTable, unsigned nbFiles, size_t chunkSize,
|
||||||
ZDICT_legacy_params_t *params, ZDICT_cover_params_t *coverParams,
|
ZDICT_legacy_params_t* params, ZDICT_cover_params_t* coverParams,
|
||||||
int optimizeCover);
|
int optimizeCover);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user