Compiler warnings: use '%zu' in the format string for size_t

This commit is contained in:
Shahram Najm 2022-11-12 13:51:52 +00:00
parent 0644fdc346
commit 8abfafdbb0
2 changed files with 5 additions and 5 deletions

View File

@ -74,7 +74,7 @@ int main(int argc, char** argv)
return 1; return 1;
} }
if (strlen(str_code) != NUM_DESCRIPTOR_DIGITS) { if (strlen(str_code) != NUM_DESCRIPTOR_DIGITS) {
fprintf(stderr, "Error on line %zu: descriptor code '%s' (column 1) is not %lu digits.\n", fprintf(stderr, "Error on line %zu: descriptor code '%s' (column 1) is not %zu digits.\n",
line_number, str_code, NUM_DESCRIPTOR_DIGITS); line_number, str_code, NUM_DESCRIPTOR_DIGITS);
return 1; return 1;
} }
@ -90,13 +90,13 @@ int main(int argc, char** argv)
return 1; return 1;
} }
if (strlen(str_key) >= maxlen_keyName) { if (strlen(str_key) >= maxlen_keyName) {
fprintf(stderr, "Error on line %zu: descriptor key name '%s' (column 2) exceeds %lu characters.\n", fprintf(stderr, "Error on line %zu: descriptor key name '%s' (column 2) exceeds %zu characters.\n",
line_number, str_key, maxlen_keyName); line_number, str_key, maxlen_keyName);
return 1; return 1;
} }
str_units = list[4]; str_units = list[4];
if (strlen(str_units) >= maxlen_units) { if (strlen(str_units) >= maxlen_units) {
fprintf(stderr, "Error on line %lu: descriptor units '%s' (column 5) exceeds %lu characters.\n", fprintf(stderr, "Error on line %zu: descriptor units '%s' (column 5) exceeds %zu characters.\n",
line_number, str_units, maxlen_units); line_number, str_units, maxlen_units);
return 1; return 1;
} }

View File

@ -175,14 +175,14 @@ int main(int argc, char** argv)
Assert(num_all_vals == numberOfDataPoints); /*Sanity check*/ Assert(num_all_vals == numberOfDataPoints); /*Sanity check*/
GRIB_CHECK(grib_set_long(h, "bitmapPresent", 1), 0); GRIB_CHECK(grib_set_long(h, "bitmapPresent", 1), 0);
GRIB_CHECK(grib_set_double(h, "missingValue", missing), 0); GRIB_CHECK(grib_set_double(h, "missingValue", missing), 0);
printf("Fully specified: %ld values\n", num_all_vals); printf("Fully specified: %zu values\n", num_all_vals);
GRIB_CHECK(grib_set_double_array(h, "values", values, num_all_vals), 0); GRIB_CHECK(grib_set_double_array(h, "values", values, num_all_vals), 0);
} }
else { else {
const size_t num_coded_vals = sizeof(codedValues) / sizeof(codedValues[0]); const size_t num_coded_vals = sizeof(codedValues) / sizeof(codedValues[0]);
Assert(strcmp(mode, "coded_values") == 0); Assert(strcmp(mode, "coded_values") == 0);
Assert(num_coded_vals < numberOfDataPoints); /*Sanity check*/ Assert(num_coded_vals < numberOfDataPoints); /*Sanity check*/
printf("Partially specified: %ld values\n", num_coded_vals); printf("Partially specified: %zu values\n", num_coded_vals);
GRIB_CHECK(grib_set_force_double_array(h, "codedValues", codedValues, num_coded_vals), 0); GRIB_CHECK(grib_set_force_double_array(h, "codedValues", codedValues, num_coded_vals), 0);
} }