1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-25 20:16:00 +00:00

some minor c++11 and -Weverything code updates

- use `nullptr` instead of plain '0'
- use `[[noreturn]]` (clang -Wmissing-noreturn)
- drop never reached returns (clang -Wunreachable-code-return)
- drop `throw()` lists, use `noexcept` (clang -Wdeprecated)
- add `R*_Init` prototypes (clang -Wmissing-prototypes)
- Rw11VirtEthTap.cpp: BUGFIX: buffer not null terminated (coverity)
This commit is contained in:
wfjm
2018-10-28 12:19:19 +01:00
parent 86380fc2c6
commit 2a50d35e71
14 changed files with 50 additions and 36 deletions

View File

@@ -64,20 +64,26 @@ The full set of tests is only run for tagged releases.
- sys_w11a_*.vhd: use DM_STAT_EXP; IDEC to maxisys; setup PERFEXT
- RtclRw11Unit: fix for clang: M_virt() now public
- backend code review:
- use for C++ compiles also `-Wpedantic`
- use for C++ compiles `-Wpedantic` (in addition to `-Wall` and `-Wextra`)
- fixes for uninitialized variables (coverity, all uncritical)
- catch exceptions in dtors (coverity, use Catch2Cerr)
- use `nullptr` instead of plain '0'
- use `[[noreturn]]` (clang -Wmissing-noreturn)
- drop never reached returns (clang -Wunreachable-code-return)
- drop `throw()` lists, use `noexcept` (clang -Wdeprecated)
- add `R*_Init` prototypes (clang -Wmissing-prototypes)
- now -Wunused-parameter clean (comment out unused params)
- now -Wunused-variable clean (comment out so far unused code)
- move `using namespace std` after includes (clang warning)
- some selected clang -Weverything aspects
- now -Wdocumentation clean (some wrong doxygen trailing comments)
- now -Wdocumentation clean (some wrong doxygen trailing comments)
### Bug Fixes
- RtclArgs.hpp: BUGFIX: get *_min limits correct (gcc -Wpedantic)
- RtclArgs.cpp: BUGFIX: GetArg(): argument in wrong order (coverity)
- Rw11CntlDEUNA.cpp: BUGFIX: SetMacDefault(): resource leak (coverity)
- Rw11VirtDiskFile.cpp: BUGFIX: Open(): resource leak (coverity)
- Rw11VirtEthTap.cpp: BUGFIX: buffer not null terminated (coverity)
- Rw11VirtTapeTap.cpp:
- BUGFIX: Open(): resource leak (coverity)
- BUGFIX: Rewind(): bad constant expression (coverity)

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommand.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RlinkCommand.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -240,7 +240,7 @@ void RlinkCommand::SetBlockRead(size_t size)
void RlinkCommand::SetBlockExt(uint16_t* pblock, size_t size)
{
if (pblock == 0)
if (pblock == nullptr)
throw Rexception("RlinkCommand::SetBlockExt()",
"Bad args: pblock is null");
if (size == 0 || size > 65535)

View File

@@ -1,4 +1,4 @@
// $Id: RlinkPortCuff.cpp 1059 2018-10-27 10:34:16Z mueller $
// $Id: RlinkPortCuff.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2012-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -509,6 +509,7 @@ bool RlinkPortCuff::TraceOn()
//------------------------------------------+-----------------------------------
//! FIXME_docs
[[noreturn]]
void RlinkPortCuff::BadSysCall(const char* meth, const char* text, int rc)
{
stringstream ss;
@@ -520,6 +521,7 @@ void RlinkPortCuff::BadSysCall(const char* meth, const char* text, int rc)
//------------------------------------------+-----------------------------------
//! FIXME_docs
[[noreturn]]
void RlinkPortCuff::BadUSBCall(const char* meth, const char* text, int rc)
{
stringstream ss;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPortCuff.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RlinkPortCuff.hpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2012-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2012-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -91,8 +91,8 @@ namespace Retro {
void DriverEventUSB();
libusb_transfer* NewWriteTransfer();
bool TraceOn();
void BadSysCall(const char* meth, const char* text, int rc);
void BadUSBCall(const char* meth, const char* text, int rc);
[[noreturn]] void BadSysCall(const char* meth, const char* text, int rc);
[[noreturn]] void BadUSBCall(const char* meth, const char* text, int rc);
void CheckUSBTransfer(const char* meth, libusb_transfer *t);
const char* USBErrorName(int rc);

View File

@@ -1,6 +1,6 @@
// $Id: Rlinktpp_Init.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rlinktpp_Init.cpp 1061 2018-10-27 17:39:11Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -40,6 +40,8 @@
using namespace std;
using namespace Retro;
extern "C" int Rlinktpp_Init(Tcl_Interp* interp); // -Wmissing-prototypes fix
//------------------------------------------+-----------------------------------
extern "C" int Rlinktpp_Init(Tcl_Interp* interp)
{

View File

@@ -1,6 +1,6 @@
// $Id: Rexception.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rexception.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-10-27 1060 1.3 drop throw() list; use noexcept
// 2017-04-29 888 1.2 BUGFIX: add fErrtxt for proper what() return
// 2014-12-30 625 1.1 add ctor(meth,text,emsg)
// 2013-01-12 474 1.0 Initial version
@@ -81,13 +82,13 @@ Rexception::Rexception(const std::string& meth, const std::string& text,
//------------------------------------------+-----------------------------------
//! Destructor
Rexception::~Rexception() throw()
Rexception::~Rexception()
{}
//------------------------------------------+-----------------------------------
//! FIXME_docs
const char* Rexception::what() const throw()
const char* Rexception::what() const noexcept
{
// what() must return a pointer to a string which stays valid at least as long
// as the exception object lives. Use member variable fErrtxt for this.

View File

@@ -1,6 +1,6 @@
// $Id: Rexception.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rexception.hpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-10-27 1060 1.3 drop throw() list; use noexcept
// 2017-04-29 888 1.2 BUGFIX: add fErrtxt for proper what() return
// 2014-12-30 625 1.1 add ctor(meth,text,emsg)
// 2013-02-12 487 1.0.1 add ErrMsg() getter
@@ -45,9 +46,9 @@ namespace Retro {
const std::string& text, int errnum);
Rexception(const std::string& meth,
const std::string& text, const RerrMsg& errmsg);
~Rexception() throw();
~Rexception();
virtual const char* what() const throw();
virtual const char* what() const noexcept;
const RerrMsg& ErrMsg() const;
protected:

View File

@@ -1,6 +1,6 @@
// $Id: RiosState.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RiosState.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2006-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -82,7 +82,7 @@ void RiosState::SetFormat(const char* form, int prec)
char c_fill = 0;
char c;
if (form == 0) form = ""; // allow null as format
if (form == nullptr) form = ""; // allow null as format
for (c = *form++; ; c = *form++) {
if (c == '+') { b_plus = true; continue;}

View File

@@ -1,6 +1,6 @@
// $Id: Rstats.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rstats.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -156,7 +156,7 @@ size_t Rstats::NameMaxLength() const
void Rstats::Print(std::ostream& os, const char* format,
int width, int prec) const
{
if (format == 0 || format[0]==0) {
if (format == nullptr || format[0]==0) {
format = fFormat.c_str();
width = fWidth;
prec = fPrec;

View File

@@ -1,6 +1,6 @@
// $Id: Rutiltpp_Init.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rutiltpp_Init.cpp 1061 2018-10-27 17:39:11Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -35,6 +35,8 @@
using namespace std;
using namespace Retro;
extern "C" int Rutiltpp_Init(Tcl_Interp* interp); // -Wmissing-prototypes fix
//------------------------------------------+-----------------------------------
extern "C" int Rutiltpp_Init(Tcl_Interp* interp)
{

View File

@@ -1,4 +1,4 @@
// $Id: Rw11UnitDisk.cpp 1049 2018-09-22 13:56:52Z mueller $
// $Id: Rw11UnitDisk.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -66,7 +66,6 @@ void Rw11UnitDisk::SetType(const std::string& /*type*/)
{
throw Rexception("Rw11UnitDisk::SetType",
string("Bad args: only type '") + fType + "' supported");
return;
}
//------------------------------------------+-----------------------------------

View File

@@ -1,4 +1,4 @@
// $Id: Rw11UnitTape.cpp 1049 2018-09-22 13:56:52Z mueller $
// $Id: Rw11UnitTape.cpp 1060 2018-10-27 11:32:39Z mueller $
//
// Copyright 2015-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -61,7 +61,6 @@ void Rw11UnitTape::SetType(const std::string& /*type*/)
{
throw Rexception("Rw11UnitTape::SetType",
string("Bad args: only type '") + fType + "' supported");
return;
}
//------------------------------------------+-----------------------------------

View File

@@ -1,4 +1,4 @@
// $Id: Rw11VirtEthTap.cpp 1059 2018-10-27 10:34:16Z mueller $
// $Id: Rw11VirtEthTap.cpp 1062 2018-10-28 11:14:20Z mueller $
//
// Copyright 2014-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -14,7 +14,7 @@
// Revision History:
// Date Rev Version Comment
// 2018-10-27 1059 1.0.1 coverity fixup (uncaught exception in dtor)
// coverity fixup (buffer not null terminated)
// BUGFIX: coverity (buffer not null terminated)
// 2017-04-15 875 1.0 Initial version
// 2014-06-09 561 0.1 First draft
// ---------------------------------------------------------------------------

View File

@@ -1,6 +1,6 @@
// $Id: Rwxxtpp_Init.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rwxxtpp_Init.cpp 1061 2018-10-27 17:39:11Z mueller $
//
// Copyright 2013-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -33,6 +33,8 @@
using namespace std;
using namespace Retro;
extern "C" int Rwxxtpp_Init(Tcl_Interp* interp); // -Wmissing-prototypes fix
//------------------------------------------+-----------------------------------
extern "C" int Rwxxtpp_Init(Tcl_Interp* interp)
{