Examples: cppcheck warnings

This commit is contained in:
Shahram Najm 2021-11-30 13:27:22 +00:00
parent 1631acfa9f
commit 17cf9edcd4
6 changed files with 11 additions and 4 deletions

View File

@ -62,6 +62,7 @@ int main(int argc, char** argv)
h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
if (h == NULL) {
fprintf(stderr, "Error: unable to create handle from file %s\n", infile);
fclose(out);
return 1;
}

View File

@ -52,6 +52,7 @@ int main(int argc, char** argv)
h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
if (h == NULL) {
fprintf(stderr, "Error: unable to create handle from file %s\n", infile);
fclose(out);
return 1;
}

View File

@ -53,6 +53,7 @@ int main(int argc, char** argv)
h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
if (h == NULL) {
fprintf(stderr, "Error: unable to create handle from file %s\n", infile);
fclose(out);
return 1;
}

View File

@ -47,10 +47,11 @@ int main(int argc, char** argv)
return 1;
}
/* create a new handle from a message in a file */
/* create a new GRIB handle from a message in a file */
h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
if (h == NULL) {
fprintf(stderr, "Error: unable to create handle from file %s\n", infile);
fclose(out);
return 1;
}

View File

@ -61,6 +61,7 @@ int main(int argc, char** argv)
h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
if (h == NULL) {
fprintf(stderr, "Error: unable to create handle from file %s\n", infile);
fclose(out);
return 1;
}

View File

@ -17,15 +17,17 @@ int main()
{
const int ni = 2880;
const int nj = 2880;
size_t numbytes = 0;
double* values;
int i = 0;
codes_handle* h = NULL;
const char* filename = "bigfile.grib";
values = (double*)malloc(ni * nj * sizeof(double));
numbytes = ni * nj * sizeof(double);
values = (double*)malloc(numbytes);
if (!values) {
printf("Malloc failed - requested %lu bytes\n", ni * nj * sizeof(double));
exit(1);
printf("Malloc failed - requested %lu bytes\n", (unsigned long)numbytes);
return 1;
}
for (i = 0; i < ni * nj; i++) {