1
0
mirror of https://github.com/wfjm/w11.git synced 2026-05-02 14:31:17 +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

@@ -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;