Merge pull request #2994 from opensourcerouting/sa-warnings

fix remaining SA warnings
This commit is contained in:
Donald Sharp 2018-09-08 21:04:54 -04:00 committed by GitHub
commit 4bb7d4482d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 37 additions and 19 deletions

View File

@ -248,6 +248,8 @@ ssize_t bfd_recv_ipv4(int sd, uint8_t *msgbuf, size_t msgbuflen, uint8_t *ttl,
struct iovec iov[1]; struct iovec iov[1];
uint8_t cmsgbuf[255]; uint8_t cmsgbuf[255];
port[0] = '\0';
/* Prepare the recvmsg params. */ /* Prepare the recvmsg params. */
iov[0].iov_base = msgbuf; iov[0].iov_base = msgbuf;
iov[0].iov_len = msgbuflen; iov[0].iov_len = msgbuflen;

View File

@ -1620,10 +1620,8 @@ lde_address_list_free(struct lde_nbr *ln)
{ {
struct lde_addr *lde_addr; struct lde_addr *lde_addr;
while ((lde_addr = TAILQ_FIRST(&ln->addr_list)) != NULL) { while ((lde_addr = TAILQ_POP_FIRST(&ln->addr_list, entry)) != NULL)
TAILQ_REMOVE(&ln->addr_list, lde_addr, entry);
free(lde_addr); free(lde_addr);
}
} }
static void zclient_sync_init(unsigned short instance) static void zclient_sync_init(unsigned short instance)

View File

@ -1198,6 +1198,7 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in,
/* retrieve action */ /* retrieve action */
token = strsep(&working, " "); token = strsep(&working, " ");
assert(token);
/* match result to known actions */ /* match result to known actions */
if (strmatch(token, "include")) { if (strmatch(token, "include")) {

View File

@ -563,6 +563,8 @@ void csv_decode(csv_t *csv, char *inbuf)
csv_record_t *rec; csv_record_t *rec;
buf = (inbuf) ? inbuf : csv->buf; buf = (inbuf) ? inbuf : csv->buf;
assert(buf);
pos = strpbrk(buf, "\n"); pos = strpbrk(buf, "\n");
while (pos != NULL) { while (pos != NULL) {
rec = calloc(1, sizeof(csv_record_t)); rec = calloc(1, sizeof(csv_record_t));

View File

@ -21,9 +21,9 @@
#include "queue.h" #include "queue.h"
#include "imsg.h" #include "imsg.h"
int ibuf_realloc(struct ibuf *, size_t); static int ibuf_realloc(struct ibuf *, size_t);
void ibuf_enqueue(struct msgbuf *, struct ibuf *); static void ibuf_enqueue(struct msgbuf *, struct ibuf *);
void ibuf_dequeue(struct msgbuf *, struct ibuf *); static void ibuf_dequeue(struct msgbuf *, struct ibuf *);
struct ibuf *ibuf_open(size_t len) struct ibuf *ibuf_open(size_t len)
{ {
@ -57,7 +57,7 @@ struct ibuf *ibuf_dynamic(size_t len, size_t max)
return (buf); return (buf);
} }
int ibuf_realloc(struct ibuf *buf, size_t len) static int ibuf_realloc(struct ibuf *buf, size_t len)
{ {
uint8_t *b; uint8_t *b;
@ -183,6 +183,8 @@ void msgbuf_drain(struct msgbuf *msgbuf, size_t n)
next = TAILQ_NEXT(buf, entry); next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->wpos) { if (buf->rpos + n >= buf->wpos) {
n -= buf->wpos - buf->rpos; n -= buf->wpos - buf->rpos;
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
ibuf_dequeue(msgbuf, buf); ibuf_dequeue(msgbuf, buf);
} else { } else {
buf->rpos += n; buf->rpos += n;
@ -195,7 +197,7 @@ void msgbuf_clear(struct msgbuf *msgbuf)
{ {
struct ibuf *buf; struct ibuf *buf;
while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL) while ((buf = TAILQ_POP_FIRST(&msgbuf->bufs, entry)) != NULL)
ibuf_dequeue(msgbuf, buf); ibuf_dequeue(msgbuf, buf);
} }
@ -266,16 +268,15 @@ again:
return (1); return (1);
} }
void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf) static void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
{ {
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry); TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++; msgbuf->queued++;
} }
void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf) static void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
{ {
TAILQ_REMOVE(&msgbuf->bufs, buf, entry); /* TAILQ_REMOVE done by caller */
if (buf->fd != -1) if (buf->fd != -1)
close(buf->fd); close(buf->fd);

View File

@ -299,11 +299,10 @@ int imsg_get_fd(struct imsgbuf *ibuf)
int fd; int fd;
struct imsg_fd *ifd; struct imsg_fd *ifd;
if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL) if ((ifd = TAILQ_POP_FIRST(&ibuf->fds, entry)) == NULL)
return (-1); return (-1);
fd = ifd->fd; fd = ifd->fd;
TAILQ_REMOVE(&ibuf->fds, ifd, entry);
free(ifd); free(ifd);
return (fd); return (fd);

View File

@ -72,4 +72,17 @@
#include "freebsd-queue.h" #include "freebsd-queue.h"
#endif /* defined(__OpenBSD__) && !defined(STAILQ_HEAD) */ #endif /* defined(__OpenBSD__) && !defined(STAILQ_HEAD) */
#ifndef TAILQ_POP_FIRST
#define TAILQ_POP_FIRST(head, field) \
({ typeof((head)->tqh_first) _elm = TAILQ_FIRST(head); \
if (_elm) { \
if ((TAILQ_NEXT((_elm), field)) != NULL) \
TAILQ_NEXT((_elm), field)->field.tqe_prev = \
&TAILQ_FIRST(head); \
else \
(head)->tqh_last = &TAILQ_FIRST(head); \
TAILQ_FIRST(head) = TAILQ_NEXT((_elm), field); \
}; _elm; })
#endif
#endif /* _FRR_QUEUE_H */ #endif /* _FRR_QUEUE_H */

View File

@ -202,6 +202,7 @@ int skiplist_insert(register struct skiplist *l, register void *key,
} }
k = randomLevel(); k = randomLevel();
assert(k >= 0);
if (k > l->level) { if (k > l->level) {
k = ++l->level; k = ++l->level;
update[k] = l->header; update[k] = l->header;

View File

@ -732,7 +732,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
? 1 ? 1
: 2, : 2,
buf, listcount(route->paths), buf, listcount(route->paths),
listcount(route->nh_list)); route->nh_list ?
listcount(route->nh_list) : 0);
} }
if (listcount(route->paths)) { if (listcount(route->paths)) {

View File

@ -732,7 +732,7 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
route->next = next; route->next = next;
if (node->info == next) { if (node->info == next) {
assert(next->rnode == node); assert(next && next->rnode == node);
node->info = route; node->info = route;
UNSET_FLAG(next->flag, OSPF6_ROUTE_BEST); UNSET_FLAG(next->flag, OSPF6_ROUTE_BEST);
SET_FLAG(route->flag, OSPF6_ROUTE_BEST); SET_FLAG(route->flag, OSPF6_ROUTE_BEST);

View File

@ -995,7 +995,6 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
if (len <= 0) if (len <= 0)
type_next = 1; type_next = 1;
else { else {
len = 1;
type_next = 0; type_next = 0;
*type = *offset; *type = *offset;
} }

View File

@ -88,8 +88,8 @@ static struct list *static_list;
static int static_list_compare_helper(const char *s1, const char *s2) static int static_list_compare_helper(const char *s1, const char *s2)
{ {
/* Are Both NULL */ /* extra (!s1 && !s2) to keep SA happy */
if (s1 == s2) if (s1 == s2 || (!s1 && !s2))
return 0; return 0;
if (!s1 && s2) if (!s1 && s2)

View File

@ -129,6 +129,7 @@ static inline int add_nexthop(qpb_allocator_t *allocator, Fpm__AddRoute *msg,
} }
// TODO: Use src. // TODO: Use src.
(void)src;
return 1; return 1;
} }