Skip to content

Conversation

@jimklimov
Copy link
Member

@jimklimov jimklimov commented Jan 14, 2022

Got this to build; usability not tested so far (nutconf --help does not crash at least)

C++ style there needs several patterns of face-lift:

g++ -DHAVE_CONFIG_H -I. -I../../include    -I../../include -I../../include -DWITH_NUTSCANNER -I../../tools/nut-scanner -g -O2 -Wno-error -MT nutconf-nutconf.o -MD -MP -MF .deps/nutconf-nutconf.Tpo -c -o nutconf-nutconf.o `test -f 'nutconf.cpp' || echo './'`nutconf.cpp
In file included from ../../include/nutconf.h:24,
                 from nutconf.cpp:26:
../../include/nutstream.hpp:232:24: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
  232 |  std::string tmpName() throw(std::runtime_error);
      |                        ^~~~~
In file included from nutconf.cpp:26:
../../include/nutconf.h: In instantiation of 'nut::Settable<Type>& nut::Settable<Type>::operator=(const Type&) [with Type = nut::NutConfiguration::NutMode]':
nutconf.cpp:2085:63:   required from here
../../include/nutconf.h:72:71: warning: no return statement in function returning non-void [-Wreturn-type]
   72 |  Settable<Type>& operator=(const Type& val){_value = val; _set = true;}
      |                                                                       ^
      |                                                                       return *this;

Historic note: effort is related to upstream-NUT feature not merged yet, with networkupstools#6 for context

@jimklimov jimklimov requested a review from aquette January 14, 2022 15:07
@jimklimov jimklimov force-pushed the FTY-contrib-scripts branch from 6c3e82f to c181a4d Compare January 14, 2022 21:24
@jimklimov
Copy link
Member Author

jimklimov commented Jan 15, 2022

Coverage also complains about C++ quality (probably needs to be at least quiesced before PR merge, at best actually solved, to not block builds):

...b_nut_PR-161/tmp/build-coverity/common/nutipc.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "135",
      "lineEnd": "167",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::Process::Executor::operator ()()</b> an exception of type <b>std::runtime_error</b> is thrown and never caught. <i>(line 135)</i><br>exception_thrown: An exception of type <b>std::runtime_error</b> is thrown. <i>(line 167)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "735",
      "lineEnd": "737",
      "message": "A C++ exception is thrown but never caught",
      "description": "exn_spec_violation: An exception of type <b>std::runtime_error</b> is thrown but the throw list <b>noexcept</b> doesn't allow it to be thrown. This will cause a call to unexpected() which usually calls terminate(). <i>(line 735)</i><br>fun_call_w_exception: Called function throws an exception of type <b>std::runtime_error</b>. <i>(line 737)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "453",
      "lineEnd": "471",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutSocket::Address::Address(std::vector<unsigned char, std::allocator<unsigned char> > const &, uint16_t)</b> an exception of type <b>std::logic_error</b> is thrown and never caught. <i>(line 453)</i><br>exception_thrown: An exception of type <b>std::logic_error</b> is thrown. <i>(line 471)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "616",
      "lineEnd": "652",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutSocket::accept(nut::NutSocket &, nut::NutSocket const &, int &, std::string &)</b> an exception of type <b>std::logic_error</b> is thrown and never caught. <i>(line 616)</i><br>exception_thrown: An exception of type <b>std::logic_error</b> is thrown. <i>(line 652)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "564",
      "lineEnd": "601",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>_ZNK3nut9NutSocket7Address3strB5cxx11Ev() const</b> an exception of type <b>std::logic_error</b> is thrown and never caught. <i>(line 564)</i><br>exception_thrown: An exception of type <b>std::logic_error</b> is thrown. <i>(line 601)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "93",
      "lineEnd": "106",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutFile::NutFile(nut::NutFile::anonymous_t)</b> an exception of type <b>std::runtime_error</b> is thrown and never caught. <i>(line 93)</i><br>exception_thrown: An exception of type <b>std::runtime_error</b> is thrown. <i>(line 106)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "656",
      "lineEnd": "675",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutSocket::NutSocket(nut::NutSocket::domain_t, nut::NutSocket::type_t, nut::NutSocket::proto_t)</b> an exception of type <b>std::runtime_error</b> is thrown and never caught. <i>(line 656)</i><br>exception_thrown: An exception of type <b>std::runtime_error</b> is thrown. <i>(line 675)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "230",
      "lineEnd": "231",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutFile::NutFile(nut::NutFile::access_t)</b> an exception of type <b>std::runtime_error</b> is thrown and never caught. <i>(line 230)</i><br>fun_call_w_exception: Called function throws an exception of type <b>std::runtime_error</b>. <i>(line 231)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutstream.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "230",
      "lineEnd": "236",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutFile::NutFile(nut::NutFile::access_t)</b> an exception of type <b>std::runtime_error</b> is thrown and never caught. <i>(line 230)</i><br>fun_call_w_exception: Called function throws an exception of type <b>std::runtime_error</b>. <i>(line 236)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutipc.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "247",
      "lineEnd": "256",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutSignal::send(nut::Signal::enum_t, std::string const &)</b> an exception of type <b>std::logic_error</b> is thrown and never caught. <i>(line 247)</i><br>fun_call_w_exception: Called function throws an exception of type <b>std::logic_error</b>. <i>(line 256)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutipc.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "247",
      "lineEnd": "256",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::NutSignal::send(nut::Signal::enum_t, std::string const &)</b> an exception of type <b>std::runtime_error</b> is thrown and never caught. <i>(line 247)</i><br>fun_call_w_exception: Called function throws an exception of type <b>std::runtime_error</b>. <i>(line 256)</i><br><i>For more information look at Coverity Portal</i>"
    },
    {
      "fileName": "/dev/shm/jenkins-swarm-client/workspace/42ity-github_nut_PR-161/tmp/build-coverity/common/nutwriter.cpp",
      "type": "Uncaught exception (UNCAUGHT_EXCEPTION)",
      "category": "Error handling issues",
      "severity": "NORMAL",
      "lineStart": "126",
      "lineEnd": "130",
      "message": "A C++ exception is thrown but never caught",
      "description": "root_function: In function <b>nut::SectionlessConfigWriter::writeSectionName(std::string const &)</b> an exception of type <b>std::logic_error</b> is thrown and never caught. <i>(line 126)</i><br>exception_thrown: An exception of type <b>std::logic_error</b> is thrown. <i>(line 130)</i><br><i>For more information look at Coverity Portal</i>"
    }
  ]
}

Overall:

Defect occurrences found       : 84 Total
                                  3 CHECKED_RETURN
                                  9 CONSTANT_EXPRESSION_RESULT
                                  3 DEADCODE
                                  1 DELETE_ARRAY
                                  2 FORWARD_NULL
                                  1 NEGATIVE_RETURNS
                                  1 NESTING_INDENT_MISMATCH
                                 16 NULL_RETURNS
                                  1 PATH_MANIPULATION
                                  2 PW.DECLARED_BUT_NOT_REFERENCED
                                  1 PW.NON_CONST_PRINTF_FORMAT_STRING
                                  4 PW.SET_BUT_NOT_USED
                                 10 RESOURCE_LEAK
                                  3 SECURE_CODING
                                  2 SECURE_TEMP
                                 13 UNCAUGHT_EXCEPT
                                  2 UNINIT
                                  9 UNINIT_CTOR
                                  1 UNUSED_VALUE

@jimklimov jimklimov marked this pull request as draft January 15, 2022 10:21
@jimklimov jimklimov force-pushed the FTY-contrib-scripts branch from 2cfeaa5 to a43b1bb Compare January 15, 2022 12:11
@jimklimov jimklimov marked this pull request as ready for review January 15, 2022 13:29
@jimklimov
Copy link
Member Author

For now, neutered this by ./configure --with-nutconf required to enable the feature (and currently - grievances for static analysis), so by default this PR does not affect CI builds and packaging.

@jimklimov
Copy link
Member Author

Note: the build failures are reported by upstream NUT CI farm check of this PR, since the codebase is not clean enough to pass the "medium" warnings level yet. IPM2 farm is more relaxed and has no qualms with this submission.

...and of IPSS_Unix installer/helper scripts
@jimklimov jimklimov force-pushed the FTY-contrib-scripts branch from fed7ec2 to 169d3c5 Compare January 17, 2022 13:03
@jimklimov jimklimov merged commit 4cac998 into 42ity:FTY Jan 19, 2022
@jimklimov jimklimov deleted the FTY-contrib-scripts branch January 19, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants