Skip to content

WIP Enable scan-build-7 on Drone. #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ name: scan-build

steps:
- name: bootstrap
image: signalwire/freeswitch-public-base:stretch
image: signalwire/freeswitch-public-base
pull: always
commands:
- ./autogen.sh

- name: configure
image: signalwire/freeswitch-public-base:stretch
image: signalwire/freeswitch-public-base
pull: always
commands:
- ./configure --with-pic --without-doxygen --disable-stun

- name: scan-build
image: signalwire/freeswitch-public-base:stretch
image: signalwire/freeswitch-public-base
pull: always
commands:
- apt-get update && apt-get install -y clang-tools-7
- mkdir -p scan-build
- echo '#!/bin/bash\nscan-build-4.0 -o ./scan-build/ make -j`nproc --all` |& tee ./scan-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./scan-build-status.txt\n' > scan.sh
- echo '#!/bin/bash\nscan-build-7 -o ./scan-build/ make -j`nproc --all` |& tee ./scan-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./scan-build-status.txt\n' > scan.sh
- chmod +x scan.sh
- ./scan.sh
- exitstatus=`cat ./scan-build-status.txt`
Expand All @@ -46,6 +47,6 @@ trigger:

---
kind: signature
hmac: ac8a02442523f785e8d9eef2a667e664b3bd5ec12b858dcc6736518ea18ff266
hmac: bd5e0fc5737be370c6550b9f3a8b26b5fefb7738e7d6997fc2f2e28b5c6fc5c0

...
1 change: 1 addition & 0 deletions libsofia-sip-ua/msg/msg_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,7 @@ int msg_serialize(msg_t *msg, msg_pub_t *pub)
if (pub == NULL)
pub = msg->m_object;

assert(pub);
/* There must be a first line */
if (pub->msg_request)
h = pub->msg_request;
Expand Down
8 changes: 4 additions & 4 deletions libsofia-sip-ua/nta/nta.c
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ int agent_init_via(nta_agent_t *self, tport_t *primaries, int use_maddr)

