mirror of https://github.com/ecmwf/eccodes.git
Tools: cppcheck warnings
This commit is contained in:
parent
766f4aeb63
commit
dbc044d828
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2005- ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
grib_handle* h = NULL;
|
||||
FILE* f = NULL;
|
||||
int i = 0;
|
||||
int err = 0;
|
||||
char* mode = "file";
|
||||
char name[80];
|
||||
char value[80];
|
||||
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
mode = argv[i] + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
f = fopen(argv[i], "r");
|
||||
if (!f) {
|
||||
perror(argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((h = grib_handle_new_from_file(0, f, &err)) != NULL) {
|
||||
grib_keys_iterator* ks = grib_keys_iterator_new(h, GRIB_KEYS_ITERATOR_ALL_KEYS, "mars");
|
||||
while (grib_keys_iterator_next(ks)) {
|
||||
size_t len = sizeof(value);
|
||||
char tmp[100];
|
||||
|
||||
strcpy(name, grib_keys_iterator_get_name(ks));
|
||||
|
||||
sprintf(tmp, "mars.%s", name);
|
||||
|
||||
if ((err = grib_keys_iterator_get_string(ks, value, &len)) != GRIB_SUCCESS)
|
||||
/* if(err = grib_get_string(h,tmp,value,&len)) */
|
||||
{
|
||||
fprintf(stderr, "Cannot get %s as string %d (%s)\n", name, err,
|
||||
grib_get_error_message(err));
|
||||
exit(err);
|
||||
}
|
||||
|
||||
printf("%s=%s\n", name, value);
|
||||
}
|
||||
grib_keys_iterator_delete(ks);
|
||||
printf("\n");
|
||||
|
||||
|
||||
grib_handle_delete(h);
|
||||
}
|
||||
fclose(f);
|
||||
if (err) {
|
||||
fprintf(stderr, "%s\n", grib_get_error_message(err));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -189,7 +189,7 @@ int grib_tool_before_getopt(grib_runtime_options* options)
|
|||
|
||||
int grib_tool_init(grib_runtime_options* options)
|
||||
{
|
||||
int ret = 0, i = 0;
|
||||
int ret = 0;
|
||||
int nfiles = 1;
|
||||
const char orderby[] = "md5Headers";
|
||||
grib_context* context = grib_context_get_default();
|
||||
|
@ -240,6 +240,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
}
|
||||
|
||||
if (grib_options_on("b:")) {
|
||||
int i;
|
||||
grib_string_list* next = 0;
|
||||
blocklist = (grib_string_list*)grib_context_malloc_clear(context, sizeof(grib_string_list));
|
||||
blocklist->value = grib_context_strdup(context, options->set_values[0].name);
|
||||
|
@ -281,6 +282,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
global_tolerance = 0;
|
||||
compare_double = &compare_double_absolute;
|
||||
if (grib_options_on("R:")) {
|
||||
int i;
|
||||
global_tolerance = 0;
|
||||
for (i = 0; i < options->tolerance_count; i++) {
|
||||
if (!strcmp((options->tolerance[i]).name, "all")) {
|
||||
|
@ -533,8 +535,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
|
|||
|
||||
while ((handle1 = grib_handle_new_from_file(c, options->infile_extra->file, &err))) {
|
||||
morein1++;
|
||||
if (handle1)
|
||||
grib_handle_delete(handle1);
|
||||
grib_handle_delete(handle1);
|
||||
}
|
||||
|
||||
error += morein1 + morein2;
|
||||
|
|
|
@ -202,7 +202,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
if (!first_handle && options->handle_count > 1) {
|
||||
fprintf(stdout, ",\n");
|
||||
}
|
||||
if (json && first_handle) {
|
||||
if (first_handle) {
|
||||
fprintf(stdout, "{ \"messages\" : [\n");
|
||||
first_handle = 0;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ int main(int argc, char** argv)
|
|||
char* fname = 0;
|
||||
float lat, lon;
|
||||
double *vlat, *vlon;
|
||||
int npoints = 0, i = 0, n = 0;
|
||||
long npoints = 0, i = 0, n = 0;
|
||||
grib_handle* h;
|
||||
double *outlats, *outlons, *values, *lsm_values, *distances;
|
||||
size_t* indexes;
|
||||
|
@ -53,42 +53,42 @@ int main(int argc, char** argv)
|
|||
|
||||
vlat = (double*)malloc(npoints * sizeof(double));
|
||||
if (!vlat) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
vlon = (double*)malloc(npoints * sizeof(double));
|
||||
if (!vlon) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
outlats = (double*)malloc(npoints * sizeof(double));
|
||||
if (!outlats) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
outlons = (double*)malloc(npoints * sizeof(double));
|
||||
if (!outlons) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
values = (double*)malloc(npoints * sizeof(double));
|
||||
if (!values) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
lsm_values = (double*)malloc(npoints * sizeof(double));
|
||||
if (!lsm_values) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
distances = (double*)malloc(npoints * sizeof(double));
|
||||
if (!distances) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
indexes = (size_t*)malloc(npoints * sizeof(double));
|
||||
if (!indexes) {
|
||||
printf("unable to allocate %d bytes\n", npoints * sizeof(double));
|
||||
printf("unable to allocate %lu bytes\n", npoints * sizeof(double));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue