Skip to content

Commit 7ff5e2e

Browse files
committed
Tools: Dead code removal and cppcheck warnings
1 parent f5c4b5d commit 7ff5e2e

File tree

3 files changed

+17
-73
lines changed

3 files changed

+17
-73
lines changed

tools/grib_tools.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,16 +1339,15 @@ void grib_print_file_statistics(grib_runtime_options* options, grib_tools_file*
13391339
file->name);
13401340
if (!failed)
13411341
return;
1342-
/*
1343-
fprintf(dump_file,"Following bad messages found in %s\n", file->name);
1344-
fprintf(dump_file,"N Error\n");
1345-
while (failed){
1346-
fprintf(dump_file,"%-*d %s\n", 7,failed->count,
1347-
grib_get_error_message(failed->error));
1348-
failed=failed->next;
1349-
}
1350-
fprintf(dump_file,"\n");
1351-
*/
1342+
1343+
// fprintf(dump_file,"Following bad messages found in %s\n", file->name);
1344+
// fprintf(dump_file,"N Error\n");
1345+
// while (failed){
1346+
// fprintf(dump_file,"%-*d %s\n", 7,failed->count,
1347+
// grib_get_error_message(failed->error));
1348+
// failed=failed->next;
1349+
// }
1350+
// fprintf(dump_file,"\n");
13521351
}
13531352

13541353
void grib_print_full_statistics(grib_runtime_options* options)
@@ -1422,7 +1421,7 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h)
14221421
}
14231422

14241423
if (options->gts && h->gts_header) {
1425-
char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' };
1424+
const char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' };
14261425
if (fwrite(gts_trailer, 1, 4, of->handle) != 4) {
14271426
grib_context_log(h->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR),
14281427
"Error writing GTS trailer to %s", filename);

tools/gts_compare.cc

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,11 @@ static void save_error(grib_context* c, const char* key)
373373

374374
static int compare_values(const grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type)
375375
{
376-
size_t len1 = 0;
377-
size_t len2 = 0;
378-
int err = 0;
379-
int err1;
380-
int err2;
376+
size_t len1 = 0, len2 = 0;
377+
int err = 0, err1 = 0, err2 = 0;
381378
int type1, type2;
382379
int countdiff;
383-
int isMissing1 = 0, isMissing2 = 0;
380+
// int isMissing1 = 0, isMissing2 = 0;
384381

385382
char *sval1 = NULL, *sval2 = NULL;
386383
long *lval1 = NULL, *lval2 = NULL;
@@ -442,30 +439,6 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1,
442439
//isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0;
443440
//isMissing2 = ((grib_is_missing(h2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0;
444441

445-
if ((isMissing1 == 1) && (isMissing2 == 1)) {
446-
if (verbose)
447-
printf(" is set to missing in both fields\n");
448-
return GRIB_SUCCESS;
449-
}
450-
451-
if (isMissing1 == 1) {
452-
if (verbose) printf(" is set to missing in 1st field\n");
453-
printInfo(h1);
454-
printf("%s is set to missing in 1st field but is not missing in 2nd field\n", name);
455-
err1 = GRIB_VALUE_MISMATCH;
456-
save_error(c, name);
457-
return GRIB_VALUE_MISMATCH;
458-
}
459-
460-
if (isMissing2 == 1) {
461-
if (verbose) printf(" is set to missing in 1st field\n");
462-
printInfo(h1);
463-
printf("%s is set to missing in 2nd field but is not missing in 1st field\n", name);
464-
err1 = GRIB_VALUE_MISMATCH;
465-
save_error(c, name);
466-
return GRIB_VALUE_MISMATCH;
467-
}
468-
469442
switch (type1) {
470443
case GRIB_TYPE_STRING:
471444
if (verbose) printf(" as string\n");

tools/metar_compare.cc

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,17 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1,
426426
{
427427
size_t len1 = 0;
428428
size_t len2 = 0;
429-
int err = 0, i = 0;
430-
int err1;
431-
int err2;
429+
int err = 0, i = 0, err1 = 0, err2 = 0;
432430
int type1, type2;
433431
int countdiff;
434-
int isMissing1 = 0, isMissing2 = 0;
432+
//int isMissing1 = 0, isMissing2 = 0;
435433

436434
char *sval1 = NULL, *sval2 = NULL;
437435
double *dval1 = NULL, *dval2 = NULL;
438436
long *lval1 = NULL, *lval2 = NULL;
439-
double maxdiff = 0;
437+
double maxdiff = 0;
440438
double value_tolerance = 0;
441-
grib_context* c = h1->context;
439+
grib_context* c = h1->context;
442440

443441
type1 = type;
444442
type2 = type;
@@ -498,32 +496,6 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1,
498496
// isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0;
499497
// isMissing2 = ((grib_is_missing(h2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0;
500498

501-
if ((isMissing1 == 1) && (isMissing2 == 1)) {
502-
if (verbose)
503-
printf(" is set to missing in both fields\n");
504-
return GRIB_SUCCESS;
505-
}
506-
507-
if (isMissing1 == 1) {
508-
if (verbose)
509-
printf(" is set to missing in 1st field\n");
510-
printInfo(h1);
511-
printf("%s is set to missing in 1st field but is not missing in 2nd field\n", name);
512-
err1 = GRIB_VALUE_MISMATCH;
513-
save_error(c, name);
514-
return GRIB_VALUE_MISMATCH;
515-
}
516-
517-
if (isMissing2 == 1) {
518-
if (verbose)
519-
printf(" is set to missing in 1st field\n");
520-
printInfo(h1);
521-
printf("%s is set to missing in 2nd field but is not missing in 1st field\n", name);
522-
err1 = GRIB_VALUE_MISMATCH;
523-
save_error(c, name);
524-
return GRIB_VALUE_MISMATCH;
525-
}
526-
527499
switch (type1) {
528500
case GRIB_TYPE_STRING:
529501
if (verbose)

0 commit comments

Comments
 (0)