PCMDI / cmor

Climate Model Output Rewriter
BSD 3-Clause "New" or "Revised" License
53 stars 32 forks source link

Numerous warnings when compiling CMOR #602

Open mauzey1 opened 4 years ago

mauzey1 commented 4 years ago

When CMOR is built using make, the C compiler will output many warnings. A lot of them are related to snprintf, which is due to the destination string potentially being not long enough to store the entire string being generated.

Src/cmor_CV.c: In function 'cmor_CV_checkExperiment':
Src/cmor_CV.c:1473:58: warning: '%s' directive output may be truncated writing up to 1023 bytes into a region of size 1002 [-Wformat-truncation=]
                                  "Your input attribute \"%s\" with value \n! \"%s\" "
                                                          ^~

Some are due to comparisons between different data types.

Src/cmor.c: In function 'cmor_pop_traceback':
Src/cmor.c:434:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < strlen(cmor_traceback_info); i++) {
                   ^

Some are due to function declarations that should be prototypes in the header files. Functions that don't have parameters should be declared with (void) instead of ().

In file included from ./include/cmor.h:578:0,
                 from Src/cmor_variables.c:4:
./include/cmor_func_def.h:15:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
 extern void cmor_set_terminate_signal_to_sigint();
 ^~~~~~

Although we could suppress these warning messages, it would be better to fix these issues in the code.

taylor13 commented 4 years ago

Yes, I agree it would be best to "fix" these, but suggest this might not be a high priority. Thanks for opening the issue.

durack1 commented 7 months ago

@mauzey1 it would be useful to gauge what "easy" fixes can be incorporated for the CMOR 3.9.0 planned release