1
0
mirror of https://github.com/wfjm/w11.git synced 2026-05-03 22:59:46 +00:00

coverity: catch exceptions in dtor

This commit is contained in:
wfjm
2018-10-27 12:44:39 +02:00
parent 4b355707c8
commit 86380fc2c6
8 changed files with 43 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
// $Id: Rw11VirtEthTap.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rw11VirtEthTap.cpp 1059 2018-10-27 10:34:16Z mueller $
//
// Copyright 2014-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-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,8 @@
//
// 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)
// 2017-04-15 875 1.0 Initial version
// 2014-06-09 561 0.1 First draft
// ---------------------------------------------------------------------------
@@ -36,6 +38,7 @@
#include "boost/bind.hpp"
#include "librtools/RosFill.hpp"
#include "librtools/Rtools.hpp"
#include "Rw11VirtEthTap.hpp"
@@ -63,8 +66,9 @@ Rw11VirtEthTap::Rw11VirtEthTap(Rw11Unit* punit)
Rw11VirtEthTap::~Rw11VirtEthTap()
{
if (fFd>=2) {
Server().RemovePollHandler(fFd);
close(fFd);
Rtools::Catch2Cerr(__func__,
[this](){ Server().RemovePollHandler(fFd); } );
::close(fFd);
}
}
@@ -90,7 +94,7 @@ bool Rw11VirtEthTap::Open(const std::string& url, RerrMsg& emsg)
struct ifreq ifr;
::memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, fUrl.Path().c_str(), IFNAMSIZ);
::strncpy(ifr.ifr_name, fUrl.Path().c_str(), IFNAMSIZ-1);
ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
if (::ioctl(fd, TUNSETIFF, &ifr) < 0) {

View File

@@ -1,6 +1,6 @@
// $Id: Rw11VirtTermPty.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rw11VirtTermPty.cpp 1059 2018-10-27 10:34:16Z 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 1059 1.0.3 coverity fixup (uncaught exception in dtor)
// 2017-04-15 875 1.0.2 Open(): set default scheme
// 2017-04-07 868 1.0.1 Dump(): add detail arg
// 2013-03-06 495 1.0 Initial version
@@ -59,8 +60,9 @@ Rw11VirtTermPty::Rw11VirtTermPty(Rw11Unit* punit)
Rw11VirtTermPty::~Rw11VirtTermPty()
{
if (fFd>=2) {
Server().RemovePollHandler(fFd);
close(fFd);
Rtools::Catch2Cerr(__func__,
[this](){ Server().RemovePollHandler(fFd); } );
::close(fFd);
}
}

View File

@@ -1,4 +1,4 @@
// $Id: Rw11VirtTermTcp.cpp 1049 2018-09-22 13:56:52Z mueller $
// $Id: Rw11VirtTermTcp.cpp 1059 2018-10-27 10:34:16Z mueller $
//
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-10-27 1059 1.0.7 coverity fixup (uncaught exception in dtor)
// 2017-04-15 875 1.0.6 Open(): set default scheme
// 2017-04-07 868 1.0.5 Dump(): add detail arg
// 2014-08-22 584 1.0.4 use nullptr
@@ -37,6 +38,7 @@
#include "librtools/RosFill.hpp"
#include "librtools/RlogMsg.hpp"
#include "librtools/Rtools.hpp"
#include "Rw11VirtTermTcp.hpp"
@@ -104,12 +106,14 @@ Rw11VirtTermTcp::Rw11VirtTermTcp(Rw11Unit* punit)
Rw11VirtTermTcp::~Rw11VirtTermTcp()
{
if (fFdListen > 2) {
Server().RemovePollHandler(fFdListen);
close(fFdListen);
Rtools::Catch2Cerr(__func__,
[this](){ Server().RemovePollHandler(fFdListen); } );
::close(fFdListen);
}
if (Connected()) {
Server().RemovePollHandler(fFd);
close(fFd);
Rtools::Catch2Cerr(__func__,
[this](){ Server().RemovePollHandler(fFd); } );
::close(fFd);
}
}