Skip to content

Fightwarn - implicit int/long/float/double manipulations #1648

Open

Description

@jimklimov

Per NUT CI farm "fightwarn" branch builds, currently (as of v2.8.0-Windows tag) we still have a lot of "hard" level warnings to tackle, primarily exposed by builds with clang (those from gcc seem to come from openbsd-6.5 builds with gcc-4.2.1 that does not understand pragmas to hush warnings around our range-checks that ensure portability).

Single-tool slice of the analysis at https://ci.networkupstools.org/job/nut/job/nut/job/fightwarn/71/analysis/origin.508244455/# says:

Category Total
-Werror,-Wdouble-promotion 198
-Werror,-Wfloat-conversion 44
-Werror,-Wimplicit-float-conversion 566
-Werror,-Wimplicit-int-conversion 16
-Werror,-Wimplicit-int-float-conversion 86
-Werror,-Wshorten-64-to-32 6
-Werror,-Wsign-conversion 15
Total 931

Many of those fall into a few categories, like:

  • initialization of a floating-point number from a literal without a type modifier (a few files with large tables make up most of these warnings; maybe a hush pragma around such tables would be more maintainable than adding "F" suffix to each float number... probably no need to change them into double's which can also tank performance on some platforms for no gain in NUT case)
  • maths and assignments between variables of different types without casting
  • more worrysome of those may be those with:
    • signedness change, e.g. implicit conversion changes signedness: 'int' to '__uid_t' (aka 'unsigned int') or implicit conversion changes signedness: 'int' to 'unsigned long'
    • and integer size change: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'

Obligatory link to #823 to track the fightwarn effort, whose "reasonable" scope was achieved some time ago.

Activity

  1. added
    refactor/fightwarnPR or issue proposal to improve code maintainability without functional changes, or to fix warnings
    on Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactor/fightwarnPR or issue proposal to improve code maintainability without functional changes, or to fix warnings

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions