more code analysis mostly trivial except string formating changes

This commit is contained in:
Jeff Lenk 2011-06-01 22:36:19 -05:00
parent 5409caca22
commit 5923f71a84
6 changed files with 30 additions and 24 deletions

View File

@ -231,7 +231,7 @@ void stfu_n_debug(stfu_instance_t *i, const char *name)
void stfu_n_report(stfu_instance_t *i, stfu_report_t *r)
{
assert(i);
stfu_assert(i);
r->qlen = i->qlen;
r->packet_in_count = i->period_packet_in_count;
r->clean_count = i->period_clean_count;
@ -580,7 +580,7 @@ static int stfu_n_find_any_frame(stfu_instance_t *in, stfu_queue_t *queue, stfu_
uint32_t i = 0;
stfu_frame_t *frame = NULL;
assert(r_frame);
stfu_assert(r_frame);
*r_frame = NULL;

View File

@ -40,6 +40,13 @@ extern "C" {
#include <string.h>
#include <stdarg.h>
#if (_MSC_VER >= 1400) // VC8+
#define stfu_assert(expr) assert(expr);__analysis_assume( expr )
#endif
#ifndef stfu_assert
#define stfu_assert(_x) assert(_x)
#endif
#ifdef _MSC_VER
#ifndef uint32_t

View File

@ -3643,7 +3643,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
switch_snprintf(tmp, sizeof(tmp), "%d", billsec);
switch_channel_set_variable(channel, "billsec", tmp);
switch_snprintf(tmp, sizeof(tmp), "%d", progresssec);
switch_snprintf(tmp, sizeof(tmp), "%"SWITCH_TIME_T_FMT, progresssec);
switch_channel_set_variable(channel, "progresssec", tmp);
switch_snprintf(tmp, sizeof(tmp), "%d", answersec);
@ -3652,7 +3652,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
switch_snprintf(tmp, sizeof(tmp), "%d", waitsec);
switch_channel_set_variable(channel, "waitsec", tmp);
switch_snprintf(tmp, sizeof(tmp), "%d", progress_mediasec);
switch_snprintf(tmp, sizeof(tmp), "%"SWITCH_TIME_T_FMT, progress_mediasec);
switch_channel_set_variable(channel, "progress_mediasec", tmp);
switch_snprintf(tmp, sizeof(tmp), "%d", legbillsec);

View File

@ -105,7 +105,7 @@ static switch_status_t console_xml_config(void)
for (param = switch_xml_child(settings, "key"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
int i = atoi(var);
i = atoi(var);
if ((i < 1) || (i > 12)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Keybind %s is invalid, range is from 1 to 12\n", var);
} else {
@ -913,7 +913,7 @@ static unsigned char console_fnkey_pressed(int i)
{
char *c, *cmd;
assert((i > 0) && (i <= 12));
switch_assert((i > 0) && (i <= 12));
c = console_fnkeys[i - 1];
@ -1675,6 +1675,7 @@ SWITCH_DECLARE(void) switch_console_sort_matches(switch_console_callback_match_t
sort[3] = sort[2] ? sort[2]->next : NULL;
for (j = 1; j <= (matches->count - i); j++) {
switch_assert(sort[1] && sort[2]);
if (strcmp(sort[1]->val, sort[2]->val) > 0) {
sort[1]->next = sort[3];
sort[2]->next = sort[1];

View File

@ -1302,11 +1302,10 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
llen = strlen(hp->name) + strlen(encode_buf) + 8;
if ((len + llen) > dlen) {
char *m;
char *m = buf;
dlen += (blocksize + (len + llen));
if ((m = realloc(buf, dlen))) {
if (!(buf = realloc(buf, dlen))) {
buf = m;
} else {
abort();
}
}
@ -1329,11 +1328,10 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
}
if ((len + llen) > dlen) {
char *m;
char *m = buf;
dlen += (blocksize + (len + llen));
if ((m = realloc(buf, dlen))) {
if (!(buf = realloc(buf, dlen))) {
buf = m;
} else {
abort();
}
}

View File

@ -1125,12 +1125,12 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE * fp)
do {
len += (l = fread((s + len), 1, SWITCH_XML_BUFSIZE, fp));
if (l == SWITCH_XML_BUFSIZE) {
char *tmp = (char *) realloc(s, len + SWITCH_XML_BUFSIZE);
if (!tmp) {
free(s);
char *tmp = s;
s = (char *) realloc(s, len + SWITCH_XML_BUFSIZE);
if (!s) {
free(tmp);
return NULL;
}
s = tmp;
}
} while (s && l == SWITCH_XML_BUFSIZE);
@ -2279,10 +2279,10 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len,
*s = switch_xml_ampencode(txt + start, xml->off - start, s, len, max, 0);
while (*len + strlen(xml->name) + 5 + (strlen(XML_INDENT) * (*count)) + 1 > *max) { /* reallocate s */
char *tmp = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
if (!tmp)
return *s;
*s = tmp;
char *tmp = *s;
*s = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
if (!*s)
return tmp;
}
if (*len && *(*s + (*len) - 1) == '>') {
@ -2335,10 +2335,10 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len,
}
while (*len + strlen(xml->name) + 5 + (strlen(XML_INDENT) * (*count)) > *max) { /* reallocate s */
char *tmp = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
if (!tmp)
return *s;
*s = tmp;
char *tmp = *s;
*s = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
if (!*s)
return tmp;
}
if (xml->child || xml->txt) {