Skip to content

Commit

Permalink
Remove InvalidCast exception.
Browse files Browse the repository at this point in the history
And fix a few broken things from previous commits.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Sep 8, 2017
1 parent 2adeb19 commit cc87af2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 37 deletions.
7 changes: 0 additions & 7 deletions xorp/libxorp/exceptions.cc
Expand Up @@ -86,13 +86,6 @@ InvalidPort::InvalidPort(const char* file,
{
}

InvalidCast::InvalidCast(const char* file,
size_t line,
const string& init_why)
: XorpReasonedException("XorpCast", file, line, init_why)
{
}

InvalidBufferOffset::InvalidBufferOffset(const char* file,
size_t line,
const string& init_why)
Expand Down
8 changes: 0 additions & 8 deletions xorp/libxorp/exceptions.hh
Expand Up @@ -150,14 +150,6 @@ public:
InvalidPort(const char* file, size_t line, const string& init_why = "");
};

/**
* @short A standard XORP exception that is thrown if a cast is invalid.
*/
class InvalidCast : public XorpReasonedException {
public:
InvalidCast(const char* file, size_t line, const string& init_why = "");
};

/**
* @short A standard XORP exception that is thrown if a buffer ofset is
* invalid.
Expand Down
3 changes: 1 addition & 2 deletions xorp/libxorp/ipv4.hh
Expand Up @@ -505,8 +505,7 @@ public:
* @return address size in number of octets.
*/
static size_t addr_bytelen() {
x_static_assert(sizeof(IPv4) == sizeof(uint32_t));
return sizeof(IPv4);
return 4;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions xorp/libxorp/ipvx.cc
Expand Up @@ -157,7 +157,7 @@ IPvX::operator~() const
}

IPvX
IPvX::operator|(const IPvX& other) const throw (InvalidCast)
IPvX::operator|(const IPvX& other) const
{
if (is_ipv4()) {
return get_ipv4() | other.get_ipv4();
Expand All @@ -167,7 +167,7 @@ IPvX::operator|(const IPvX& other) const throw (InvalidCast)
}

IPvX
IPvX::operator&(const IPvX& other) const throw (InvalidCast)
IPvX::operator&(const IPvX& other) const
{
if (is_ipv4()) {
return get_ipv4() & other.get_ipv4();
Expand All @@ -177,7 +177,7 @@ IPvX::operator&(const IPvX& other) const throw (InvalidCast)
}

IPvX
IPvX::operator^(const IPvX& other) const throw (InvalidCast)
IPvX::operator^(const IPvX& other) const
{
if (is_ipv4()) {
return get_ipv4() ^ other.get_ipv4();
Expand Down
22 changes: 11 additions & 11 deletions xorp/libxorp/ipvx.hh
Expand Up @@ -305,23 +305,23 @@ public:
* @param other the right-hand operand to OR with.
* @return bitwise OR of two addresses.
*/
IPvX operator|(const IPvX& other) const throw (InvalidCast);
IPvX operator|(const IPvX& other);

/**
* AND Operator
*
* @param other the right-hand operand to AND with.
* @return bitwise AND of two addresses.
*/
IPvX operator&(const IPvX& other) const throw (InvalidCast);
IPvX operator&(const IPvX& other);

/**
* XOR Operator
*
* @param other the right-hand operand to XOR with.
* @return bitwize eXclusive-OR of two addresses.
*/
IPvX operator^(const IPvX& other) const throw (InvalidCast);
IPvX operator^(const IPvX& other);

/**
* Operator <<
Expand Down Expand Up @@ -757,22 +757,22 @@ public:
*
* @return IPv4 address contained with IPvX structure.
*/
IPv4 get_ipv4() const throw (InvalidCast);
IPv4 get_ipv4() const;

/**
* Get IPv6 address.
*
* @return IPv6 address contained with IPvX structure.
*/
IPv6 get_ipv6() const throw (InvalidCast);
IPv6 get_ipv6() const;

/**
* Assign address value to an IPv4 address.
*
* @param to_ipv4 IPv4 address to be assigned IPv4 value contained
* within this address.
*/
void get(IPv4& to_ipv4) const throw (InvalidCast) {
void get(IPv4& to_ipv4) const {
to_ipv4 = get_ipv4();
}

Expand All @@ -782,7 +782,7 @@ public:
* @param to_ipv6 IPv6 address to be assigned IPv4 value contained
* within this address.
*/
void get(IPv6& to_ipv6) const throw (InvalidCast) {
void get(IPv6& to_ipv6) const {
to_ipv6 = get_ipv6();
}

Expand Down Expand Up @@ -864,19 +864,19 @@ private:
};

inline IPv4
IPvX::get_ipv4() const throw (InvalidCast)
IPvX::get_ipv4() const
{
if (_af == AF_INET)
return IPv4(_addr[0]);
xorp_throw(InvalidCast, "Miscast as IPv4");
XLOG_ASSERT(0);
}

inline IPv6
IPvX::get_ipv6() const throw (InvalidCast)
IPvX::get_ipv6() const
{
if (_af == AF_INET6)
return IPv6(&_addr[0]);
xorp_throw(InvalidCast, "Miscast as IPv6");
XLOG_ASSERT(0);
}

inline uint32_t
Expand Down
8 changes: 4 additions & 4 deletions xorp/libxorp/ipvxnet.hh
Expand Up @@ -163,7 +163,7 @@ public:
*
* @return IPv4Net subnet contained with IPvXNet structure.
*/
IPv4Net get_ipv4net() const throw (InvalidCast) {
IPv4Net get_ipv4net() const {
return IPv4Net(masked_addr().get_ipv4(), prefix_len());
}

Expand All @@ -172,7 +172,7 @@ public:
*
* @return IPv6Net subnet contained with IPvXNet structure.
*/
IPv6Net get_ipv6net() const throw (InvalidCast) {
IPv6Net get_ipv6net() const {
return IPv6Net(masked_addr().get_ipv6(), prefix_len());
}

Expand All @@ -182,7 +182,7 @@ public:
* @param to_ipv4net IPv4Net subnet to be assigned IPv4Net value contained
* within this subnet.
*/
void get(IPv4Net& to_ipv4net) const throw (InvalidCast) {
void get(IPv4Net& to_ipv4net) const {
to_ipv4net = get_ipv4net();
}

Expand All @@ -192,7 +192,7 @@ public:
* @param to_ipv6net IPv6Net subnet to be assigned IPv6Net value contained
* within this subnet.
*/
void get(IPv6Net& to_ipv6net) const throw (InvalidCast) {
void get(IPv6Net& to_ipv6net) const {
to_ipv6net = get_ipv6net();
}

Expand Down
8 changes: 6 additions & 2 deletions xorp/libxorp/range.hh
Expand Up @@ -22,6 +22,9 @@
#ifndef __LIBXORP_RANGE_HH__
#define __LIBXORP_RANGE_HH__

#include "libxorp_module.h"
#include "xlog.h"

class IPv4;
class IPv6;

Expand Down Expand Up @@ -56,7 +59,8 @@ public:

const T& low() const { return _low; }
const T& high() const { return _high; }
bool invalid() const { return _invalid; }
virtual bool invalid() const { return _invalid; }

protected:
T _low;
T _high;
Expand Down Expand Up @@ -371,7 +375,7 @@ public:
from_string.length())
.c_str());
} else {
_invalid = true;
Range<T>::_invalid = true;
XLOG_WARNING("Syntax error: %s", from_cstr);
}
}
Expand Down

0 comments on commit cc87af2

Please sign in to comment.