| author | Peder Andersen | 2012-07-05 14:09:28 (EDT) |
|---|---|---|
| committer | Eugene Tarassov | 2012-08-01 12:15:34 (EDT) |
| commit | 8d7474846dbff8b9ce5762111416e8a92f981b61 (patch) (side-by-side diff) | |
| tree | 8d774964aaa4cd9b4662d9ecf9e235b0f8eab516 | |
| parent | 373ec268ab6649211e13216a25735a5b23afa51f (diff) | |
| download | org.eclipse.tcf.agent-8d7474846dbff8b9ce5762111416e8a92f981b61.zip org.eclipse.tcf.agent-8d7474846dbff8b9ce5762111416e8a92f981b61.tar.gz org.eclipse.tcf.agent-8d7474846dbff8b9ce5762111416e8a92f981b61.tar.bz2 | |
Agent: various compiler warning fixes
Includes fixes for VxWorks-specific logic, (missing function
declarations, etc.) and in particular, typing for 64-bit platforms.
Also fixes diab's reporting of unnecessary variable setting, and removes
a few simple conditionals which always evaluate to true.
27 files changed, 144 insertions, 141 deletions
diff --git a/agent/tcf/framework/base64.c b/agent/tcf/framework/base64.c index 96359ca..d70d6dc 100644 --- a/agent/tcf/framework/base64.c +++ b/agent/tcf/framework/base64.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -63,9 +63,8 @@ size_t write_base64(OutputStream * out, const char * buf0, size_t len) { const unsigned char * buf = (const unsigned char *)buf0; char obf[OBF_SIZE + 8]; - size_t obf_len; + size_t obf_len = 0; - obf_len = 0; while (pos < len) { int byte0 = buf[pos++]; obf[obf_len++] = int2char[byte0 >> 2]; @@ -94,7 +93,6 @@ size_t write_base64(OutputStream * out, const char * buf0, size_t len) { } if (obf_len > 0) { write_block_stream(out, obf, obf_len); - obf_len = 0; } assert(pos == len); return ((len + 2) / 3) * 4; @@ -106,7 +104,7 @@ size_t read_base64(InputStream * inp, char * buf, size_t buf_size) { assert(buf_size >= 3); while (pos + 3 <= buf_size) { - int n0 = 0, n1 = 0, n2 = 0, n3 = 0; + int n0, n1 = 0, n2 = 0, n3 = 0; int ch0, ch1, ch2, ch3; ch0 = peek_stream(inp); diff --git a/agent/tcf/framework/channel.c b/agent/tcf/framework/channel.c index 7bc5b41..5b7ad08 100644 --- a/agent/tcf/framework/channel.c +++ b/agent/tcf/framework/channel.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -92,7 +92,7 @@ static void write_block_all(OutputStream * out, const char * bytes, size_t size) static ssize_t splice_block_all(OutputStream * out, int fd, size_t size, int64_t * offset) { char buffer[0x400]; - ssize_t rd = 0; + ssize_t rd; assert(is_dispatch_thread()); if (size > sizeof(buffer)) size = sizeof(buffer); diff --git a/agent/tcf/framework/channel_tcp.c b/agent/tcf/framework/channel_tcp.c index 7d61c29..fc1c13f 100644 --- a/agent/tcf/framework/channel_tcp.c +++ b/agent/tcf/framework/channel_tcp.c @@ -509,7 +509,7 @@ static ssize_t tcp_splice_block_stream(OutputStream * out, int fd, size_t size, } #endif /* ENABLE_Splice */ { - ssize_t rd = 0; + ssize_t rd; char buffer[BUF_SIZE]; if (size > BUF_SIZE) size = BUF_SIZE; if (offset != NULL) { @@ -752,7 +752,7 @@ static void start_channel(Channel * channel) { static ChannelTCP * create_channel(int sock, int en_ssl, int server, int unix_domain) { const int i = 1; - ChannelTCP * c = NULL; + ChannelTCP * c; SSL * ssl = NULL; assert(sock >= 0); @@ -1154,7 +1154,7 @@ ChannelServer * channel_tcp_server(PeerServer * ps) { const char * reason = NULL; struct addrinfo hints; struct addrinfo * reslist = NULL; - struct addrinfo * res = NULL; + struct addrinfo * res; const char * host = peer_server_getprop(ps, "Host", NULL); const char * port = peer_server_getprop(ps, "Port", NULL); int def_port = 0; @@ -1184,7 +1184,7 @@ ChannelServer * channel_tcp_server(PeerServer * ps) { return NULL; } sock = -1; - reason = NULL; + for (res = reslist; res != NULL; res = res->ai_next) { sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (sock < 0) { @@ -1292,12 +1292,11 @@ static void channel_tcp_connect_done(void * args) { } void channel_tcp_connect(PeerServer * ps, ChannelConnectCallBack callback, void * callback_args) { - int error = 0; + int error; const char * host = peer_server_getprop(ps, "Host", NULL); const char * port = peer_server_getprop(ps, "Port", NULL); struct addrinfo hints; struct addrinfo * reslist = NULL; - struct addrinfo * res = NULL; ChannelConnectInfo * info = NULL; char port_str[16]; @@ -1312,6 +1311,7 @@ void channel_tcp_connect(PeerServer * ps, ChannelConnectCallBack callback, void error = loc_getaddrinfo(host, port, &hints, &reslist); if (error) error = set_gai_errno(error); if (!error) { + struct addrinfo * res; info = (ChannelConnectInfo *)loc_alloc_zero(sizeof(ChannelConnectInfo)); info->sock = -1; for (res = reslist; res != NULL; res = res->ai_next) { @@ -1366,11 +1366,9 @@ void channel_unix_connect(PeerServer * ps, ChannelConnectCallBack callback, void if (!error) set_socket_buffer_sizes(info->sock); if (error) { - if (info != NULL) { - if (info->sock >= 0) closesocket(info->sock); - loc_free(info->addr_buf); - loc_free(info); - } + if (info->sock >= 0) closesocket(info->sock); + loc_free(info->addr_buf); + loc_free(info); callback(callback_args, error, NULL); } else { diff --git a/agent/tcf/framework/context.c b/agent/tcf/framework/context.c index 06ffa80..5c0f630 100644 --- a/agent/tcf/framework/context.c +++ b/agent/tcf/framework/context.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -103,7 +103,7 @@ void add_context_event_listener(ContextEventListener * listener, void * client_d } size_t context_extension(size_t size) { - size_t offs = 0; + size_t offs; assert(!context_created); while (extension_size % sizeof(void *) != 0) extension_size++; offs = sizeof(Context) + extension_size; diff --git a/agent/tcf/framework/errors.c b/agent/tcf/framework/errors.c index 2957beb..95bb615 100644 --- a/agent/tcf/framework/errors.c +++ b/agent/tcf/framework/errors.c @@ -267,7 +267,7 @@ static const char * format_error_report_message(const char * fmt, char ** params in_quotes = 1; } else if (ch == '{') { - size_t j = 0; + size_t j; int index = 0; char type[16]; char style[16]; @@ -282,7 +282,7 @@ static const char * format_error_report_message(const char * fmt, char ** params ch = fmt[fmt_pos++]; if (j < sizeof(type) - 1) type[j++] = ch; } - type[j++] = 0; + type[j] = 0; if (fmt[fmt_pos] == ',') { fmt_pos++; j = 0; @@ -290,7 +290,7 @@ static const char * format_error_report_message(const char * fmt, char ** params ch = fmt[fmt_pos++]; if (j < sizeof(style) - 1) style[j++] = ch; } - style[j++] = 0; + style[j] = 0; } } if (index < param_cnt) append_format_parameter(type, style, params[index]); diff --git a/agent/tcf/framework/inputbuf.c b/agent/tcf/framework/inputbuf.c index d5626c3..a8b8735 100644 --- a/agent/tcf/framework/inputbuf.c +++ b/agent/tcf/framework/inputbuf.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -198,7 +198,6 @@ void ibuf_flush(InputBuf * ibuf) { void ibuf_read_done(InputBuf * ibuf, size_t len) { unsigned char * inp; - assert(len >= 0); if (len == 0) { ibuf_eof(ibuf); return; diff --git a/agent/tcf/framework/json.c b/agent/tcf/framework/json.c index e05689b..1303846 100644 --- a/agent/tcf/framework/json.c +++ b/agent/tcf/framework/json.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -66,7 +66,7 @@ void json_write_ulong(OutputStream * out, unsigned long n) { json_write_ulong(out, n / 10); n = n % 10; } - write_stream(out, n + '0'); + write_stream(out, (unsigned int) n + '0'); } void json_write_long(OutputStream * out, long n) { @@ -257,7 +257,7 @@ int json_read_string(InputStream * inp, char * str, size_t size) { } char * json_read_alloc_string(InputStream * inp) { - char * str = NULL; + char * str; int ch = read_stream(inp); if (ch == 'n') { json_test_char(inp, 'u'); @@ -307,7 +307,7 @@ int json_read_boolean(InputStream * inp) { } long json_read_long(InputStream * inp) { - long res = 0; + long res; int neg = 0; int ch = read_stream(inp); if (ch == '-') { @@ -327,7 +327,7 @@ long json_read_long(InputStream * inp) { } unsigned long json_read_ulong(InputStream * inp) { - unsigned long res = 0; + unsigned long res; int neg = 0; int ch = read_stream(inp); if (ch == '-') { @@ -347,7 +347,7 @@ unsigned long json_read_ulong(InputStream * inp) { } int64_t json_read_int64(InputStream * inp) { - int64_t res = 0; + int64_t res; int neg = 0; int ch = read_stream(inp); if (ch == '-') { @@ -367,7 +367,7 @@ int64_t json_read_int64(InputStream * inp) { } uint64_t json_read_uint64(InputStream * inp) { - uint64_t res = 0; + uint64_t res; int neg = 0; int ch = read_stream(inp); if (ch == '-') { @@ -389,7 +389,7 @@ uint64_t json_read_uint64(InputStream * inp) { double json_read_double(InputStream * inp) { char buf[256]; int pos = 0; - double n = 0; + double n; char * end = buf; for (;;) { @@ -417,7 +417,7 @@ double json_read_double(InputStream * inp) { break; } if (pos == 0) exception(ERR_JSON_SYNTAX); - buf[pos++] = 0; + buf[pos] = 0; n = strtod(buf, &end); if (*end != 0) exception(ERR_JSON_SYNTAX); return n; @@ -472,8 +472,8 @@ char ** json_read_alloc_string_array(InputStream * inp, int * cnt) { unsigned i; size_t j; - char * str = NULL; - char ** arr = NULL; + char * str; + char ** arr; buf_pos = 0; @@ -770,7 +770,7 @@ void json_splice_binary_offset(OutputStream * out, int fd, size_t size, int64_t json_write_binary_start(&state, out, size); while (size > 0) { - ssize_t rd = 0; + ssize_t rd; if (offset != NULL) { rd = pread(fd, buffer, size < sizeof(buffer) ? size : sizeof(buffer), (off_t)*offset); if (rd > 0) *offset += rd; @@ -880,7 +880,7 @@ static void skip_object(InputStream * inp) { } char * json_read_object(InputStream * inp) { - char * str = NULL; + char * str; buf_pos = 0; skip_object(inp); buf_add(0); @@ -930,7 +930,7 @@ int read_errno(InputStream * inp) { json_test_char(inp, ':'); if (err == NULL) err = create_error_report(); if (strcmp(name, "Code") == 0) { - err->code = json_read_long(inp); + err->code = (int) json_read_long(inp); } else if (strcmp(name, "Time") == 0) { err->time_stamp = json_read_uint64(inp); @@ -979,7 +979,7 @@ static void write_error_props(OutputStream * out, ErrorReport * rep) { } if (rep->param_cnt > 0) { - int n = 0; + int n; write_stream(out, ','); json_write_string(out, "Params"); write_stream(out, ':'); diff --git a/agent/tcf/framework/mdep.c b/agent/tcf/framework/mdep.c index 5e59004..2b6f2ea 100644 --- a/agent/tcf/framework/mdep.c +++ b/agent/tcf/framework/mdep.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -1040,12 +1040,12 @@ int loc_getaddrinfo(const char * nodename, const char * servname, int flags = 0; int socktype = 0; int protocol = 0; - int err = 0; + int err; int port = 0; char * canonname = NULL; - const char * host = NULL; - struct addrinfo * ai = NULL; - union sockaddr_union * sa = NULL; + const char * host; + struct addrinfo * ai; + union sockaddr_union * sa; *res = NULL; @@ -1070,7 +1070,7 @@ int loc_getaddrinfo(const char * nodename, const char * servname, } if (servname != NULL && servname[0] != 0) { char * p = NULL; - port = strtol(servname, &p, 10); + port = (unsigned int) strtoul(servname, &p, 10); if (port < 0 || port > 0xffff || *p != '\0' || p == servname) { return 1; } @@ -1102,12 +1102,12 @@ int loc_getaddrinfo(const char * nodename, const char * servname, switch (family) { case AF_INET: assert(sa->sin.sin_family == AF_INET); - sa->sin.sin_port = htons(port); + sa->sin.sin_port = (unsigned short) htons(port); ai->ai_addrlen = sizeof(struct sockaddr_in); break; case AF_INET6: assert(sa->sin6.sin6_family == AF_INET6); - sa->sin6.sin6_port = htons(port); + sa->sin6.sin6_port = (unsigned short) htons(port); ai->ai_addrlen = sizeof(struct sockaddr_in6); break; default: diff --git a/agent/tcf/framework/mdep.h b/agent/tcf/framework/mdep.h index da1c95b..bc480bb 100644 --- a/agent/tcf/framework/mdep.h +++ b/agent/tcf/framework/mdep.h @@ -237,6 +237,7 @@ extern char * canonicalize_file_name(const char * path); #include <version.h> #include <unistd.h> #include <socket.h> +#include <string.h> /* for memset(), strlcpy(), strcmp() */ #include <strings.h> #include <sys/ioctl.h> #include <selectLib.h> diff --git a/agent/tcf/framework/myalloc.c b/agent/tcf/framework/myalloc.c index 00f10f8..50b9af0 100644 --- a/agent/tcf/framework/myalloc.c +++ b/agent/tcf/framework/myalloc.c @@ -77,7 +77,7 @@ void tmp_gc(void) { } void * tmp_alloc(size_t size) { - void * p = NULL; + void * p; assert(is_dispatch_thread()); if (!tmp_gc_posted) { post_event(gc_event, NULL); diff --git a/agent/tcf/framework/outputbuf.c b/agent/tcf/framework/outputbuf.c index 6764cf7..f7fc1ab 100644 --- a/agent/tcf/framework/outputbuf.c +++ b/agent/tcf/framework/outputbuf.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (q) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (q) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -36,7 +36,7 @@ void output_queue_add(OutputQueue * q, const void * buf, size_t size) { if (q->error) return; if (q->queue.next != q->queue.prev) { /* Append data to the last pending buffer */ - size_t gap = 0; + size_t gap; OutputBuffer * bf = link2buf(q->queue.prev); assert(bf->buf_pos == 0); gap = sizeof(bf->buf) - bf->buf_len; @@ -51,7 +51,7 @@ void output_queue_add(OutputQueue * q, const void * buf, size_t size) { } while (size > 0) { size_t len = size; - OutputBuffer * bf = NULL; + OutputBuffer * bf; if (list_is_empty(&q->pool)) { bf = (OutputBuffer *)loc_alloc_zero(sizeof(OutputBuffer)); bf->queue = q; diff --git a/agent/tcf/framework/trace.c b/agent/tcf/framework/trace.c index f652837..c319277 100644 --- a/agent/tcf/framework/trace.c +++ b/agent/tcf/framework/trace.c @@ -116,7 +116,7 @@ int parse_trace_mode(const char * mode, int * result) { for(;;) { if (*mode >= '0' && *mode <= '9') { char * endptr; - *result |= strtoul(mode, &endptr, 0); + *result |= (int) strtoul(mode, &endptr, 0); mode = endptr; } else { diff --git a/agent/tcf/main/cmdline.c b/agent/tcf/main/cmdline.c index 4c9c030..e123f40 100644 --- a/agent/tcf/main/cmdline.c +++ b/agent/tcf/main/cmdline.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -90,7 +90,7 @@ static void channel_connected(Channel * c) { } static void channel_disconnected(Channel * c) { - size_t i = 0; + size_t i; if (chan == c) chan = NULL; protocol_release(c->protocol); for (i = 0; i < disconnect_hnd_count; ++i) disconnect_hnds[i](c); @@ -264,7 +264,7 @@ static void connect_callback(void * args, int error, Channel * c) { cmd_done(error); } else { - size_t i = 0; + size_t i; c->connected = channel_connected; c->disconnected = channel_disconnected; c->protocol = proto; @@ -278,7 +278,7 @@ static void connect_callback(void * args, int error, Channel * c) { } static int cmd_connect(char * s) { - PeerServer * ps = NULL; + PeerServer * ps; ps = channel_peer_from_url(s); if (ps == NULL) { diff --git a/agent/tcf/main/main.c b/agent/tcf/main/main.c index 9f88c97..b6f74a7 100644 --- a/agent/tcf/main/main.c +++ b/agent/tcf/main/main.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -158,6 +158,7 @@ static void show_help(void) { #endif #if defined(_WRS_KERNEL) +int tcf(void); int tcf(void) { #else int main(int argc, char ** argv) { @@ -170,8 +171,8 @@ int main(int argc, char ** argv) { int interactive = 0; int print_server_properties = 0; const char * url = "TCP:"; - Protocol * proto = NULL; - TCFBroadcastGroup * bcg = NULL; + Protocol * proto; + TCFBroadcastGroup * bcg; ini_mdep(); ini_trace(); diff --git a/agent/tcf/main/main_client.c b/agent/tcf/main/main_client.c index 74696a8..9fee7e4 100644 --- a/agent/tcf/main/main_client.c +++ b/agent/tcf/main/main_client.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -48,6 +48,7 @@ static Protocol * proto; */ #if defined(_WRS_KERNEL) +int tcf_client(void); int tcf_client(void) { #else int main(int argc, char ** argv) { diff --git a/agent/tcf/main/main_log.c b/agent/tcf/main/main_log.c index f9b84e7..1b6385a 100644 --- a/agent/tcf/main/main_log.c +++ b/agent/tcf/main/main_log.c @@ -70,8 +70,8 @@ static void connect_done(void * args, int error, Channel * c2) { static void connect_dest(void * x) { Channel * c1 = (Channel *)x; - PeerServer * ps = NULL; - ConnectInfo * info = NULL; + PeerServer * ps; + ConnectInfo * info; ps = channel_peer_from_url(dest_url); if (ps == NULL) { @@ -155,6 +155,7 @@ static void show_help(void) { #endif #if defined(_WRS_KERNEL) +int tcf_log(void); int tcf_log(void) { #else int main(int argc, char ** argv) { diff --git a/agent/tcf/main/main_lua.c b/agent/tcf/main/main_lua.c index eca0a5d..f485148 100644 --- a/agent/tcf/main/main_lua.c +++ b/agent/tcf/main/main_lua.c @@ -1441,6 +1441,7 @@ static const luaL_Reg posteventfuncs[] = { */ #if defined(_WRS_KERNEL) +int tcf_lua(void); int tcf_lua(void) { #else int main(int argc, char ** argv) { diff --git a/agent/tcf/main/main_reg.c b/agent/tcf/main/main_reg.c index f77588f..75d1239 100644 --- a/agent/tcf/main/main_reg.c +++ b/agent/tcf/main/main_reg.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -36,6 +36,7 @@ static const char * progname; #if defined(_WRS_KERNEL) +int tcf_registry(void); int tcf_registry(void) { #else int main(int argc, char **argv) { diff --git a/agent/tcf/main/main_va.c b/agent/tcf/main/main_va.c index 592a7ba..766f9bb 100644 --- a/agent/tcf/main/main_va.c +++ b/agent/tcf/main/main_va.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -53,6 +53,7 @@ static void channel_new_connection(ChannelServer * serv, Channel * c) { } #if defined(_WRS_KERNEL) +int tcf_va(void); int tcf_va(void) { #else int main(int argc, char ** argv) { diff --git a/agent/tcf/services/contextquery.c b/agent/tcf/services/contextquery.c index ec9f1f3..e993e62 100644 --- a/agent/tcf/services/contextquery.c +++ b/agent/tcf/services/contextquery.c @@ -291,7 +291,7 @@ static void command_query(char * token, Channel * c) { static void command_get_attr_names(char * token, Channel * c) { unsigned cnt = 0; - Comparator * l = NULL; + Comparator * l; json_test_char(&c->inp, MARKER_EOM); diff --git a/agent/tcf/services/diagnostics.c b/agent/tcf/services/diagnostics.c index 4ec2240..4cfb8df 100644 --- a/agent/tcf/services/diagnostics.c +++ b/agent/tcf/services/diagnostics.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -93,7 +93,7 @@ struct RunTestDoneArgs { static void command_echo(char * token, Channel * c) { char str[0x1000]; int len = json_read_string(&c->inp, str, sizeof(str)); - if (len >= (int)sizeof(str)) exception(ERR_JSON_SYNTAX); + if ((len < 0) || (len >= (int)sizeof(str))) exception(ERR_JSON_SYNTAX); json_test_char(&c->inp, MARKER_EOA); json_test_char(&c->inp, MARKER_EOM); write_stringz(&c->out, "R"); @@ -115,7 +115,7 @@ static void command_echo_fp(char * token, Channel * c) { } static void command_echo_err(char * token, Channel * c) { - int no = 0; + int no; for (;;) { no = read_errno(&c->inp); if (peek_stream(&c->inp) == MARKER_EOM) break; @@ -168,7 +168,7 @@ static void run_test_done(int error, Context * ctx, void * arg) { #endif static void command_run_test(char * token, Channel * c) { - int err = 0; + int err; char id[256]; json_read_string(&c->inp, id, sizeof(id)); @@ -203,14 +203,14 @@ static void command_run_test(char * token, Channel * c) { static void command_cancel_test(char * token, Channel * c) { char id[256]; - int err = 0; + int err; json_read_string(&c->inp, id, sizeof(id)); json_test_char(&c->inp, MARKER_EOA); json_test_char(&c->inp, MARKER_EOM); #if ENABLE_RCBP_TEST - if (terminate_debug_context(id2ctx(id)) != 0) err = errno; + err = (terminate_debug_context(id2ctx(id)) != 0) ? errno : 0; #else err = ERR_UNSUPPORTED; #endif @@ -280,8 +280,8 @@ static void get_symbol_cache_client(void * x) { static void command_get_symbol(char * token, Channel * c) { char id[256]; - char * name = NULL; - int error = 0; + char * name; + int error; ContextAddress addr = 0; json_read_string(&c->inp, id, sizeof(id)); @@ -311,7 +311,7 @@ static void command_get_symbol(char * token, Channel * c) { #elif ENABLE_RCBP_TEST void * ptr = NULL; int cls = 0; - if (find_test_symbol(ctx, name, &ptr, &cls) < 0) error = errno; + error = (find_test_symbol(ctx, name, &ptr, &cls) < 0) ? errno : 0; addr = (ContextAddress)ptr; #else error = ERR_UNSUPPORTED; diff --git a/agent/tcf/services/discovery.c b/agent/tcf/services/discovery.c index 7f2d847..ae79af3 100644 --- a/agent/tcf/services/discovery.c +++ b/agent/tcf/services/discovery.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -102,7 +102,7 @@ static void read_peer_attr(InputStream * inp, const char * name, void * x) { } static void command_redirect(char * token, Channel * c) { - PeerServer * ps = NULL; + PeerServer * ps; int free_ps = 0; assert(c->state == ChannelStateConnected); diff --git a/agent/tcf/services/discovery_udp.c b/agent/tcf/services/discovery_udp.c index e310cf5..fd30866 100644 --- a/agent/tcf/services/discovery_udp.c +++ b/agent/tcf/services/discovery_udp.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -111,10 +111,10 @@ static void app_strz(const char * str) { static int get_slave_addr(char * buf, ssize_t * pos, struct sockaddr_in * addr, uint64_t * timestamp) { char * port = buf + *pos; char * stmp = buf + *pos; - char * host = buf + *pos; + char * host; size_t len = strlen(buf + *pos); uint64_t ts = 0; - int n = 0; + int n; while (*port && *port != ':') port++; if (*port == ':') *port++ = 0; @@ -179,12 +179,12 @@ static void trigger_recv(void) { static int create_server_socket(void) { int sock = -1; - int error = 0; + int error; const char * reason = NULL; const int i = 1; struct addrinfo hints; struct addrinfo * reslist = NULL; - struct addrinfo * res = NULL; + struct addrinfo * res; struct sockaddr_in local_addr; #if defined(_WRS_KERNEL) int local_addr_size = sizeof(local_addr); @@ -309,7 +309,7 @@ static int send_packet(ip_ifc_info * ifc, struct sockaddr_in * addr) { if (log_file != NULL && (log_mode & LOG_DISCOVERY) != 0) { int i; char buf[sizeof(send_buf) + 32]; - size_t pos = 0; + size_t pos; char ch; switch (send_buf[4]) { case UDP_ACK_INFO: @@ -373,7 +373,7 @@ static int send_packet(ip_ifc_info * ifc, struct sockaddr_in * addr) { static int udp_send_peer_info(PeerServer * ps, void * arg) { struct sockaddr_in * addr = (struct sockaddr_in *)arg; const char * host = NULL; - const char * prot = NULL; + const char * prot; struct in_addr peer_addr; int n; @@ -558,7 +558,7 @@ static void udp_send_all(struct sockaddr_in * addr, SlaveInfo * s) { static SlaveInfo * add_slave(struct sockaddr_in * addr, time_t timestamp) { int i = 0; - SlaveInfo * s = NULL; + SlaveInfo * s; while (i < slave_cnt) { s = slave_info + i++; if (memcmp(&s->addr, addr, sizeof(struct sockaddr_in)) == 0) { @@ -655,7 +655,7 @@ static void udp_receive_ack_info(void) { assert(is_dispatch_thread()); while (p < e) { char * name = p; - char * value = NULL; + char * value; while (p < e && *p != '\0' && *p != '=') p++; if (p >= e || *p != '=') { p = NULL; @@ -714,7 +714,7 @@ static void udp_receive_ack_slaves(time_t timenow) { uint64_t timestamp; if (get_slave_addr(recv_buf, &pos, &addr, ×tamp)) { time_t delta = 60 * 10; /* 10 minutes */ - time_t timeval = 0; + time_t timeval; if (timestamp < 3600000) { /* Timestamp is "time to live" in milliseconds */ timeval = timenow + (time_t)(timestamp / 1000) - PEER_DATA_RETENTION_PERIOD; @@ -793,7 +793,7 @@ static void udp_server_recv(void * x) { udp_receive_peer_removed(); } else { - int n = 0; + int n; time_t timenow = time(NULL); SlaveInfo * s = NULL; if (ntohs(recvreq_addr.sin_port) != DISCOVERY_TCF_PORT) { @@ -847,7 +847,7 @@ static void local_peer_changed(PeerServer * ps, int type, void * arg) { } int discovery_start_udp(void) { - int error = 0; + int error; assert(!discovery_stopped); error = create_server_socket(); if (error) return error; diff --git a/agent/tcf/services/dwarfio.c b/agent/tcf/services/dwarfio.c index d52860f..b28b3d7 100644 --- a/agent/tcf/services/dwarfio.c +++ b/agent/tcf/services/dwarfio.c @@ -139,7 +139,7 @@ void dio_EnterSection(DIO_UnitDescriptor * Unit, ELF_Section * Section, U8_T Off assert(sDataPos < sDataLen); } -void dio_ExitSection() { +void dio_ExitSection(void) { sSection = NULL; sDataPos = 0; sDataLen = 0; @@ -147,7 +147,7 @@ void dio_ExitSection() { sUnit = NULL; } -U8_T dio_GetPos() { +U8_T dio_GetPos(void) { return sDataPos; } diff --git a/agent/tcf/services/filesystem.c b/agent/tcf/services/filesystem.c index e415cf2..d23e51b 100644 --- a/agent/tcf/services/filesystem.c +++ b/agent/tcf/services/filesystem.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -163,9 +163,9 @@ static OpenFileInfo * create_open_file_info(Channel * ch, char * path, int file, } static OpenFileInfo * find_open_file_info(char * id) { - unsigned long handle = 0; - LINK * list_head = NULL; - LINK * list_next = NULL; + unsigned long handle; + LINK * list_head; + LINK * list_next; if (id == NULL || id[0] != 'F' || id[1] != 'S' || id[2] == 0) return NULL; handle = strtoul(id + 2, &id, 10); @@ -186,7 +186,7 @@ static void delete_open_file_info(OpenFileInfo * h) { static void channel_close_listener(Channel * c) { LINK list; - LINK * list_next = NULL; + LINK * list_next; list_init(&list); for (list_next = file_info_ring.next; list_next != &file_info_ring; list_next = list_next->next) { @@ -349,7 +349,9 @@ static void write_file_attrs(OutputStream * out, FileAttrs * attrs) { json_write_string(out, "MTime"); write_stream(out, ':'); json_write_uint64(out, attrs->mtime); +#if defined(_WIN32) cnt++; +#endif } #if defined(_WIN32) @@ -377,7 +379,7 @@ static int to_local_open_flags(int flags) { } static void read_path(InputStream * inp, char * path, int size) { - int i = 0; + int i; char buf[FILE_PATH_SIZE]; json_read_string(inp, path, size); if (path[0] == 0) strlcpy(path, get_user_home(), size); @@ -424,15 +426,15 @@ static void read_path(InputStream * inp, char * path, int size) { static void command_open(char * token, Channel * c) { char path[FILE_PATH_SIZE]; - unsigned long flags = 0; + unsigned int flags; FileAttrs attrs; - int file = -1; + int file; int err = 0; OpenFileInfo * handle = NULL; read_path(&c->inp, path, sizeof(path)); json_test_char(&c->inp, MARKER_EOA); - flags = json_read_ulong(&c->inp); + flags = (unsigned int) json_read_ulong(&c->inp); json_test_char(&c->inp, MARKER_EOA); memset(&attrs, 0, sizeof(FileAttrs)); #if defined(_WIN32) @@ -474,7 +476,7 @@ static void reply_close(char * token, OutputStream * out, int err) { write_stream(out, MARKER_EOM); } -static void reply_read(char * token, OutputStream * out, int err, void * buf, unsigned len, int eof) { +static void reply_read(char * token, OutputStream * out, int err, void * buf, size_t len, int eof) { write_stringz(out, "R"); write_stringz(out, token); json_write_binary(out, buf, len); @@ -677,7 +679,7 @@ static IORequest * create_io_request(char * token, OpenFileInfo * handle, int ty static void command_close(char * token, Channel * c) { char id[256]; - OpenFileInfo * h = NULL; + OpenFileInfo * h; int err = 0; json_read_string(&c->inp, id, sizeof(id)); @@ -709,7 +711,7 @@ static void command_close(char * token, Channel * c) { static void command_read(char * token, Channel * c) { char id[256]; - OpenFileInfo * h = NULL; + OpenFileInfo * h; int64_t offset; unsigned long len; @@ -743,7 +745,7 @@ static void command_read(char * token, Channel * c) { static void command_write(char * token, Channel * c) { char id[256]; - OpenFileInfo * h = NULL; + OpenFileInfo * h; int64_t offset; size_t len = 0; JsonReadBinaryState state; @@ -825,7 +827,7 @@ static void command_lstat(char * token, Channel * c) { static void command_fstat(char * token, Channel * c) { char id[256]; - OpenFileInfo * h = NULL; + OpenFileInfo * h; json_read_string(&c->inp, id, sizeof(id)); json_test_char(&c->inp, MARKER_EOA); @@ -886,7 +888,7 @@ static void command_setstat(char * token, Channel * c) { static void command_fsetstat(char * token, Channel * c) { char id[256]; FileAttrs attrs; - OpenFileInfo * h = NULL; + OpenFileInfo * h; json_read_string(&c->inp, id, sizeof(id)); json_test_char(&c->inp, MARKER_EOA); @@ -911,7 +913,7 @@ static void command_fsetstat(char * token, Channel * c) { static void command_opendir(char * token, Channel * c) { char path[FILE_PATH_SIZE]; - DIR * dir = NULL; + DIR * dir; int err = 0; OpenFileInfo * handle = NULL; @@ -936,7 +938,7 @@ static void command_opendir(char * token, Channel * c) { static void command_readdir(char * token, Channel * c) { char id[256]; - OpenFileInfo * h = NULL; + OpenFileInfo * h; int err = 0; int eof = 0; @@ -1035,7 +1037,9 @@ static void command_mkdir(char * token, Channel * c) { char path[FILE_PATH_SIZE]; FileAttrs attrs; int err = 0; - int mode = 0777; +#if !defined(_WRS_KERNEL) + int mode; +#endif read_path(&c->inp, path, sizeof(path)); json_test_char(&c->inp, MARKER_EOA); @@ -1047,12 +1051,10 @@ static void command_mkdir(char * token, Channel * c) { json_test_char(&c->inp, MARKER_EOA); json_test_char(&c->inp, MARKER_EOM); - if (attrs.flags & ATTR_PERMISSIONS) { - mode = attrs.permissions; - } #if defined(_WRS_KERNEL) if (mkdir(path) < 0) err = errno; #else + mode = (attrs.flags & ATTR_PERMISSIONS) ? attrs.permissions : 0777; if (mkdir(path, mode) < 0) err = errno; #endif #if defined(_WIN32) @@ -1070,7 +1072,7 @@ static void command_mkdir(char * token, Channel * c) { static void command_realpath(char * token, Channel * c) { char path[FILE_PATH_SIZE]; - char * real = NULL; + char * real; int err = 0; read_path(&c->inp, path, sizeof(path)); @@ -1119,7 +1121,7 @@ static void command_rename(char * token, Channel * c) { static void command_readlink(char * token, Channel * c) { char path[FILE_PATH_SIZE]; char link[FILE_PATH_SIZE]; - int err = 0; + int err; read_path(&c->inp, path, sizeof(path)); json_test_char(&c->inp, MARKER_EOA); @@ -1129,7 +1131,7 @@ static void command_readlink(char * token, Channel * c) { #if defined(_WIN32) || defined(_WRS_KERNEL) err = ENOSYS; #else - if (readlink(path, link, sizeof(link)) < 0) err = errno; + err = (readlink(path, link, sizeof(link)) < 0) ? errno : 0; #endif write_stringz(&c->out, "R"); @@ -1143,7 +1145,7 @@ static void command_readlink(char * token, Channel * c) { static void command_symlink(char * token, Channel * c) { char link[FILE_PATH_SIZE]; char target[FILE_PATH_SIZE]; - int err = 0; + int err; read_path(&c->inp, link, sizeof(link)); json_test_char(&c->inp, MARKER_EOA); @@ -1154,7 +1156,7 @@ static void command_symlink(char * token, Channel * c) { #if defined(_WIN32) || defined(_WRS_KERNEL) err = ENOSYS; #else - if (symlink(target, link) < 0) err = errno; + err = (symlink(target, link) < 0) ? errno : 0; #endif write_stringz(&c->out, "R"); @@ -1190,7 +1192,7 @@ static void command_copy(char * token, Channel * c) { while (err == 0 && pos < st.st_size) { char buf[BUF_SIZE]; - ssize_t wr = 0; + ssize_t wr; ssize_t rd = read(fi, buf, sizeof(buf)); if (rd == 0) break; if (rd < 0) { diff --git a/agent/tcf/services/pathmap.c b/agent/tcf/services/pathmap.c index 869a87b..7363b60 100644 --- a/agent/tcf/services/pathmap.c +++ b/agent/tcf/services/pathmap.c @@ -27,11 +27,11 @@ #include <tcf/services/pathmap.h> char * canonic_path_map_file_name(const char * fnm) { - char * buf = NULL; + char * buf; size_t buf_pos = 0; - size_t buf_max = 0; + size_t buf_max = 0x100; - buf = (char *)tmp_alloc(buf_max = 0x100); + buf = (char *)tmp_alloc(buf_max); for (;;) { char ch = *fnm++; if (ch == 0) break; @@ -44,7 +44,7 @@ char * canonic_path_map_file_name(const char * fnm) { continue; } if (buf_pos > 0 && *fnm == '.' && (fnm[1] == '/' || fnm[1] == '\\')) { - unsigned j = buf_pos - 1; + size_t j = buf_pos - 1; if (j > 0 && buf[j - 1] != '/') { buf[buf_pos] = 0; while (j > 0 && buf[j - 1] != '/') j--; @@ -57,7 +57,7 @@ char * canonic_path_map_file_name(const char * fnm) { } } if (buf_pos == 0 && ch >= 'a' && ch <= 'z' && *fnm == ':') { - ch = ch - 'a' + 'A'; + ch = (char) (ch - 'a' + 'A'); } if (buf_pos + 1 >= buf_max) { buf_max += 0x100; @@ -138,7 +138,7 @@ static void path_map_event_mapping_changed(Channel * c) { } void add_path_map_event_listener(PathMapEventListener * listener, void * args) { - Listener * l = NULL; + Listener * l; if (listener_cnt >= listener_max) { listener_max += 8; listeners = (Listener *)loc_realloc(listeners, listener_max * sizeof(Listener)); @@ -211,7 +211,7 @@ static int update_rule(PathMapRule * r, PathMapRuleAttribute * new_attrs) { PathMapRuleAttribute * new_attr = new_attrs; PathMapRuleAttribute * old_attr = old_attrs; PathMapRuleAttribute ** old_ref = &old_attrs; - InputStream * buf_inp = NULL; + InputStream * buf_inp; ByteArrayInputStream buf; char * name = new_attr->name; @@ -237,7 +237,6 @@ static int update_rule(PathMapRule * r, PathMapRuleAttribute * new_attrs) { loc_free(old_attr->value); loc_free(old_attr->name); loc_free(old_attr); - old_attr = NULL; } *new_ref = new_attr; @@ -343,7 +342,7 @@ static char * map_file_name(Context * ctx, PathMap * m, char * fnm, int mode) { } if (r->query != NULL && !context_query(ctx, r->query)) continue; src = canonic_path_map_file_name(r->src); - k = strlen(src); + k = (unsigned int) strlen(src); if (strncmp(src, fnm, k)) continue; if (fnm[k] != 0 && fnm[k] != '/' && fnm[k] != '\\') { /* skip this rule only if it's not re-rooting the file-system */ @@ -372,7 +371,7 @@ char * apply_path_map(Channel * c, Context * ctx, char * fnm, int mode) { } } else { - PathMap * m = NULL; + PathMap * m; #if ENABLE_ContextProxy Channel * h = proxy_get_host_channel(c); if (h != NULL) { @@ -407,7 +406,7 @@ PathMapRuleAttribute * get_path_mapping_attributes(PathMapRule * map) { } PathMapRule * create_path_mapping(PathMapRuleAttribute * attrs) { - PathMapRule * r = NULL; + PathMapRule * r; PathMap * m = find_map(NULL); if (m == NULL) { @@ -471,7 +470,7 @@ static void read_rule_attrs(InputStream * inp, const char * name, void * args) { static void read_rule(InputStream * inp, void * args) { PathMap * m = (PathMap *)args; - PathMapRule * r = NULL; + PathMapRule * r; PathMapRuleAttribute * attrs = NULL; PathMapRuleAttribute ** attr_list = &attrs; @@ -543,7 +542,7 @@ static void command_set(char * token, Channel * c) { static void channel_close_listener(Channel * c) { unsigned i; - PathMap * m = NULL; + PathMap * m; /* Keep path map over channel redirection */ if (c->state == ChannelStateHelloReceived) return; m = find_map(c); diff --git a/agent/tcf/services/streamsservice.c b/agent/tcf/services/streamsservice.c index 375befb..2cc3b7f 100644 --- a/agent/tcf/services/streamsservice.c +++ b/agent/tcf/services/streamsservice.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -342,10 +342,10 @@ static void send_read_reply(StreamClient * client, char * token, size_t size) { VirtualStream * stream = client->stream; Channel * c = client->channel; size_t lost = 0; - size_t read1 = 0; + size_t read1; size_t read2 = 0; int eos = 0; - char * data1 = NULL; + char * data1; char * data2 = NULL; size_t pos; size_t len = (stream->buf_inp + stream->buf_len - stream->buf_out) % stream->buf_len; @@ -626,8 +626,8 @@ static void command_unsubscribe(char * token, Channel * c) { static void command_read(char * token, Channel * c) { char id[256]; - size_t size = 0; - StreamClient * client = NULL; + size_t size; + StreamClient * client; int err = 0; json_read_string(&c->inp, id, sizeof(id)); @@ -672,8 +672,8 @@ static void command_read(char * token, Channel * c) { static void command_write(char * token, Channel * c) { char id[256]; - StreamClient * client = NULL; - long size = 0; + StreamClient * client; + long size; long offs = 0; char * data = NULL; int err = 0; @@ -742,7 +742,7 @@ static void command_write(char * token, Channel * c) { static void command_eos(char * token, Channel * c) { char id[256]; - StreamClient * client = NULL; + StreamClient * client; size_t done = 0; WriteRequest * r = NULL; int err = 0; @@ -794,7 +794,7 @@ static void command_connect(char * token, Channel * c) { static void command_disconnect(char * token, Channel * c) { char id[256]; - StreamClient * client = NULL; + StreamClient * client; int err = 0; json_read_string(&c->inp, id, sizeof(id)); @@ -812,7 +812,7 @@ static void command_disconnect(char * token, Channel * c) { } static void channel_close_listener(Channel * c) { - LINK * l = NULL; + LINK * l; for (l = clients.next; l != &clients;) { StreamClient * client = all2client(l); |