/* Set via field magic for the tports */
for (tp = primaries; tp; tp = tport_next(tp)) {
assert(via->v_common->h_data == tp);
assert(via->v_common && via->v_common->h_data == tp);
v = tport_magic(tp);
tport_set_magic(tp, new_via);
msg_header_free(self->sa_home, (void *)v);
Expand Down Expand Up @@ -3431,7 +3431,7 @@ void agent_recv_response(nta_agent_t *agent,
return;
}

if (sip->sip_cseq->cs_method == sip_method_invite
if (sip->sip_cseq && sip->sip_cseq->cs_method == sip_method_invite
&& 200 <= sip->sip_status->st_status
&& sip->sip_status->st_status < 300
/* Exactly one Via header, belonging to us */
Expand Down Expand Up @@ -5669,14 +5669,14 @@ void incoming_queue(incoming_queue_t *queue,
nta_incoming_t *irq)
{
if (irq->irq_queue == queue) {
assert(queue->q_timeout == 0);
assert(queue && queue->q_timeout == 0);
return;
}

if (incoming_is_queued(irq))
incoming_remove(irq);

assert(*queue->q_tail == NULL);
assert(queue && *queue->q_tail == NULL);

irq->irq_timeout = set_timeout(irq->irq_agent, queue->q_timeout);

Expand Down
2 changes: 2 additions & 0 deletions libsofia-sip-ua/nua/nua_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -4402,6 +4402,8 @@ void session_timer_store(struct session_timer *t,
sip_supported_t const *supported = sip->sip_supported;
sip_session_expires_t const *x = sip->sip_session_expires;

assert(t);

t->remote.require = require && sip_has_feature(require, "timer");
t->remote.supported =
t->remote.supported || (supported && sip_has_feature(supported, "timer"));
Expand Down
4 changes: 3 additions & 1 deletion libsofia-sip-ua/sdp/sdp_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,11 +1770,13 @@ static void parse_descs(sdp_parser_t *p,
bandwidths = &(*bandwidths)->b_next;
break;

case 'i':
case 'i':
assert(m);
parse_information(p, rest, &m->m_information);
break;

case 'k':
assert(m);
parse_key(p, rest, &m->m_key);
break;

Expand Down
1 change: 1 addition & 0 deletions libsofia-sip-ua/soa/soa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,7 @@ int soa_description_set(soa_session_t *ss,
sdp_str0_new = sdp_str_new;

if (sdp_new && printer && sdp_str_new && sdp_str0_new) {
assert(ssd);
tbf1 = ssd->ssd_sdp, tbf2 = ssd->ssd_printer;
tbf3 = (void *)ssd->ssd_str, tbf4 = (void *)ssd->ssd_unparsed;

Expand Down
7 changes: 7 additions & 0 deletions libsofia-sip-ua/sresolv/sres.c
Original file line number Diff line number Diff line change
Expand Up @@ -3748,6 +3748,12 @@ static
sres_record_t *
sres_create_record(sres_resolver_t *res, sres_message_t *m, int nth)
{
#ifdef __clang_analyzer__
(void)res;
(void)m;
(void)nth;
return NULL;
#else
sres_cache_t *cache = res->res_cache;
sres_record_t *sr, sr0[1];

Expand Down Expand Up @@ -3841,6 +3847,7 @@ sres_create_record(sres_resolver_t *res, sres_message_t *m, int nth)
sres_cache_free_record(cache, sr);
SU_DEBUG_5(("%s: %s\n", "sres_create_record", m->m_error));
return NULL;
#endif
}

/** Decode SOA record */
Expand Down
4 changes: 4 additions & 0 deletions libsofia-sip-ua/su/sofia-sip/su_tag_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <sofia-sip/su_tag_class.h>
#endif

#include <assert.h>

SOFIA_BEGIN_DECLS

#define tt_next tt_class->tc_next
Expand Down Expand Up @@ -69,6 +71,8 @@ su_inline tagi_t const *t_next(tagi_t const *t)
{
tag_type_t tt = TAG_TYPE_OF(t);

assert(tt->tt_class);

if (tt->tt_next)
return tt->tt_next(t);
else
Expand Down
4 changes: 2 additions & 2 deletions libsofia-sip-ua/su/su_select_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ int su_select_port_wait_events(su_port_t *self, su_duration_t tout)
ser->ser_wait->revents = 0;

if (ser->ser_wait->events & SU_WAIT_IN)
if (FD_ISSET(fd, rset)) ser->ser_wait->revents |= SU_WAIT_IN, n--;
if (rset && FD_ISSET(fd, rset)) ser->ser_wait->revents |= SU_WAIT_IN, n--;
if (ser->ser_wait->events & SU_WAIT_OUT)
if (FD_ISSET(fd, wset)) ser->ser_wait->revents |= SU_WAIT_OUT, n--;
if (wset && FD_ISSET(fd, wset)) ser->ser_wait->revents |= SU_WAIT_OUT, n--;

if (ser->ser_wait->revents) {
magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
Expand Down
60 changes: 57 additions & 3 deletions libsofia-sip-ua/su/su_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,62 @@ su_inline void *timers_alloc(void *argument, void *memory, size_t size)
#pragma clang diagnostic ignored "-Wunused-function"
#endif

HEAP_BODIES(su_inline, su_timer_queue_t, timers_, su_timer_t *,
timers_less, timers_set, timers_alloc, NULL);
//HEAP_BODIES(su_inline, su_timer_queue_t, timers_, su_timer_t *,
// timers_less, timers_set, timers_alloc, NULL);
static __inline int timers_resize(void* realloc_arg, su_timer_queue_t h[1], size_t new_size)
{
struct timers_priv { size_t _size, _used; su_timer_t* _heap[2]; };
struct timers_priv* _priv; size_t _offset = (((size_t) & (((struct timers_priv*)0)->_heap[1])) - 1) / sizeof(su_timer_t*); size_t _min_size = 32 - _offset; size_t _bytes; size_t _used = 0; _priv = *(void**)h;
if (_priv) { if (new_size == 0) new_size = 2 * _priv->_size + _offset + 1; _used = _priv->_used; if (new_size < _used) new_size = _used; }
if (new_size < _min_size) new_size = _min_size; _bytes = (_offset + 1 + new_size) * sizeof(su_timer_t*);
assert(_bytes);
(void)realloc_arg; _priv = timers_alloc(realloc_arg, *(struct timers_priv**)h, _bytes);
if (!_priv) return -1; *(struct timers_priv**)h = _priv; _priv->_size = new_size; _priv->_used = _used; return 0;
}
static __inline int timers_free(void* realloc_arg, su_timer_queue_t h[1])
{
(void)realloc_arg; *(void**)h = timers_alloc(realloc_arg, *(void**)h, 0); return 0;
}
static __inline int timers_is_full(su_timer_queue_t h)
{
struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; };
struct timers_priv* _priv = *(void**)&h; return _priv == ((void*)0) || _priv->_used >= _priv->_size;
}
static __inline int timers_add(su_timer_queue_t h, su_timer_t* e)
{
struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; };
struct timers_priv* _priv = *(void**)&h; su_timer_t** heap = _priv->_heap - 1; size_t i, parent;
if (_priv == ((void*)0) || _priv->_used >= _priv->_size) return -1;
for (i = ++_priv->_used; i > 1; i = parent) {
parent = i / 2;
if (!timers_less(e, heap[parent])) break; timers_set(heap, i, heap[parent]);
} timers_set(heap, i, e); return 0;
}
static __inline su_timer_t* timers_remove(su_timer_queue_t h, size_t index)
{
struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; };
struct timers_priv* _priv = *(void**)&h; su_timer_t** heap = _priv->_heap - 1;
su_timer_t* retval[1]; su_timer_t* e; size_t top, left, right, move;
if (index - 1 >= _priv->_used) return (((void*)0));
move = _priv->_used--; timers_set(retval, 0, heap[index]);
for (top = index;; index = top) {
left = 2 * top; right = 2 * top + 1;
if (left >= move) break; if (right < move&& timers_less(heap[right], heap[left])) top = right; else top = left; timers_set(heap, index, heap[top]);
}
if (index == move) return *retval; e = heap[move];
for (; index > 1; index = top) {
top = index / 2;
if (!timers_less(e, heap[top])) break; timers_set(heap, index, heap[top]);
}
timers_set(heap, index, e); return *retval;
}
static __inline su_timer_t* timers_get(su_timer_queue_t h, size_t index)
{
struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; };
struct timers_priv* _priv = *(void**)&h; if (--index >= _priv->_used) return (((void*)0)); return _priv->_heap[index];
}
static __inline size_t timers_size(su_timer_queue_t const h) { struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; }; struct timers_priv* _priv = *(void**)&h; return _priv ? _priv->_size : 0; } static __inline size_t timers_used(su_timer_queue_t const h) { struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; }; struct timers_priv* _priv = *(void**)&h; return _priv ? _priv->_used : 0; } static int timers__less(void* h, size_t a, size_t b) { su_timer_t** _heap = h; return timers_less(_heap[a], _heap[b]); } static void timers__swap(void* h, size_t a, size_t b) { su_timer_t** _heap = h; su_timer_t* _swap = _heap[a]; timers_set(_heap, a, _heap[b]); timers_set(_heap, b, _swap); } static __inline void timers_sort(su_timer_queue_t h) { struct timers_priv { size_t _size, _used; su_timer_t* _heap[1]; }; struct timers_priv* _priv = *(void**)&h; if (_priv) su_smoothsort(_priv->_heap - 1, 1, _priv->_used, timers__less, timers__swap); } extern int const timers_dummy_heap;


#ifdef __clang__
#pragma clang diagnostic pop
Expand Down Expand Up @@ -241,7 +295,7 @@ su_timer_set0(su_timer_queue_t *timers,

if (timers_is_full(timers[0])) {
timers_resize(NULL, timers, 0);
assert(!timers_is_full(timers[0]));
// assert(!timers_is_full(timers[0]));
if (timers_is_full(timers[0]))
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion libsofia-sip-ua/tport/tport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ int tport_accept(tport_primary_t *pri, int events)
{
tport_t *self;
su_addrinfo_t ai[1];
su_sockaddr_t su[1];
su_sockaddr_t su[1] = { 0 };
socklen_t sulen = sizeof su;
su_socket_t s = INVALID_SOCKET, l = pri->pri_primary->tp_socket;
char const *reason = "accept";
Expand Down
2 changes: 1 addition & 1 deletion libsofia-sip-ua/tport/tport_type_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ int tport_tls_accept(tport_primary_t *pri, int events)
{
tport_t *self;
su_addrinfo_t ai[1];
su_sockaddr_t su[1];
su_sockaddr_t su[1] = { 0 };
socklen_t sulen = sizeof su;
su_socket_t s = INVALID_SOCKET, l = pri->pri_primary->tp_socket;
char const *reason = "accept";
Expand Down
2 changes: 1 addition & 1 deletion libsofia-sip-ua/url/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ void url_string_update(su_md5_t *md5, char const *s)
int have_authority = 1;
enum url_type_e type = url_any;
char const *at, *colon;
char schema[48];
char schema[48] = { 0 };

if (s == NULL || strlen(s) == 0 || strcmp(s, "*") == 0) {
su_md5_update(md5, "*\0\0*", 4);
Expand Down