1
1
* fix Wstrict-prototypes warnings found by clang

also fix usage_long() call

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wunreachable-code-break warnings found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wshadow warnings found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wmissing-noreturn warning found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* ix memory leak found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix Wmisleading-indentation warnings raised by gcc-6

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix warning: Value stored to 'ptr' during its initialization is never read found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix warning: The left operand of '>' is a garbage value found by clang

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>

* fix memory leak in global cleanup

Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Этот коммит содержится в:
Gabriel Ganne 2017-04-20 22:33:15 +02:00 коммит произвёл Bruce A. Mah
родитель 5e52a8460b
Коммит 5ab2132ce3
6 изменённых файлов: 27 добавлений и 21 удалений

Просмотреть файл

@ -48,9 +48,10 @@ const char *cJSON_GetErrorPtr(void) {return global_ep;}
static int cJSON_strcasecmp(const char *s1,const char *s2) static int cJSON_strcasecmp(const char *s1,const char *s2)
{ {
if (!s1) return (s1==s2)?0:1;if (!s2) return 1; if (!s1) return (s1==s2)?0:1;
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0; if (!s2) return 1;
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
} }
static void *(*cJSON_malloc)(size_t sz) = malloc; static void *(*cJSON_malloc)(size_t sz) = malloc;
@ -202,7 +203,7 @@ static unsigned parse_hex4(const char *str)
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
static const char *parse_string(cJSON *item,const char *str,const char **ep) static const char *parse_string(cJSON *item,const char *str,const char **ep)
{ {
const char *ptr=str+1,*end_ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2; const char *ptr,*end_ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
if (*str!='\"') {*ep=str;return 0;} /* not a string! */ if (*str!='\"') {*ep=str;return 0;} /* not a string! */
while (*end_ptr!='\"' && *end_ptr && ++len) while (*end_ptr!='\"' && *end_ptr && ++len)
@ -620,7 +621,8 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
len=(fmt?1:0)+(child->next?1:0); len=(fmt?1:0)+(child->next?1:0);
ptr=ensure(p,len+1); if (!ptr) return 0; ptr=ensure(p,len+1); if (!ptr) return 0;
if (child->next) *ptr++=','; if (child->next) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0; if (fmt) *ptr++='\n';
*ptr=0;
p->offset+=len; p->offset+=len;
child=child->next; child=child->next;
} }
@ -670,7 +672,8 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
*ptr++=':';if (fmt) *ptr++='\t'; *ptr++=':';if (fmt) *ptr++='\t';
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]); strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
if (i!=numentries-1) *ptr++=','; if (i!=numentries-1) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0; if (fmt) *ptr++='\n';
*ptr=0;
cJSON_free(names[i]);cJSON_free(entries[i]); cJSON_free(names[i]);cJSON_free(entries[i]);
} }
@ -700,7 +703,7 @@ void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddIte
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));} void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0; cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;} if (c->prev) {c->prev->next=c->next;}if (c->next) {c->next->prev=c->prev;}if (c==array->child) {array->child=c->next;} c->prev=c->next=0;return c;}
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));} void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;} cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));} void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}

Просмотреть файл

@ -354,9 +354,9 @@ iperf_set_test_burst(struct iperf_test *ipt, int burst)
} }
void void
iperf_set_test_server_port(struct iperf_test *ipt, int server_port) iperf_set_test_server_port(struct iperf_test *ipt, int srv_port)
{ {
ipt->server_port = server_port; ipt->server_port = srv_port;
} }
void void
@ -445,9 +445,9 @@ iperf_set_test_unit_format(struct iperf_test *ipt, char unit_format)
} }
void void
iperf_set_test_bind_address(struct iperf_test *ipt, char *bind_address) iperf_set_test_bind_address(struct iperf_test *ipt, char *bnd_address)
{ {
ipt->bind_address = strdup(bind_address); ipt->bind_address = strdup(bnd_address);
} }
void void
@ -759,11 +759,11 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
#if defined(HAVE_SCTP) #if defined(HAVE_SCTP)
set_protocol(test, Psctp); set_protocol(test, Psctp);
client_flag = 1; client_flag = 1;
break;
#else /* HAVE_SCTP */ #else /* HAVE_SCTP */
i_errno = IEUNIMP; i_errno = IEUNIMP;
return -1; return -1;
#endif /* HAVE_SCTP */ #endif /* HAVE_SCTP */
break;
case OPT_NUMSTREAMS: case OPT_NUMSTREAMS:
#if defined(linux) || defined(__FreeBSD__) #if defined(linux) || defined(__FreeBSD__)
@ -1622,6 +1622,7 @@ send_results(struct iperf_test *test)
} }
cJSON_AddStringToObject(j, "server_output_text", output); cJSON_AddStringToObject(j, "server_output_text", output);
free(output);
} }
} }
@ -2489,7 +2490,7 @@ iperf_print_results(struct iperf_test *test)
struct iperf_stream *sp = NULL; struct iperf_stream *sp = NULL;
iperf_size_t bytes_sent, total_sent = 0; iperf_size_t bytes_sent, total_sent = 0;
iperf_size_t bytes_received, total_received = 0; iperf_size_t bytes_received, total_received = 0;
double start_time, end_time, avg_jitter = 0.0, lost_percent; double start_time, end_time = 0.0, avg_jitter = 0.0, lost_percent;
double bandwidth; double bandwidth;
/* print final summary for all intervals */ /* print final summary for all intervals */

