Skip to content

Commit e63388a

Browse files
jared mauchjared mauch
authored andcommitted
ospfd: fix sign comparison warnings in SNMP code
Fix compiler warnings about comparing signed and unsigned integers by casting arithmetic expressions to size_t to match the type of *length parameter. Fixed in functions: - ospfAreaRangeLookup - ospfHostLookup - ospfIfLookup - ospfIfMetricLookup - ospfVirtIfLookup - ospfNbrLookup - ospfExtLsdbLookup Signed-off-by: jared mauch <[email protected]>
1 parent 66bae5f commit e63388a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ospfd/ospf_snmp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
10931093

10941094
if (exact) {
10951095
/* Area ID + Range Network. */
1096-
if (v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE != *length)
1096+
if ((size_t)(v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE) != *length)
10971097
return NULL;
10981098

10991099
/* Set OID offset for Area ID. */
@@ -1231,7 +1231,7 @@ static struct ospf_nbr_nbma *ospfHostLookup(struct variable *v, oid *name,
12311231

12321232
if (exact) {
12331233
/* INDEX { ospfHostIpAddress, ospfHostTOS } */
1234-
if (*length != v->namelen + IN_ADDR_SIZE + 1)
1234+
if (*length != (size_t)(v->namelen + IN_ADDR_SIZE + 1))
12351235
return NULL;
12361236

12371237
/* Check ospfHostTOS. */
@@ -1528,7 +1528,7 @@ static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
15281528
oid *offset;
15291529

15301530
if (exact) {
1531-
if (*length != v->namelen + IN_ADDR_SIZE + 1)
1531+
if (*length != (size_t)(v->namelen + IN_ADDR_SIZE + 1))
15321532
return NULL;
15331533

15341534
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, ifaddr);
@@ -1668,7 +1668,7 @@ static struct ospf_interface *ospfIfMetricLookup(struct variable *v, oid *name,
16681668
int metric;
16691669

16701670
if (exact) {
1671-
if (*length != v->namelen + IN_ADDR_SIZE + 1 + 1)
1671+
if (*length != (size_t)(v->namelen + IN_ADDR_SIZE + 1 + 1))
16721672
return NULL;
16731673

16741674
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, ifaddr);
@@ -1864,7 +1864,7 @@ ospfVirtIfLookup(struct variable *v, oid *name, size_t *length,
18641864
struct ospf_vl_data *vl_data;
18651865

18661866
if (exact) {
1867-
if (*length != v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE)
1867+
if (*length != (size_t)(v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE))
18681868
return NULL;
18691869

18701870
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, area_id);
@@ -2041,7 +2041,7 @@ static struct ospf_neighbor *ospfNbrLookup(struct variable *v, oid *name,
20412041
return NULL;
20422042

20432043
if (exact) {
2044-
if (*length != v->namelen + IN_ADDR_SIZE + 1)
2044+
if (*length != (size_t)(v->namelen + IN_ADDR_SIZE + 1))
20452045
return NULL;
20462046

20472047
oid2in_addr(name + v->namelen, IN_ADDR_SIZE, nbr_addr);
@@ -2227,7 +2227,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
22272227

22282228
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
22292229
if (exact) {
2230-
if (*length != v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
2230+
if (*length != (size_t)(v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE))
22312231
return NULL;
22322232

22332233
offset = name + v->namelen;

0 commit comments

Comments
 (0)