From 76c1e3f2b650c91117812f1876f7496095f27bea Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 2 Jun 2022 15:06:01 +0100 Subject: [PATCH] Clang++ -fsanitize=undefined: Fix invalid code table entries --- definitions/grib3/template.3.110.def | 2 +- definitions/grib3/template.3.140.def | 2 +- definitions/grib3/template.3.20.def | 2 +- definitions/grib3/template.3.resolution_flags.def | 2 +- definitions/grib3/template.4.resolution_flags.def | 2 +- src/grib_accessor_class_codeflag.c | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/definitions/grib3/template.3.110.def b/definitions/grib3/template.3.110.def index 419736fb2..5ad2db7a6 100644 --- a/definitions/grib3/template.3.110.def +++ b/definitions/grib3/template.3.110.def @@ -21,7 +21,7 @@ unsigned[4] longitudeOfTangencyPoint : dump ; alias Lo1 = longitudeOfTangencyPoint; # Resolution and component flag -flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/3.3.table' : dump ; +flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/4.1.table' : dump ; # Dx - X-direction grid length in units of 10 -3 m as measured at the point of the axis unsigned[4] Dx : dump ; diff --git a/definitions/grib3/template.3.140.def b/definitions/grib3/template.3.140.def index 0b15856b6..d049fa5ea 100644 --- a/definitions/grib3/template.3.140.def +++ b/definitions/grib3/template.3.140.def @@ -33,7 +33,7 @@ signed[4] centralLongitudeInMicrodegrees : dump; alias centralLongitude=centralLongitudeInMicrodegrees; # Resolution and component flag -flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/3.3.table' : dump ; +flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/4.1.table' : dump ; # Dx - X-direction grid length in millimetres unsigned[4] xDirectionGridLengthInMillimetres : dump ; diff --git a/definitions/grib3/template.3.20.def b/definitions/grib3/template.3.20.def index fa805f82d..1495b6005 100644 --- a/definitions/grib3/template.3.20.def +++ b/definitions/grib3/template.3.20.def @@ -29,7 +29,7 @@ meta geography.longitudeOfFirstGridPointInDegrees scale(longitudeOfFirstGridPoin alias Lo1 = longitudeOfFirstGridPoint; # Resolution and component flag -flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/3.3.table' : dump; +flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/4.1.table' : dump; # LaD - Latitude where Dx and Dy are specified signed[4] LaD : edition_specific; diff --git a/definitions/grib3/template.3.resolution_flags.def b/definitions/grib3/template.3.resolution_flags.def index 759ad5d0e..8968cf4a2 100644 --- a/definitions/grib3/template.3.resolution_flags.def +++ b/definitions/grib3/template.3.resolution_flags.def @@ -1,7 +1,7 @@ # (C) Copyright 2005- ECMWF. # Resolution and component flags -flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/3.3.table' : edition_specific,no_copy; +flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/4.1.table' : edition_specific,no_copy; # Note our flagbit numbers run from 7 to 0, while WMO convention uses 1 to 8 # (most significant to least significant) diff --git a/definitions/grib3/template.4.resolution_flags.def b/definitions/grib3/template.4.resolution_flags.def index 759ad5d0e..8968cf4a2 100644 --- a/definitions/grib3/template.4.resolution_flags.def +++ b/definitions/grib3/template.4.resolution_flags.def @@ -1,7 +1,7 @@ # (C) Copyright 2005- ECMWF. # Resolution and component flags -flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/3.3.table' : edition_specific,no_copy; +flags[1] resolutionAndComponentFlags 'grib3/tables/[tablesVersion]/4.1.table' : edition_specific,no_copy; # Note our flagbit numbers run from 7 to 0, while WMO convention uses 1 to 8 # (most significant to least significant) diff --git a/src/grib_accessor_class_codeflag.c b/src/grib_accessor_class_codeflag.c index b9f1d35cd..9d8c3ded6 100644 --- a/src/grib_accessor_class_codeflag.c +++ b/src/grib_accessor_class_codeflag.c @@ -148,6 +148,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* param) static int test_bit(long a, long b) { + DebugAssert(b>=0); return a & (1 << b); }