Fix compiler warnings

This commit is contained in:
Shahram Najm 2024-01-23 14:50:27 +00:00
parent ce72f44c17
commit 44adab0569
3 changed files with 14 additions and 4 deletions

View File

@ -280,12 +280,13 @@ grib_handle* codes_bufr_handle_new_from_samples(grib_context* c, const char* nam
} }
g = codes_external_template(c, PRODUCT_BUFR, name); g = codes_external_template(c, PRODUCT_BUFR, name);
if (!g) if (!g) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"Unable to load BUFR sample file '%s.tmpl'\n" "Unable to load BUFR sample file '%s.tmpl'\n"
" from %s\n" " from %s\n"
" (ecCodes Version=%s)", " (ecCodes Version=%s)",
name, c->grib_samples_path, ECCODES_VERSION_STR); name, c->grib_samples_path, ECCODES_VERSION_STR);
}
return g; return g;
} }

View File

@ -25,6 +25,10 @@ int main(int argc, char** argv)
assert(argc == 2); assert(argc == 2);
outfilename = argv[1]; outfilename = argv[1];
// Test non-existent sample file. Should fail
h = codes_bufr_handle_new_from_samples(NULL, "some rubbish");
assert(!h);
h = codes_bufr_handle_new_from_samples(NULL, sampleName); h = codes_bufr_handle_new_from_samples(NULL, sampleName);
assert(h); assert(h);

View File

@ -7,7 +7,12 @@
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by * 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. * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/ */
#include <stdio.h>
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
#include "eccodes.h" #include "eccodes.h"
@ -24,7 +29,7 @@ int main(int argc, char* argv[])
assert (argc == 3); assert (argc == 3);
printf("%ld\n", codes_get_api_version()); cout << codes_get_api_version() << endl;
in = fopen(argv[1], "rb"); in = fopen(argv[1], "rb");
assert(in); assert(in);
@ -33,7 +38,7 @@ int main(int argc, char* argv[])
assert(source_handle); assert(source_handle);
CODES_CHECK(codes_get_message_offset(source_handle, &offset), 0); CODES_CHECK(codes_get_message_offset(source_handle, &offset), 0);
printf("offset = %lld\n", offset); cout << "offset = "<< offset << endl;
// How big is the input GRIB message? // How big is the input GRIB message?
CODES_CHECK(codes_get_message_size(source_handle, &totalLength), 0); CODES_CHECK(codes_get_message_size(source_handle, &totalLength), 0);