Просмотреть файл

@ -169,7 +169,7 @@ void iperf_reporter_callback(struct iperf_test * test);
* returns NULL on failure * returns NULL on failure
* *
*/ */
struct iperf_test *iperf_new_test(); struct iperf_test *iperf_new_test(void);
int iperf_defaults(struct iperf_test * testp); int iperf_defaults(struct iperf_test * testp);
@ -222,8 +222,8 @@ int iperf_send(struct iperf_test *, fd_set *) /* __attribute__((hot)) */;
int iperf_recv(struct iperf_test *, fd_set *); int iperf_recv(struct iperf_test *, fd_set *);
void iperf_catch_sigend(void (*handler)(int)); void iperf_catch_sigend(void (*handler)(int));
void iperf_got_sigend(struct iperf_test *test) __attribute__ ((noreturn)); void iperf_got_sigend(struct iperf_test *test) __attribute__ ((noreturn));
void usage(); void usage(void);
void usage_long(); void usage_long(FILE * f);
void warning(char *); void warning(char *);
int iperf_exchange_results(struct iperf_test *); int iperf_exchange_results(struct iperf_test *);
int iperf_init_test(struct iperf_test *); int iperf_init_test(struct iperf_test *);

Просмотреть файл

@ -82,7 +82,7 @@ iperf_errexit(struct iperf_test *test, const char *format, ...)
int i_errno; int i_errno;
char * char *
iperf_strerror(int i_errno) iperf_strerror(int int_errno)
{ {
static char errstr[256]; static char errstr[256];
int len, perr, herr; int len, perr, herr;
@ -91,7 +91,7 @@ iperf_strerror(int i_errno)
len = sizeof(errstr); len = sizeof(errstr);
memset(errstr, 0, len); memset(errstr, 0, len);
switch (i_errno) { switch (int_errno) {
case IENONE: case IENONE:
snprintf(errstr, len, "no error"); snprintf(errstr, len, "no error");
break; break;

Просмотреть файл

@ -434,6 +434,9 @@ cleanup_server(struct iperf_test *test)
tmr_cancel(test->omit_timer); tmr_cancel(test->omit_timer);
test->omit_timer = NULL; test->omit_timer = NULL;
} }
if (test->congestion_used != NULL) {
free(test->congestion_used);
}
} }

Просмотреть файл

@ -100,7 +100,7 @@ main(int argc, char **argv)
if (iperf_parse_arguments(test, argc, argv) < 0) { if (iperf_parse_arguments(test, argc, argv) < 0) {
iperf_err(test, "parameter error - %s", iperf_strerror(i_errno)); iperf_err(test, "parameter error - %s", iperf_strerror(i_errno));
fprintf(stderr, "\n"); fprintf(stderr, "\n");
usage_long(); usage_long(stdout);
exit(1); exit(1);
} }
@ -115,7 +115,7 @@ main(int argc, char **argv)
static jmp_buf sigend_jmp_buf; static jmp_buf sigend_jmp_buf;
static void static void __attribute__ ((noreturn))
sigend_handler(int sig) sigend_handler(int sig)
{ {
longjmp(sigend_jmp_buf, 1); longjmp(sigend_jmp_buf, 1);
@ -153,7 +153,6 @@ run(struct iperf_test *test)
iperf_err(test, "error - %s", iperf_strerror(i_errno)); iperf_err(test, "error - %s", iperf_strerror(i_errno));
if (rc < -1) { if (rc < -1) {
iperf_errexit(test, "exiting"); iperf_errexit(test, "exiting");
break;
} }
} }
iperf_reset_test(test); iperf_reset_test(test);