@@ -31,30 +31,30 @@ int bgp_ls_node_descriptor_cmp(const struct bgp_ls_node_descriptor *d1,
3131
3232 /* Must have same TLVs present */
3333 if (d1 -> present_tlvs != d2 -> present_tlvs )
34- return d1 -> present_tlvs - d2 -> present_tlvs ;
34+ return numcmp ( d1 -> present_tlvs , d2 -> present_tlvs ) ;
3535
3636 /* Compare AS Number if present */
3737 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_NODE_DESC_AS_BIT )) {
3838 if (d1 -> asn != d2 -> asn )
39- return d1 -> asn - d2 -> asn ;
39+ return numcmp ( d1 -> asn , d2 -> asn ) ;
4040 }
4141
4242 /* Compare BGP-LS ID if present */
4343 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_NODE_DESC_BGP_LS_ID_BIT )) {
4444 if (d1 -> bgp_ls_id != d2 -> bgp_ls_id )
45- return d1 -> bgp_ls_id - d2 -> bgp_ls_id ;
45+ return numcmp ( d1 -> bgp_ls_id , d2 -> bgp_ls_id ) ;
4646 }
4747
4848 /* Compare OSPF Area ID if present */
4949 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_NODE_DESC_OSPF_AREA_BIT )) {
5050 if (d1 -> ospf_area_id != d2 -> ospf_area_id )
51- return d1 -> ospf_area_id - d2 -> ospf_area_id ;
51+ return numcmp ( d1 -> ospf_area_id , d2 -> ospf_area_id ) ;
5252 }
5353
5454 /* Compare IGP Router ID if present */
5555 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_NODE_DESC_IGP_ROUTER_BIT )) {
5656 if (d1 -> igp_router_id_len != d2 -> igp_router_id_len )
57- return d1 -> igp_router_id_len - d2 -> igp_router_id_len ;
57+ return numcmp ( d1 -> igp_router_id_len , d2 -> igp_router_id_len ) ;
5858 ret = memcmp (d1 -> igp_router_id , d2 -> igp_router_id , d1 -> igp_router_id_len );
5959 if (ret != 0 )
6060 return ret ;
@@ -80,14 +80,14 @@ int bgp_ls_link_descriptor_cmp(const struct bgp_ls_link_descriptor *d1,
8080
8181 /* Must have same TLVs present */
8282 if (d1 -> present_tlvs != d2 -> present_tlvs )
83- return d1 -> present_tlvs - d2 -> present_tlvs ;
83+ return numcmp ( d1 -> present_tlvs , d2 -> present_tlvs ) ;
8484
8585 /* Compare Link IDs if present */
8686 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_LINK_DESC_LINK_ID_BIT )) {
8787 if (d1 -> link_local_id != d2 -> link_local_id )
88- return d1 -> link_local_id - d2 -> link_local_id ;
88+ return numcmp ( d1 -> link_local_id , d2 -> link_local_id ) ;
8989 if (d1 -> link_remote_id != d2 -> link_remote_id )
90- return d1 -> link_remote_id - d2 -> link_remote_id ;
90+ return numcmp ( d1 -> link_remote_id , d2 -> link_remote_id ) ;
9191 }
9292
9393 /* Compare IPv4 Interface Address if present */
@@ -121,10 +121,10 @@ int bgp_ls_link_descriptor_cmp(const struct bgp_ls_link_descriptor *d1,
121121 /* Compare Multi-Topology IDs if present */
122122 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_LINK_DESC_MT_ID_BIT )) {
123123 if (d1 -> mt_id_count != d2 -> mt_id_count )
124- return d1 -> mt_id_count - d2 -> mt_id_count ;
124+ return numcmp ( d1 -> mt_id_count , d2 -> mt_id_count ) ;
125125 for (int i = 0 ; i < d1 -> mt_id_count ; i ++ ) {
126126 if (d1 -> mt_id [i ] != d2 -> mt_id [i ])
127- return d1 -> mt_id [i ] - d2 -> mt_id [i ];
127+ return numcmp ( d1 -> mt_id [i ], d2 -> mt_id [i ]) ;
128128 }
129129 }
130130
@@ -148,7 +148,7 @@ int bgp_ls_prefix_descriptor_cmp(const struct bgp_ls_prefix_descriptor *d1,
148148
149149 /* Must have same TLVs present */
150150 if (d1 -> present_tlvs != d2 -> present_tlvs )
151- return d1 -> present_tlvs - d2 -> present_tlvs ;
151+ return numcmp ( d1 -> present_tlvs , d2 -> present_tlvs ) ;
152152
153153 /* Compare prefix */
154154 ret = prefix_cmp (& d1 -> prefix , & d2 -> prefix );
@@ -158,16 +158,16 @@ int bgp_ls_prefix_descriptor_cmp(const struct bgp_ls_prefix_descriptor *d1,
158158 /* Compare OSPF Route Type if present */
159159 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_PREFIX_DESC_OSPF_ROUTE_BIT )) {
160160 if (d1 -> ospf_route_type != d2 -> ospf_route_type )
161- return d1 -> ospf_route_type - d2 -> ospf_route_type ;
161+ return numcmp ( d1 -> ospf_route_type , d2 -> ospf_route_type ) ;
162162 }
163163
164164 /* Compare Multi-Topology IDs if present */
165165 if (BGP_LS_TLV_CHECK (d1 -> present_tlvs , BGP_LS_PREFIX_DESC_MT_ID_BIT )) {
166166 if (d1 -> mt_id_count != d2 -> mt_id_count )
167- return d1 -> mt_id_count - d2 -> mt_id_count ;
167+ return numcmp ( d1 -> mt_id_count , d2 -> mt_id_count ) ;
168168 for (int i = 0 ; i < d1 -> mt_id_count ; i ++ ) {
169169 if (d1 -> mt_id [i ] != d2 -> mt_id [i ])
170- return d1 -> mt_id [i ] - d2 -> mt_id [i ];
170+ return numcmp ( d1 -> mt_id [i ], d2 -> mt_id [i ]) ;
171171 }
172172 }
173173
@@ -190,7 +190,7 @@ int bgp_ls_nlri_cmp(const struct bgp_ls_nlri *nlri1, const struct bgp_ls_nlri *n
190190
191191 /* Different types are never equal */
192192 if (nlri1 -> nlri_type != nlri2 -> nlri_type )
193- return nlri1 -> nlri_type - nlri2 -> nlri_type ;
193+ return numcmp ( nlri1 -> nlri_type , nlri2 -> nlri_type ) ;
194194
195195 /* Type-specific comparison */
196196 switch (nlri1 -> nlri_type ) {
@@ -200,11 +200,11 @@ int bgp_ls_nlri_cmp(const struct bgp_ls_nlri *nlri1, const struct bgp_ls_nlri *n
200200
201201 /* Compare protocol ID */
202202 if (n1 -> protocol_id != n2 -> protocol_id )
203- return n1 -> protocol_id - n2 -> protocol_id ;
203+ return numcmp ( n1 -> protocol_id , n2 -> protocol_id ) ;
204204
205205 /* Compare identifier */
206206 if (n1 -> identifier != n2 -> identifier )
207- return n1 -> identifier - n2 -> identifier ;
207+ return numcmp ( n1 -> identifier , n2 -> identifier ) ;
208208
209209 /* Compare local node descriptor */
210210 return bgp_ls_node_descriptor_cmp (& n1 -> local_node , & n2 -> local_node );
@@ -216,11 +216,11 @@ int bgp_ls_nlri_cmp(const struct bgp_ls_nlri *nlri1, const struct bgp_ls_nlri *n
216216
217217 /* Compare protocol ID */
218218 if (l1 -> protocol_id != l2 -> protocol_id )
219- return l1 -> protocol_id - l2 -> protocol_id ;
219+ return numcmp ( l1 -> protocol_id , l2 -> protocol_id ) ;
220220
221221 /* Compare identifier */
222222 if (l1 -> identifier != l2 -> identifier )
223- return l1 -> identifier - l2 -> identifier ;
223+ return numcmp ( l1 -> identifier , l2 -> identifier ) ;
224224
225225 /* Compare local node descriptor */
226226 ret = bgp_ls_node_descriptor_cmp (& l1 -> local_node , & l2 -> local_node );
@@ -243,11 +243,11 @@ int bgp_ls_nlri_cmp(const struct bgp_ls_nlri *nlri1, const struct bgp_ls_nlri *n
243243
244244 /* Compare protocol ID */
245245 if (p1 -> protocol_id != p2 -> protocol_id )
246- return p1 -> protocol_id - p2 -> protocol_id ;
246+ return numcmp ( p1 -> protocol_id , p2 -> protocol_id ) ;
247247
248248 /* Compare identifier */
249249 if (p1 -> identifier != p2 -> identifier )
250- return p1 -> identifier - p2 -> identifier ;
250+ return numcmp ( p1 -> identifier , p2 -> identifier ) ;
251251
252252 /* Compare local node descriptor */
253253 ret = bgp_ls_node_descriptor_cmp (& p1 -> local_node , & p2 -> local_node );
@@ -275,11 +275,11 @@ int bgp_ls_attr_cmp(const struct bgp_ls_attr *attr1, const struct bgp_ls_attr *a
275275 int ret ;
276276
277277 if (attr1 -> present_tlvs != attr2 -> present_tlvs )
278- return attr1 -> present_tlvs - attr2 -> present_tlvs ;
278+ return numcmp ( attr1 -> present_tlvs , attr2 -> present_tlvs ) ;
279279
280280 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_NODE_FLAGS_BIT )) {
281281 if (attr1 -> node_flags != attr2 -> node_flags )
282- return attr1 -> node_flags - attr2 -> node_flags ;
282+ return numcmp ( attr1 -> node_flags , attr2 -> node_flags ) ;
283283 }
284284
285285 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_NODE_NAME_BIT )) {
@@ -290,7 +290,7 @@ int bgp_ls_attr_cmp(const struct bgp_ls_attr *attr1, const struct bgp_ls_attr *a
290290
291291 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_ISIS_AREA_BIT )) {
292292 if (attr1 -> isis_area_id_len != attr2 -> isis_area_id_len )
293- return attr1 -> isis_area_id_len - attr2 -> isis_area_id_len ;
293+ return numcmp ( attr1 -> isis_area_id_len , attr2 -> isis_area_id_len ) ;
294294 ret = memcmp (attr1 -> isis_area_id , attr2 -> isis_area_id , attr1 -> isis_area_id_len );
295295 if (ret != 0 )
296296 return ret ;
@@ -322,7 +322,7 @@ int bgp_ls_attr_cmp(const struct bgp_ls_attr *attr1, const struct bgp_ls_attr *a
322322
323323 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_ADMIN_GROUP_BIT )) {
324324 if (attr1 -> admin_group != attr2 -> admin_group )
325- return attr1 -> admin_group - attr2 -> admin_group ;
325+ return numcmp ( attr1 -> admin_group , attr2 -> admin_group ) ;
326326 }
327327
328328 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_MAX_LINK_BW_BIT )) {
@@ -350,32 +350,32 @@ int bgp_ls_attr_cmp(const struct bgp_ls_attr *attr1, const struct bgp_ls_attr *a
350350
351351 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_TE_METRIC_BIT )) {
352352 if (attr1 -> te_metric != attr2 -> te_metric )
353- return attr1 -> te_metric - attr2 -> te_metric ;
353+ return numcmp ( attr1 -> te_metric , attr2 -> te_metric ) ;
354354 }
355355
356356 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_LINK_PROTECTION_BIT )) {
357357 if (attr1 -> link_protection != attr2 -> link_protection )
358- return attr1 -> link_protection - attr2 -> link_protection ;
358+ return numcmp ( attr1 -> link_protection , attr2 -> link_protection ) ;
359359 }
360360
361361 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_MPLS_PROTOCOL_BIT )) {
362362 if (attr1 -> mpls_protocol_mask != attr2 -> mpls_protocol_mask )
363- return attr1 -> mpls_protocol_mask - attr2 -> mpls_protocol_mask ;
363+ return numcmp ( attr1 -> mpls_protocol_mask , attr2 -> mpls_protocol_mask ) ;
364364 }
365365
366366 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_IGP_METRIC_BIT )) {
367367 if (attr1 -> igp_metric_len != attr2 -> igp_metric_len )
368- return attr1 -> igp_metric_len - attr2 -> igp_metric_len ;
368+ return numcmp ( attr1 -> igp_metric_len , attr2 -> igp_metric_len ) ;
369369 if (attr1 -> igp_metric != attr2 -> igp_metric )
370- return attr1 -> igp_metric - attr2 -> igp_metric ;
370+ return numcmp ( attr1 -> igp_metric , attr2 -> igp_metric ) ;
371371 }
372372
373373 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_SRLG_BIT )) {
374374 if (attr1 -> srlg_count != attr2 -> srlg_count )
375- return attr1 -> srlg_count - attr2 -> srlg_count ;
375+ return numcmp ( attr1 -> srlg_count , attr2 -> srlg_count ) ;
376376 for (int i = 0 ; i < attr1 -> srlg_count ; i ++ ) {
377377 if (attr1 -> srlg_values [i ] != attr2 -> srlg_values [i ])
378- return attr1 -> srlg_values [i ] - attr2 -> srlg_values [i ];
378+ return numcmp ( attr1 -> srlg_values [i ], attr2 -> srlg_values [i ]) ;
379379 }
380380 }
381381
@@ -387,30 +387,30 @@ int bgp_ls_attr_cmp(const struct bgp_ls_attr *attr1, const struct bgp_ls_attr *a
387387
388388 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_IGP_FLAGS_BIT )) {
389389 if (attr1 -> igp_flags != attr2 -> igp_flags )
390- return attr1 -> igp_flags - attr2 -> igp_flags ;
390+ return numcmp ( attr1 -> igp_flags , attr2 -> igp_flags ) ;
391391 }
392392
393393 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_ROUTE_TAG_BIT )) {
394394 if (attr1 -> route_tag_count != attr2 -> route_tag_count )
395- return attr1 -> route_tag_count - attr2 -> route_tag_count ;
395+ return numcmp ( attr1 -> route_tag_count , attr2 -> route_tag_count ) ;
396396 for (int i = 0 ; i < attr1 -> route_tag_count ; i ++ ) {
397397 if (attr1 -> route_tags [i ] != attr2 -> route_tags [i ])
398- return attr1 -> route_tags [i ] - attr2 -> route_tags [i ];
398+ return numcmp ( attr1 -> route_tags [i ], attr2 -> route_tags [i ]) ;
399399 }
400400 }
401401
402402 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_EXTENDED_TAG_BIT )) {
403403 if (attr1 -> extended_tag_count != attr2 -> extended_tag_count )
404- return attr1 -> extended_tag_count - attr2 -> extended_tag_count ;
404+ return numcmp ( attr1 -> extended_tag_count , attr2 -> extended_tag_count ) ;
405405 for (int i = 0 ; i < attr1 -> extended_tag_count ; i ++ ) {
406406 if (attr1 -> extended_tags [i ] != attr2 -> extended_tags [i ])
407- return attr1 -> extended_tags [i ] - attr2 -> extended_tags [i ];
407+ return numcmp ( attr1 -> extended_tags [i ], attr2 -> extended_tags [i ]) ;
408408 }
409409 }
410410
411411 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_PREFIX_METRIC_BIT )) {
412412 if (attr1 -> prefix_metric != attr2 -> prefix_metric )
413- return attr1 -> prefix_metric - attr2 -> prefix_metric ;
413+ return numcmp ( attr1 -> prefix_metric , attr2 -> prefix_metric ) ;
414414 }
415415
416416 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_OSPF_FWD_ADDR_BIT )) {
@@ -424,26 +424,26 @@ int bgp_ls_attr_cmp(const struct bgp_ls_attr *attr1, const struct bgp_ls_attr *a
424424
425425 if (BGP_LS_TLV_CHECK (attr1 -> present_tlvs , BGP_LS_ATTR_PREFIX_SID_BIT )) {
426426 if (attr1 -> prefix_sid .sid != attr2 -> prefix_sid .sid )
427- return attr1 -> prefix_sid .sid - attr2 -> prefix_sid .sid ;
427+ return numcmp ( attr1 -> prefix_sid .sid , attr2 -> prefix_sid .sid ) ;
428428 if (attr1 -> prefix_sid .sid_flag != attr2 -> prefix_sid .sid_flag )
429- return attr1 -> prefix_sid .sid_flag - attr2 -> prefix_sid .sid_flag ;
429+ return numcmp ( attr1 -> prefix_sid .sid_flag , attr2 -> prefix_sid .sid_flag ) ;
430430 if (attr1 -> prefix_sid .algo != attr2 -> prefix_sid .algo )
431- return attr1 -> prefix_sid .algo - attr2 -> prefix_sid .algo ;
431+ return numcmp ( attr1 -> prefix_sid .algo , attr2 -> prefix_sid .algo ) ;
432432 }
433433
434434 if (attr1 -> opaque_len != attr2 -> opaque_len )
435- return attr1 -> opaque_len - attr2 -> opaque_len ;
435+ return numcmp ( attr1 -> opaque_len , attr2 -> opaque_len ) ;
436436 if (attr1 -> opaque_len > 0 ) {
437437 ret = memcmp (attr1 -> opaque_data , attr2 -> opaque_data , attr1 -> opaque_len );
438438 if (ret != 0 )
439439 return ret ;
440440 }
441441
442442 if (attr1 -> mt_id_count != attr2 -> mt_id_count )
443- return attr1 -> mt_id_count - attr2 -> mt_id_count ;
443+ return numcmp ( attr1 -> mt_id_count , attr2 -> mt_id_count ) ;
444444 for (int i = 0 ; i < attr1 -> mt_id_count ; i ++ ) {
445445 if (attr1 -> mt_id [i ] != attr2 -> mt_id [i ])
446- return attr1 -> mt_id [i ] - attr2 -> mt_id [i ];
446+ return numcmp ( attr1 -> mt_id [i ], attr2 -> mt_id [i ]) ;
447447 }
448448
449449 return 0 ;
0 commit comments