NOAA-OWP / evapotranspiration

Other
3 stars 9 forks source link

Fix warnings to support -Werror in Github CI #35

Closed PhilMiller closed 6 months ago

PhilMiller commented 6 months ago

Changes

Testing

  1. CI workflows

Screenshots

This is what I was getting in ngen's CI workflows. More turned up in the rest of the codebase here

/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c: In function ‘Initialize’:
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c:80:76: error: format ‘%e’ expects argument of type ‘double’, but argument 2 has type ‘long int’ [-Werror=format=]
   80 |             printf("the number of time steps from the forcing file is: %8.6e \n", pet->bmi.num_timesteps);
      |                                                                        ~~~~^      ~~~~~~~~~~~~~~~~~~~~~~
      |                                                                            |              |
      |                                                                            double         long int
      |                                                                        %8.6ld
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c: In function ‘Get_current_time’:
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c:517:45: error: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘double’ [-Werror=format=]
  517 |         printf("Current model time step: '%ld'\n", ((pet_model *) self->data)->bmi.current_time_step);
      |                                           ~~^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                             |                                     |
      |                                             long int                              double
      |                                           %f
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c: In function ‘read_init_config_pet’:
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c:763:26: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Werror=format=]
  763 |                 printf("%d\n", model->bmi.num_timesteps);
      |                         ~^     ~~~~~~~~~~~~~~~~~~~~~~~~
      |                          |               |
      |                          int             long int
      |                         %ld
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c:611:9: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
  611 |         fgets(config_line, max_config_line_length + 1, fp);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c: In function ‘Initialize’:
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c:77:9: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
   77 |         fgets(line_str, max_forcing_line_length + 1, ffp);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/ngen/ngen/extern/evapotranspiration/evapotranspiration/src/bmi_pet.c:84:13: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
   84 |             fgets(line_str, max_forcing_line_length + 1, ffp);  // read in a line of AORC data.
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Checklist

Testing checklist

Target Environment support

PhilMiller commented 6 months ago

@program-- Could you please have a look?

program-- commented 6 months ago

@madMatchstick @aaraney