Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea82da5

Browse files
committed
scripts: use code annotations to supress cppcheck warnings
Instead of listing the line number in the code for that the warning should be suppressed at inline annotations. This prevents that the line number of the suppression has to be changed in scripts/cppcheck.sh whenever the source file was changed.
1 parent 5cd6836 commit ea82da5

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

rtrlib/lib/ip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ int lrtr_ip_str_to_addr(const char *str, struct lrtr_ip_addr *ip)
6363
return lrtr_ipv6_str_to_addr(str, &(ip->u.addr6));
6464
}
6565

66+
// cppcheck-suppress unusedFunction
6667
bool lrtr_ip_str_cmp(const struct lrtr_ip_addr *addr1, const char *addr2)
6768
{
6869
struct lrtr_ip_addr tmp;

rtrlib/rtr/packets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,10 @@ int rtr_sync_receive_and_store_pdus(struct rtr_socket *rtr_socket){
976976
retval = rtr_undo_update_pfx_table(rtr_socket, &(ipv4_pdus[j]));
977977
for (unsigned int j = 0; j < ipv6_pdus_nindex && retval == PFX_SUCCESS; j++)
978978
retval = rtr_undo_update_pfx_table(rtr_socket, &(ipv6_pdus[j]));
979+
// cppcheck-suppress duplicateExpression
979980
for (unsigned int j = 0; j < i && (retval == PFX_SUCCESS || retval == SPKI_SUCCESS); j++)
980981
retval = rtr_undo_update_spki_table(rtr_socket, &(router_key_pdus[j]));
982+
// cppcheck-suppress duplicateExpression
981983
if (retval == RTR_ERROR || retval == SPKI_ERROR) {
982984
RTR_DBG1("Couldn't undo all update operations from failed data synchronisation: Purging all key entries");
983985
spki_table_src_remove(rtr_socket->spki_table, rtr_socket);

rtrlib/rtr_mgr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,13 @@ void rtr_mgr_free(struct rtr_mgr_config *config)
324324
free(config);
325325
}
326326

327+
// cppcheck-suppress unusedFunction
327328
inline int rtr_mgr_validate(struct rtr_mgr_config *config, const uint32_t asn, const struct lrtr_ip_addr *prefix, const uint8_t mask_len, enum pfxv_state *result)
328329
{
329330
return pfx_table_validate(config->groups[0].sockets[0]->pfx_table, asn, prefix, mask_len, result);
330331
}
331332

333+
// cppcheck-suppress unusedFunction
332334
inline int rtr_mgr_get_spki(struct rtr_mgr_config *config, const uint32_t asn, uint8_t *ski, struct spki_record *result, unsigned int *result_count)
333335
{
334336
return spki_table_get_all(config->groups[0].sockets[0]->spki_table, asn, ski, &result, result_count);
@@ -349,11 +351,13 @@ const char *rtr_mgr_status_to_str(enum rtr_mgr_status status)
349351
return mgr_str_status[status];
350352
}
351353

354+
// cppcheck-suppress unusedFunction
352355
inline void rtr_mgr_for_each_ipv4_record(struct rtr_mgr_config *config, void (fp)(const struct pfx_record *, void *data), void *data)
353356
{
354357
pfx_table_for_each_ipv4_record(config->groups[0].sockets[0]->pfx_table, fp, data);
355358
}
356359

360+
// cppcheck-suppress unusedFunction
357361
inline void rtr_mgr_for_each_ipv6_record(struct rtr_mgr_config *config, void (fp)(const struct pfx_record *, void *data), void *data)
358362
{
359363
pfx_table_for_each_ipv6_record(config->groups[0].sockets[0]->pfx_table, fp, data);

rtrlib/spki/hashtable/ht-spkitable.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ int spki_table_get_all(struct spki_table *spki_table, uint32_t asn,
185185
return SPKI_SUCCESS;
186186
}
187187

188+
// cppcheck-suppress unusedFunction
188189
int spki_table_search_by_ski(struct spki_table *spki_table, uint8_t *ski,
189190
struct spki_record **result,
190191
unsigned int *result_size)

rtrlib/spki/hashtable/tommyds-1.8/tommyarrayblkof.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ tommy_inline void* tommy_arrayblkof_ref(tommy_arrayblkof* array, unsigned pos)
9292

9393
base = tommy_cast(unsigned char*, tommy_array_get(&array->block, pos / TOMMY_ARRAYBLKOF_SIZE));
9494

95+
// cppcheck-suppress CastIntegerToAddressAtReturn
9596
return base + (pos % TOMMY_ARRAYBLKOF_SIZE) * array->element_size;
9697
}
9798

rtrlib/spki/hashtable/tommyds-1.8/tommyarrayof.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ tommy_inline void* tommy_arrayof_ref(tommy_arrayof* array, unsigned pos)
111111
base = tommy_cast(unsigned char*, array->bucket[bsr - TOMMY_ARRAYOF_BIT + 1]);
112112
}
113113

114+
// cppcheck-suppress CastIntegerToAddressAtReturn
114115
return base + pos * array->element_size;
115116
}
116117

rtrlib/transport/transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ inline void tr_close(struct tr_socket *socket)
2020
socket->close_fp(socket->socket);
2121
}
2222

23+
// cppcheck-suppress unusedFunction
2324
inline void tr_free(struct tr_socket *socket)
2425
{
2526
socket->free_fp(socket);

scripts/cppcheck.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
#!/bin/bash
22

3-
cppcheck --error-exitcode=1 --enable=all \
3+
cppcheck --error-exitcode=1 --enable=all --inline-suppr \
44
--template='{id}:{file}({line}):({severity}) {message}' \
5-
--suppress="duplicateExpression:rtrlib/rtr/packets.c:979" \
6-
--suppress="duplicateExpression:rtrlib/rtr/packets.c:981" \
7-
--suppress="unusedFunction:rtrlib/lib/ip.c:66" \
8-
--suppress="unusedFunction:rtrlib/transport/transport.c:23" \
9-
--suppress="unusedFunction:rtrlib/rtr_mgr.c:327" \
10-
--suppress="unusedFunction:rtrlib/rtr_mgr.c:332" \
11-
--suppress="unusedFunction:rtrlib/rtr_mgr.c:352" \
12-
--suppress="unusedFunction:rtrlib/rtr_mgr.c:357" \
13-
--suppress="unusedFunction:rtrlib/spki/hashtable/ht-spkitable.c:188" \
14-
--suppress="CastIntegerToAddressAtReturn:rtrlib/spki/hashtable/tommyds-1.8/tommyarrayof.h:114" \
15-
--suppress="CastIntegerToAddressAtReturn:rtrlib/spki/hashtable/tommyds-1.8/tommyarrayblkof.h:95" \
165
-i rtrlib/spki/hashtable/tommyds-1.8/ tools/ rtrlib/

0 commit comments

Comments
 (0)