Commit 6d75d1c3 authored by Uwe Schulzweida's avatar Uwe Schulzweida

Fix cppcheck warnings.

parent 3e9f4f34
Pipeline #5780 passed with stages
in 14 minutes and 50 seconds
......@@ -38,7 +38,7 @@ CheckVector
size_t m_count;
CheckVector() : ptr(dummy), m_count(0) { }
CheckVector(size_t count) : ptr(dummy), m_count(count) { }
explicit CheckVector(size_t count) : ptr(dummy), m_count(count) { }
CheckVector(size_t count, const T& value) : ptr(dummy), m_count(count) { ptr[0] = value; }
T * begin() noexcept { return &ptr[0]; }
......@@ -58,19 +58,19 @@ CheckVector
void push_back(const T& value) { ptr[0] = value; }
T * data() noexcept { return ptr; }
const T* data() const noexcept { return ptr; }
const T * data() const noexcept { return ptr; }
T& operator[](size_t pos) { (void) pos; return ptr[0]; }
const T & operator[](size_t pos) const { (void) pos; return ptr[0]; }
CheckVector& operator=( const CheckVector& other ) { (void)other; return *this; }
CheckVector& operator=( CheckVector&& other ) { (void)other; return *this; }
CheckVector& operator=(const CheckVector& other) { (void)other; ptr = dummy; m_count = 0; return *this; }
CheckVector& operator=(CheckVector&& other) { (void)other; ptr = dummy; m_count = 0; return *this; }
// Copy constructor
CheckVector(const CheckVector &v2) { ptr[0] = v2.ptr[0]; }
CheckVector(const CheckVector &v2) { m_count = 0; ptr[0] = v2.ptr[0]; }
bool operator==(const CheckVector& other) { (void)other; return true; }
private:
T dummy[1];
T dummy[1] = { 0 };
};
template <typename T>
......
......@@ -852,7 +852,7 @@ print_system_info()
#ifdef _OPENMP
fprintf(stderr, "OPENMP VERSION = %d\n", _OPENMP);
#endif
fprintf(stderr, "__cplusplus = %ld\n", __cplusplus);
fprintf(stderr, "__cplusplus = %ld\n", (long)__cplusplus);
#ifdef __GNUC__
fprintf(stderr, "GNUC VERSION = %d\n", __GNUC__);
#endif
......
......@@ -112,7 +112,7 @@ getNCErrString(int filetype, const char *progname)
: ((filetype == CDI_FILETYPE_NC2) ? "2" : ((filetype == CDI_FILETYPE_NC5) ? "5" : ""));
#ifdef HAVE_LIBNETCDF
const char *format = "%s was build with a NetCDF version which doesn't support NetCDF%s data!";
size_t finalSize = snprintf(nullptr, 0, format, progname, ncv, ncv);
size_t finalSize = snprintf(nullptr, 0, format, progname, ncv);
char *errStr = (char *) malloc(finalSize + 1);
sprintf(errStr, format, progname, ncv);
#else
......
......@@ -319,10 +319,10 @@ parseCmortablebufJson(PMList &pmlist, size_t buffersize, char *buffer, const cha
switch (status)
{
case JSMN_ERROR_INVAL:
fprintf(stderr, "JSON error: Invalid character in %s (line=%d character='%c')!\n", filename, p->lineno, buffer[p->pos]);
fprintf(stderr, "JSON error: Invalid character in %s (line=%u character='%c')!\n", filename, p->lineno, buffer[p->pos]);
break;
case JSMN_ERROR_PART: fprintf(stderr, "JSON error: End of string not found in %s (line=%d)!\n", filename, p->lineno); break;
default: fprintf(stderr, "JSON error in %s (line=%d)\n", filename, p->lineno); break;
case JSMN_ERROR_PART: fprintf(stderr, "JSON error: End of string not found in %s (line=%u)!\n", filename, p->lineno); break;
default: fprintf(stderr, "JSON error in %s (line=%u)\n", filename, p->lineno); break;
}
}
......
......@@ -152,10 +152,8 @@ void kd_printNode(struct kdNode *node);
void kd_printTree(struct kdNode *node);
/* Functions for building and destroying trees */
struct kdNode *kd_allocNodeP(kdNodePool *nodepool, struct kd_point *points, size_t pivot,
kdata_t *min, kdata_t *max, int dim, int axis);
struct kdNode *kd_allocNode(struct kd_point *points, size_t pivot,
kdata_t *min, kdata_t *max, int dim, int axis);
struct kdNode *kd_allocNodeP(kdNodePool *nodepool, struct kd_point *points, size_t pivot, kdata_t *min, kdata_t *max, int axis, int dim);
struct kdNode *kd_allocNode(struct kd_point *points, size_t pivot, kdata_t *min, kdata_t *max, int axis, int dim);
void kd_doDestroyTree(struct kdNode *node);
void kd_destroyTree(kdTree_t *tree);
void kd_initArg(struct kd_thread_data *d, kdNodePool_t *nodepool, struct kd_point *points, size_t nPoints,
......
......@@ -135,8 +135,7 @@ void kd_nodepool_delete(kdNodePool_t *nodepool)
}
struct kdNode *
kd_allocNode(struct kd_point *points, size_t pivot,
kdata_t *min, kdata_t *max, int axis, int dim)
kd_allocNode(struct kd_point *points, size_t pivot, kdata_t *min, kdata_t *max, int axis, int dim)
{
struct kdNode *node;
......@@ -154,8 +153,7 @@ kd_allocNode(struct kd_point *points, size_t pivot,
}
struct kdNode *
kd_allocNodeP(kdNodePool *nodepool, struct kd_point *points, size_t pivot,
kdata_t *min, kdata_t *max, int axis, int dim)
kd_allocNodeP(kdNodePool *nodepool, struct kd_point *points, size_t pivot, kdata_t *min, kdata_t *max, int axis, int dim)
{
struct kdNode *node;
......@@ -227,21 +225,16 @@ void *kd_doBuildTree(void *threadarg)
int sortaxis = depth % dim;
if (nPoints == 1) {
if ((node = kd_allocNodeP(nodepool, points, 0, min, max, sortaxis, dim)) == NULL)
return NULL;
if ((node = kd_allocNodeP(nodepool, points, 0, min, max, sortaxis, dim)) == NULL) return NULL;
node->index = points[0].index;
return node;
}
/*
* If this iteration is allowed to start more threads, we first
* use them to parallelize the sorting
*/
// If this iteration is allowed to start more threads, we first use them to parallelize the sorting
pmergesort(points, nPoints, sortaxis, max_threads);
size_t pivot = nPoints / 2;
if ((node = kd_allocNodeP(nodepool, points, pivot, min, max, sortaxis, dim)) == NULL)
return NULL;
if ((node = kd_allocNodeP(nodepool, points, pivot, min, max, sortaxis, dim)) == NULL) return NULL;
memcpy(tmpMaxLeft, max, dim * sizeof(kdata_t));
tmpMaxLeft[sortaxis] = node->location[sortaxis];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment