Skip to content

Commit

Permalink
bgp: Fix const related warnings.
Browse files Browse the repository at this point in the history
These errors caused build failures on Fedora 17.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Jun 6, 2012
1 parent 9c9053f commit d856e12
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 48 deletions.
92 changes: 46 additions & 46 deletions xorp/bgp/path_attribute.cc
Expand Up @@ -1978,50 +1978,50 @@ PathAttribute::operator<(const PathAttribute& him) const
// equal sorttypes imply equal types
switch (type()) {
case ORIGIN:
return ( ((OriginAttribute &)*this).origin() <
((OriginAttribute &)him).origin() );
return ( ((const OriginAttribute &)*this).origin() <
((const OriginAttribute &)him).origin() );

case AS_PATH:
return ( ((ASPathAttribute &)*this).as_path() <
((ASPathAttribute &)him).as_path() );
return ( ((const ASPathAttribute &)*this).as_path() <
((const ASPathAttribute &)him).as_path() );

case AS4_PATH:
return ( ((AS4PathAttribute &)*this).as_path() <
((AS4PathAttribute &)him).as_path() );
return ( ((const AS4PathAttribute &)*this).as_path() <
((const AS4PathAttribute &)him).as_path() );

case NEXT_HOP:
return ( ((NextHopAttribute<IPv4> &)*this).nexthop() <
((NextHopAttribute<IPv4> &)him).nexthop() );
return ( ((const NextHopAttribute<IPv4> &)*this).nexthop() <
((const NextHopAttribute<IPv4> &)him).nexthop() );

case MED:
return ( ((MEDAttribute &)*this).med() <
((MEDAttribute &)him).med() );
return ( ((const MEDAttribute &)*this).med() <
((const MEDAttribute &)him).med() );

case LOCAL_PREF:
return ( ((LocalPrefAttribute &)*this).localpref() <
((LocalPrefAttribute &)him).localpref() );
return ( ((const LocalPrefAttribute &)*this).localpref() <
((const LocalPrefAttribute &)him).localpref() );

case ATOMIC_AGGREGATE:
return false;

case AGGREGATOR:
if ( ((AggregatorAttribute &)*this).aggregator_as()
== ((AggregatorAttribute &)him).aggregator_as() ) {
return ( ((AggregatorAttribute &)*this).route_aggregator()
< ((AggregatorAttribute &)him).route_aggregator() );
if ( ((const AggregatorAttribute &)*this).aggregator_as()
== ((const AggregatorAttribute &)him).aggregator_as() ) {
return ( ((const AggregatorAttribute &)*this).route_aggregator()
< ((const AggregatorAttribute &)him).route_aggregator() );
} else {
return ( ((AggregatorAttribute &)*this).aggregator_as()
< ((AggregatorAttribute &)him).aggregator_as() );
return ( ((const AggregatorAttribute &)*this).aggregator_as()
< ((const AggregatorAttribute &)him).aggregator_as() );
}

case AS4_AGGREGATOR:
if ( ((AS4AggregatorAttribute &)*this).aggregator_as()
== ((AS4AggregatorAttribute &)him).aggregator_as() ) {
return ( ((AS4AggregatorAttribute &)*this).route_aggregator()
< ((AS4AggregatorAttribute &)him).route_aggregator() );
if ( ((const AS4AggregatorAttribute &)*this).aggregator_as()
== ((const AS4AggregatorAttribute &)him).aggregator_as() ) {
return ( ((const AS4AggregatorAttribute &)*this).route_aggregator()
< ((const AS4AggregatorAttribute &)him).route_aggregator() );
} else {
return ( ((AS4AggregatorAttribute &)*this).aggregator_as()
< ((AS4AggregatorAttribute &)him).aggregator_as() );
return ( ((const AS4AggregatorAttribute &)*this).aggregator_as()
< ((const AS4AggregatorAttribute &)him).aggregator_as() );
}

case COMMUNITY:
Expand Down Expand Up @@ -2090,43 +2090,43 @@ PathAttribute::operator==(const PathAttribute& him) const
return false;
switch (type()) {
case ORIGIN:
return ( ((OriginAttribute &)*this).origin() ==
((OriginAttribute &)him).origin() );
return ( ((const OriginAttribute &)*this).origin() ==
((const OriginAttribute &)him).origin() );

case AS_PATH:
return ( ((ASPathAttribute &)*this).as_path() ==
((ASPathAttribute &)him).as_path() );
return ( ((const ASPathAttribute &)*this).as_path() ==
((const ASPathAttribute &)him).as_path() );

case AS4_PATH:
return ( ((AS4PathAttribute &)*this).as_path() ==
((AS4PathAttribute &)him).as_path() );
return ( ((const AS4PathAttribute &)*this).as_path() ==
((const AS4PathAttribute &)him).as_path() );

case NEXT_HOP:
return ( ((NextHopAttribute<IPv4> &)*this).nexthop() ==
((NextHopAttribute<IPv4> &)him).nexthop() );
return ( ((const NextHopAttribute<IPv4> &)*this).nexthop() ==
((const NextHopAttribute<IPv4> &)him).nexthop() );

case MED:
return ( ((MEDAttribute &)*this).med() ==
((MEDAttribute &)him).med() );
return ( ((const MEDAttribute &)*this).med() ==
((const MEDAttribute &)him).med() );

case LOCAL_PREF:
return ( ((LocalPrefAttribute &)*this).localpref() ==
((LocalPrefAttribute &)him).localpref() );
return ( ((const LocalPrefAttribute &)*this).localpref() ==
((const LocalPrefAttribute &)him).localpref() );

case ATOMIC_AGGREGATE:
return true;

case AGGREGATOR:
return ( ((AggregatorAttribute &)*this).aggregator_as()
== ((AggregatorAttribute &)him).aggregator_as()
&& ((AggregatorAttribute &)*this).route_aggregator()
== ((AggregatorAttribute &)him).route_aggregator() );
return ( ((const AggregatorAttribute &)*this).aggregator_as()
== ((const AggregatorAttribute &)him).aggregator_as()
&& ((const AggregatorAttribute &)*this).route_aggregator()
== ((const AggregatorAttribute &)him).route_aggregator() );

case AS4_AGGREGATOR:
return ( ((AS4AggregatorAttribute &)*this).aggregator_as()
== ((AS4AggregatorAttribute &)him).aggregator_as()
&& ((AS4AggregatorAttribute &)*this).route_aggregator()
== ((AS4AggregatorAttribute &)him).route_aggregator() );
return ( ((const AS4AggregatorAttribute &)*this).aggregator_as()
== ((const AS4AggregatorAttribute &)him).aggregator_as()
&& ((const AS4AggregatorAttribute &)*this).route_aggregator()
== ((const AS4AggregatorAttribute &)him).route_aggregator() );

case COMMUNITY:
// XXX using encode for this is a little inefficient
Expand All @@ -2138,8 +2138,8 @@ PathAttribute::operator==(const PathAttribute& him) const
return memcmp(mybuf, hisbuf, mybuflen) == 0;

case ORIGINATOR_ID:
return ( ((OriginatorIDAttribute &)*this).originator_id()
== ((OriginatorIDAttribute &)him).originator_id() );
return ( ((const OriginatorIDAttribute &)*this).originator_id()
== ((const OriginatorIDAttribute &)him).originator_id() );

case CLUSTER_LIST:
// XXX using encode for this is a little inefficient
Expand Down
3 changes: 2 additions & 1 deletion xorp/bgp/path_attribute.hh
Expand Up @@ -17,7 +17,6 @@
// XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
// http://xorp.net

// $XORP: xorp/bgp/path_attribute.hh,v 1.54 2008/12/11 21:05:59 mjh Exp $

#ifndef __BGP_PATH_ATTRIBUTE_HH__
#define __BGP_PATH_ATTRIBUTE_HH__
Expand Down Expand Up @@ -364,6 +363,8 @@ public:
}

A& nexthop() { return _next_hop; }
const A& nexthop() const { return _next_hop; }

// This method is for use in MPReachNLRIAttribute only.
void set_nexthop(const A& n) { _next_hop = n; }

Expand Down
2 changes: 1 addition & 1 deletion xorp/bgp/update_attrib.hh
Expand Up @@ -77,7 +77,7 @@ public:
}

const IPv4Net& net() const {
return (IPv4Net &)(*this);
return (const IPv4Net &)(*this);
}

string str(string nlri_or_withdraw) const {
Expand Down

0 comments on commit d856e12

Please sign in to comment.