diff --git a/src/action_class_list.cc b/src/action_class_list.cc index c9693a554..163a6da55 100644 --- a/src/action_class_list.cc +++ b/src/action_class_list.cc @@ -160,10 +160,10 @@ static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit) { grib_action_list* self = (grib_action_list*)a; - int ret = 0; long val = 0; - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val)) != GRIB_SUCCESS) { + int ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val); + if (ret != GRIB_SUCCESS) { grib_context_log(acc->context, GRIB_LOG_ERROR, "List %s creating %ld values: Unable to evaluate long", acc->name, val); } diff --git a/src/grib_accessor_class_concept.cc b/src/grib_accessor_class_concept.cc index c409a6f92..6fa4122f8 100644 --- a/src/grib_accessor_class_concept.cc +++ b/src/grib_accessor_class_concept.cc @@ -290,7 +290,6 @@ static int concept_conditions_expression_apply(grib_handle* h, grib_concept_cond break; default: return GRIB_NOT_IMPLEMENTED; - break; } (*n)++; return err; diff --git a/src/grib_accessor_class_data_g1simple_packing.cc b/src/grib_accessor_class_data_g1simple_packing.cc index 82c72c64c..cc810e4ae 100644 --- a/src/grib_accessor_class_data_g1simple_packing.cc +++ b/src/grib_accessor_class_data_g1simple_packing.cc @@ -245,7 +245,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) ret = grib_buffer_replace(a, NULL, 0, 1, 1); if (ret != GRIB_SUCCESS) return ret; return GRIB_SUCCESS; - break; + case GRIB_NO_VALUES: ret = grib_get_long(grib_handle_of_accessor(a), "constantFieldHalfByte", &constantFieldHalfByte); if (ret) @@ -262,7 +262,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) ret = grib_buffer_replace(a, NULL, 0, 1, 1); if (ret != GRIB_SUCCESS) return ret; return GRIB_SUCCESS; - break; + case GRIB_INVALID_BPV: grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to compute packing parameters. Invalid bits per value"); return ret; diff --git a/src/grib_accessor_class_data_jpeg2000_packing.cc b/src/grib_accessor_class_data_jpeg2000_packing.cc index b00160214..a1a43b6f7 100644 --- a/src/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/grib_accessor_class_data_jpeg2000_packing.cc @@ -389,7 +389,6 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) grib_buffer_replace(a, NULL, 0, 1, 1); err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len); return err; - break; case GRIB_SUCCESS: break; default: diff --git a/src/grib_accessor_class_data_raw_packing.cc b/src/grib_accessor_class_data_raw_packing.cc index 336c73684..27c3d62e3 100644 --- a/src/grib_accessor_class_data_raw_packing.cc +++ b/src/grib_accessor_class_data_raw_packing.cc @@ -164,7 +164,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) break; default: return GRIB_NOT_IMPLEMENTED; - break; } nvals = inlen / bytes; @@ -218,7 +217,6 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) default: code = GRIB_NOT_IMPLEMENTED; goto clean_up; - break; } bufsize = bytes * inlen; @@ -282,7 +280,6 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) default: return GRIB_NOT_IMPLEMENTED; - break; } pos = bytes * idx; diff --git a/src/grib_accessor_class_expanded_descriptors.cc b/src/grib_accessor_class_expanded_descriptors.cc index d57454996..11f4ba73b 100644 --- a/src/grib_accessor_class_expanded_descriptors.cc +++ b/src/grib_accessor_class_expanded_descriptors.cc @@ -786,7 +786,6 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) break; case 2: return GRIB_INVALID_TYPE; - break; case 3: for (i = 0; i < *len; i++) val[i] = self->expanded->v[i]->width; diff --git a/src/grib_accessor_class_g2_mars_labeling.cc b/src/grib_accessor_class_g2_mars_labeling.cc index f6437c279..ad0647e30 100644 --- a/src/grib_accessor_class_g2_mars_labeling.cc +++ b/src/grib_accessor_class_g2_mars_labeling.cc @@ -165,7 +165,6 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } return grib_get_long(grib_handle_of_accessor(a), key, val); @@ -190,7 +189,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } return grib_get_string(grib_handle_of_accessor(a), key, val, len); @@ -226,7 +224,6 @@ static int extra_set(grib_accessor* a, long val) case 0: /* class */ return ret; - break; case 1: /* type */ switch (val) { @@ -400,7 +397,6 @@ static int extra_set(grib_accessor* a, long val) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } if (productDefinitionTemplateNumberNew >= 0) { @@ -442,7 +438,6 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } ret = grib_set_string(grib_handle_of_accessor(a), key, val, len); @@ -476,7 +471,6 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } ret = grib_set_long(grib_handle_of_accessor(a), key, *val); @@ -513,7 +507,6 @@ static int get_native_type(grib_accessor* a) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } ret = grib_get_native_type(grib_handle_of_accessor(a), key, &type); diff --git a/src/grib_accessor_class_g2end_step.cc b/src/grib_accessor_class_g2end_step.cc index ed47e5133..a86733eb3 100644 --- a/src/grib_accessor_class_g2end_step.cc +++ b/src/grib_accessor_class_g2end_step.cc @@ -460,19 +460,17 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) try { if (numberOfTimeRange == 1) { ret = unpack_one_time_range_long_(a, val, len); - return ret; } else { ret = unpack_multiple_time_ranges_long_(a, val, len); - return ret; } } catch (std::exception& e) { grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_long: %s", e.what()); - return GRIB_DECODING_ERROR; + ret = GRIB_DECODING_ERROR; } - return GRIB_SUCCESS; + return ret; } static int unpack_double(grib_accessor* a, double* val, size_t* len) @@ -500,19 +498,17 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) try { if (numberOfTimeRange == 1) { ret = unpack_one_time_range_double_(a, val, len); - return ret; } else { ret = unpack_multiple_time_ranges_double_(a, val, len); - return ret; } } catch (std::exception& e) { grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_double: %s", e.what()); - return GRIB_DECODING_ERROR; + ret = GRIB_DECODING_ERROR; } - return GRIB_SUCCESS; + return ret; } static int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit) diff --git a/src/grib_accessor_class_long.cc b/src/grib_accessor_class_long.cc index aeccdac78..5eb10fec5 100644 --- a/src/grib_accessor_class_long.cc +++ b/src/grib_accessor_class_long.cc @@ -116,18 +116,15 @@ static void dump(grib_accessor* a, grib_dumper* dumper) static int unpack_string(grib_accessor* a, char* v, size_t* len) { - int err = 0; long val = 0; size_t l = 1; char repres[1024]; char format[32] = "%ld"; grib_handle* h = grib_handle_of_accessor(a); - err = grib_unpack_long(a, &val, &l); + grib_unpack_long(a, &val, &l); /* TODO: We should catch all errors but in this case the test ERA_Gen.sh will fail * as the output from grib_ls will be different */ - /* if (err) return err; */ - (void)err; if ((val == GRIB_MISSING_LONG) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { snprintf(repres, sizeof(repres), "MISSING"); diff --git a/src/grib_expression_class_is_integer.cc b/src/grib_expression_class_is_integer.cc index e79f6c32c..da81cc4cb 100644 --- a/src/grib_expression_class_is_integer.cc +++ b/src/grib_expression_class_is_integer.cc @@ -92,7 +92,6 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result) char mybuf[1024] = {0,}; size_t size = 1024; char* p = 0; - long val = 0; char* start = 0; if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) @@ -103,14 +102,13 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result) if (e->length > 0) start[e->length] = 0; - val = strtol(start, &p, 10); + strtol(start, &p, 10); if (*p != 0) *result = 0; else *result = 1; - (void)val; return err; } diff --git a/src/grib_io.cc b/src/grib_io.cc index b20dbce7b..e6d2d03d2 100644 --- a/src/grib_io.cc +++ b/src/grib_io.cc @@ -1232,12 +1232,12 @@ int wmo_read_bufr_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset) int wmo_read_gts_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset) { //TODO(masn): Needs proper implementation; no malloc - unsigned char buffer[1024] = {0,}; + //unsigned char buffer[1024] = {0,}; void* mesg = NULL; int err = GRIB_SUCCESS; grib_context* c = grib_context_get_default(); - *msg_len = sizeof(buffer); + *msg_len = 1024; // sizeof(buffer) mesg = wmo_read_gts_from_file_malloc(f, 0, msg_len, msg_offset, &err); grib_context_free(c, mesg); return err; @@ -1339,7 +1339,7 @@ static size_t stream_read(void* data, void* buffer, size_t len, int* err) if (len > LONG_MAX) { /* size_t cannot be coded into long */ *err = GRIB_INTERNAL_ERROR; - return -1; + return 0; } n = s->stream_proc(s->stream_data, buffer, len); diff --git a/src/grib_loader_from_handle.cc b/src/grib_loader_from_handle.cc index cd5ae8513..a423c31cc 100644 --- a/src/grib_loader_from_handle.cc +++ b/src/grib_loader_from_handle.cc @@ -24,16 +24,13 @@ static int copy_values(grib_handle* h, grib_accessor* ga) switch (h->values[j][i].type) { case GRIB_TYPE_LONG: return grib_pack_long(ga, &h->values[j][i].long_value, &len); - break; case GRIB_TYPE_DOUBLE: return grib_pack_double(ga, &h->values[j][i].double_value, &len); - break; case GRIB_TYPE_STRING: len = strlen(h->values[j][i].string_value); return grib_pack_string(ga, h->values[j][i].string_value, &len); - break; } } } diff --git a/src/grib_parse_utils.cc b/src/grib_parse_utils.cc index 2fb771cb7..1d014995c 100644 --- a/src/grib_parse_utils.cc +++ b/src/grib_parse_utils.cc @@ -872,19 +872,14 @@ int grib_type_to_int(char id) switch (id) { case 'd': return GRIB_TYPE_DOUBLE; - break; case 'f': return GRIB_TYPE_DOUBLE; - break; case 'l': return GRIB_TYPE_LONG; - break; case 'i': return GRIB_TYPE_LONG; - break; case 's': return GRIB_TYPE_STRING; - break; } return GRIB_TYPE_UNDEFINED; } diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index 3fa715669..11f0e9dc7 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -84,7 +84,6 @@ static int compare_attribute(grib_handle* handle1, grib_handle* handle2, grib_ru static int error = 0; static int count = 0; -static int lastPrint = 0; static int force = 0; /* ECC-651: Boolean 'two_way' set to 1 when '-2' option used */ @@ -379,7 +378,6 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi static void printInfo(grib_handle* h) { printf("== %d == DIFFERENCE == ", count); - lastPrint = count; } static void print_index_key_values(grib_index* index, int icounter, const char* error_message) diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index 9133b3435..2f570c61c 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -74,7 +74,6 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option int error = 0; int count = 0; -int lastPrint = 0; int force = 0; double maxAbsoluteError = 1e-19; int onlyListed = 1; @@ -245,7 +244,6 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi static void printInfo(grib_handle* h) { printf("== %d == DIFFERENCE == ", count); - lastPrint = count; } static grib_handle* gts_handle_new_from_file_x( diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index e4318bd44..258a09024 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -74,7 +74,6 @@ static int compareAbsolute = 1; static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_options* options); static int error = 0; static int count = 0; -static int lastPrint = 0; static int force = 0; static double maxAbsoluteError = 1e-19; static int onlyListed = 1; @@ -306,7 +305,6 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi static void printInfo(grib_handle* h) { printf("== %d == DIFFERENCE == ", count); - lastPrint = count; } static grib_handle* metar_handle_new_from_file_x(grib_context* c, FILE* f, int mode, int headers_only, int* err)