mirror of
https://passt.top/passt
synced 2025-06-02 14:15:37 +02:00
Avoid shadowing index(3)
A classic gotcha of the standard C library is that its unwise to call any variable 'index' because it will shadow the standard string library function index(3). This can cause warnings from cppcheck amongst others, and it also means that if the variable is removed you tend to get confusing type errors (or sometimes nothing at all) instead of a nice simple "name is not defined" error. Strictly speaking this only occurs if <string.h> is included, but that is so common that as a rule it's best to just avoid it always. We have a number of places which hit this trap, so rename variables and parameters to avoid it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
9178a9e346
commit
5b6c68c2e4
6 changed files with 35 additions and 35 deletions
2
util.h
2
util.h
|
@ -205,7 +205,7 @@ struct ipv6_opt_hdr {
|
|||
|
||||
/* cppcheck-suppress funcArgNamesDifferent */
|
||||
__attribute__ ((weak)) int ffsl(long int i) { return __builtin_ffsl(i); }
|
||||
char *ipv6_l4hdr(const struct pool *p, int index, size_t offset, uint8_t *proto,
|
||||
char *ipv6_l4hdr(const struct pool *p, int idx, size_t offset, uint8_t *proto,
|
||||
size_t *dlen);
|
||||
int sock_l4(const struct ctx *c, int af, uint8_t proto,
|
||||
const void *bind_addr, const char *ifname, uint16_t port,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue