mirror of https://github.com/ecmwf/eccodes.git
Testing: cppcheck warnings
This commit is contained in:
parent
2617255ef1
commit
f0afba273a
|
@ -67,7 +67,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
while (codes_bufr_keys_iterator_next(kiter)) {
|
while (codes_bufr_keys_iterator_next(kiter)) {
|
||||||
char* kname = codes_bufr_keys_iterator_get_name(kiter);
|
const char* kname = codes_bufr_keys_iterator_get_name(kiter);
|
||||||
printf("%s\n", kname);
|
printf("%s\n", kname);
|
||||||
}
|
}
|
||||||
codes_bufr_keys_iterator_delete(kiter);
|
codes_bufr_keys_iterator_delete(kiter);
|
||||||
|
|
|
@ -49,7 +49,7 @@ void* runner(void* ptr)
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int encode_file(char* input_file, char* output_file)
|
static int encode_file(const char* input_file, const char* output_file)
|
||||||
{
|
{
|
||||||
grib_handle* source_handle = NULL;
|
grib_handle* source_handle = NULL;
|
||||||
const void* buffer = NULL;
|
const void* buffer = NULL;
|
||||||
|
|
|
@ -42,7 +42,7 @@ static void encode_decode(double* zval, const char* packingType, const int bitsP
|
||||||
GRIB_CHECK(grib_handle_delete(h), 0);
|
GRIB_CHECK(grib_handle_delete(h), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double calc_error(double* zval1, double* zval2)
|
static double calc_error(const double* zval1, const double* zval2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double zerr = 0;
|
double zerr = 0;
|
||||||
|
@ -55,7 +55,7 @@ static double calc_error(double* zval1, double* zval2)
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int bitsPerValue[11] = { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
|
const int bitsPerValue[11] = { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
|
||||||
int ipackingType, ibitsPerValue, ioptimizeScaleFactor;
|
int ipackingType, ibitsPerValue, ioptimizeScaleFactor;
|
||||||
|
|
||||||
for (ibitsPerValue = 0; ibitsPerValue < 11; ibitsPerValue++) {
|
for (ibitsPerValue = 0; ibitsPerValue < 11; ibitsPerValue++) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#include "grib_api.h"
|
#include "grib_api.h"
|
||||||
|
|
||||||
static void usage(char* prog)
|
static void usage(const char* prog)
|
||||||
{
|
{
|
||||||
printf("usage: %s infile\n", prog);
|
printf("usage: %s infile\n", prog);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -88,11 +88,11 @@ int main(int argc, char** argv)
|
||||||
parallel = 0;
|
parallel = 0;
|
||||||
}
|
}
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
printf("Running parallel in %ld threads. %ld iterations (prod=%ld)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION);
|
printf("Running parallel in %zu threads. %zu iterations (prod=%zu)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION);
|
||||||
printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write);
|
printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Running sequentially in %ld runs. %ld iterations\n", NUM_THREADS, FILES_PER_ITERATION);
|
printf("Running sequentially in %zu runs. %zu iterations\n", NUM_THREADS, FILES_PER_ITERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ void do_encode(void* ptr)
|
||||||
for (i = 0; i < FILES_PER_ITERATION; i++) {
|
for (i = 0; i < FILES_PER_ITERATION; i++) {
|
||||||
grib_handle* h = grib_handle_clone(hs);
|
grib_handle* h = grib_handle_clone(hs);
|
||||||
if (opt_write) {
|
if (opt_write) {
|
||||||
snprintf(output_file, 50, "output/output_file_%ld-%ld.grib", data->number, i);
|
snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i);
|
||||||
encode_values(h, output_file);
|
encode_values(h, output_file);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -160,6 +160,6 @@ void do_encode(void* ptr)
|
||||||
strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/
|
strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/
|
||||||
/* asctime_r(&result, stime); */
|
/* asctime_r(&result, stime); */
|
||||||
|
|
||||||
printf("%s: Worker %ld finished.\n", stime, data->number);
|
printf("%s: Worker %zu finished.\n", stime, data->number);
|
||||||
grib_handle_delete(hs);
|
grib_handle_delete(hs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ int opt_dump = 0; /* If 1 then dump handle to /dev/null */
|
||||||
int opt_clone = 0; /* If 1 then clone source handle */
|
int opt_clone = 0; /* If 1 then clone source handle */
|
||||||
int opt_write = 0; /* If 1 write handle to file */
|
int opt_write = 0; /* If 1 write handle to file */
|
||||||
|
|
||||||
static int encode_file(char* template_file, char* output_file)
|
static int encode_file(const char* template_file, const char* output_file)
|
||||||
{
|
{
|
||||||
FILE *in, *out = NULL;
|
FILE *in, *out = NULL;
|
||||||
grib_handle* source_handle = NULL;
|
grib_handle* source_handle = NULL;
|
||||||
|
@ -138,11 +138,11 @@ int main(int argc, char** argv)
|
||||||
parallel = 0;
|
parallel = 0;
|
||||||
}
|
}
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
printf("Running parallel in %ld threads. %ld iterations (prod=%ld)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION);
|
printf("Running parallel in %zu threads. %zu iterations (prod=%zu)\n", NUM_THREADS, FILES_PER_ITERATION, NUM_THREADS * FILES_PER_ITERATION);
|
||||||
printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write);
|
printf("Options: dump=%d, clone=%d, write=%d\n", opt_dump, opt_clone, opt_write);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Running sequentially in %ld runs. %ld iterations\n", NUM_THREADS, FILES_PER_ITERATION);
|
printf("Running sequentially in %zu runs. %zu iterations\n", NUM_THREADS, FILES_PER_ITERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -193,7 +193,7 @@ void do_stuff(void* ptr)
|
||||||
|
|
||||||
for (i = 0; i < FILES_PER_ITERATION; i++) {
|
for (i = 0; i < FILES_PER_ITERATION; i++) {
|
||||||
if (opt_write) {
|
if (opt_write) {
|
||||||
snprintf(output_file, 50, "output/output_file_%ld-%ld.grib", data->number, i);
|
snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i);
|
||||||
encode_file(INPUT_FILE, output_file);
|
encode_file(INPUT_FILE, output_file);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -206,5 +206,5 @@ void do_stuff(void* ptr)
|
||||||
strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/
|
strftime(stime, 32, "%H:%M:%S", &result); /* Try to get milliseconds here too*/
|
||||||
/* asctime_r(&result, stime); */
|
/* asctime_r(&result, stime); */
|
||||||
|
|
||||||
printf("%s: Worker %ld finished.\n", stime, data->number);
|
printf("%s: Worker %zu finished.\n", stime, data->number);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void usage(char* prog)
|
void usage(const char* prog)
|
||||||
{
|
{
|
||||||
printf("usage: %s filename\n", prog);
|
printf("usage: %s filename\n", prog);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -32,7 +32,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
if (argc != 2) usage(argv[0]);
|
if (argc != 2) usage(argv[0]);
|
||||||
|
|
||||||
printf("sizeof(off_t)=%d sizeof(long)=%d\n", sizeof(off_t), sizeof(long));
|
printf("sizeof(off_t)=%zu sizeof(long)=%zu\n", sizeof(off_t), sizeof(long));
|
||||||
|
|
||||||
f = fopen(argv[1], "r");
|
f = fopen(argv[1], "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
@ -50,7 +50,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
rsizeout = fread(str, 1, rsizein, f);
|
rsizeout = fread(str, 1, rsizein, f);
|
||||||
if (rsizeout != rsizein) {
|
if (rsizeout != rsizein) {
|
||||||
printf("rsizein=%d rsizeout=%d\n", rsizein, rsizeout);
|
printf("rsizein=%zu rsizeout=%zu\n", rsizein, rsizeout);
|
||||||
printf("end of file\n");
|
printf("end of file\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ void gribex_check(int err) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void usage(char* prog) {
|
void usage(const char* prog) {
|
||||||
printf("usage: %s [-a outfile | -w outfile ] grib_file repetitions bitsPerValue\n",prog);
|
printf("usage: %s [-a outfile | -w outfile ] grib_file repetitions bitsPerValue\n",prog);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue