Skip to content

Fix compiler warnings

Hy Murveit requested to merge murveit/kstars:cleanup2 into master

No functional changes. I went through and dealt with almost all compiler warnings I saw when compiling KStars from scratch on Ubuntu.

I started with 52 compiler warnings, and got it down to 2!

2 warnings left I wasn't sure how to deal with:

/home/hy/Projects/kstars/kstars/kstarsdata.cpp:70:6: warning: ‘bool {anonymous}::nonFatalErrorMessage(QString)’ defined but not used [-Wunused-function]
   70 | bool nonFatalErrorMessage(QString fname)

I could remove the above unused function. I left it in.

/home/hy/Projects/kstars-build/kstars/Options.cpp: In constructor ‘Options::Options()’:
/home/hy/Projects/kstars-build/kstars/Options.cpp:29:1: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
   29 | Options::Options( )

Not sure how to deal with the above one.

Main thing to review:

In CMakeLists.txt, I disabled a warning with -Wno-stringops-truncation, as we violated this 28 times in our code. IMHO we either disable the warning or modify the 28 uses of strncpy.

IF (UNIX OR APPLE)
    ...
    # Omit problematic warnings
    IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
        ...
        SET(COMP_FLAGS "${COMP_FLAGS} -Wno-stringop-truncation")

Please double check the way I added the compiler flag, as I could only test on my machine. Wasn't sure about the need for CMAKE_CXX_COMPILER_ID STREQUAL "GNU", or if I needed to add other restrictions.

Edited by Hy Murveit

Merge request reports

Loading