Skip to content

Commit

Permalink
get rid of some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrop7 committed Sep 1, 2012
1 parent e0876b0 commit 93bc612
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 61 deletions.
2 changes: 1 addition & 1 deletion client/DPReceive.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void receiver_recv_handler_send (DPReceiveReceiver *o, uint8_t *packet, i
BLog(BLOG_WARNING, "wrong number of destinations");
goto out;
}
peerid_t to_id;
peerid_t to_id = 0; // to remove warning
if (num_ids == 1) {
if (data_len < sizeof(to_id)) {
BLog(BLOG_WARNING, "missing destination");
Expand Down
2 changes: 1 addition & 1 deletion client/FragmentProtoAssembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static struct FragmentProtoAssembler_frame * allocate_new_frame (FragmentProtoAs
LinkedList1_Append(&o->frames_used, &frame->list_node);
// insert to used tree
int res = FPAFramesTree_Insert(&o->frames_used_tree, 0, frame, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

return frame;
}
Expand Down
8 changes: 4 additions & 4 deletions client/FrameDecider.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void add_mac_to_peer (FrameDeciderPeer *o, uint8_t *mac)
// add to used
LinkedList1_Append(&o->mac_entries_used, &entry->list_node);
int res = FDMacsTree_Insert(&d->macs_tree, 0, entry, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)
}

static uint32_t compute_sig_for_group (uint32_t group)
Expand Down Expand Up @@ -156,7 +156,7 @@ static void add_to_multicast (FrameDecider *d, struct _FrameDecider_group_entry

// insert to multicast tree
int res = FDMulticastTree_Insert(&d->multicast_tree, 0, group_entry, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

// init list node
LinkedList3Node_InitLonely(&group_entry->sig_list_node);
Expand Down Expand Up @@ -188,7 +188,7 @@ static void remove_from_multicast (FrameDecider *d, struct _FrameDecider_group_e

// insert to multicast tree
int res = FDMulticastTree_Insert(&d->multicast_tree, 0, newmaster, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)
}
}

Expand Down Expand Up @@ -240,7 +240,7 @@ static void add_group_to_peer (FrameDeciderPeer *o, uint32_t group)

// insert to peer's groups tree
int res = FDGroupsTree_Insert(&o->groups_tree, 0, group_entry, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

// add to multicast
add_to_multicast(d, group_entry);
Expand Down
28 changes: 14 additions & 14 deletions client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1918,10 +1918,10 @@ void peer_chat_handler_message (struct peer_data *peer, uint8_t *data, int data_
}

// read message
uint16_t type;
uint16_t type = 0; // to remove warning
ASSERT_EXECUTE(msgParser_Gettype(&parser, &type))
uint8_t *payload;
int payload_len;
uint8_t *payload = NULL; // to remove warning
int payload_len = 0; // to remove warning
ASSERT_EXECUTE(msgParser_Getpayload(&parser, &payload, &payload_len))

// dispatch according to message type
Expand Down Expand Up @@ -1979,17 +1979,17 @@ void peer_msg_youconnect (struct peer_data *peer, uint8_t *data, int data_len)
}

// check if the address scope is known
uint8_t *name_data;
int name_len;
uint8_t *name_data = NULL; // to remove warning
int name_len = 0; // to remove warning
ASSERT_EXECUTE(msg_youconnect_addrParser_Getname(&aparser, &name_data, &name_len))
char *name;
if (!(name = address_scope_known(name_data, name_len))) {
continue;
}

// read address
uint8_t *addr_data;
int addr_len;
uint8_t *addr_data = NULL; // to remove warning
int addr_len = 0; // to remove warning
ASSERT_EXECUTE(msg_youconnect_addrParser_Getaddr(&aparser, &addr_data, &addr_len))
if (!addr_read(addr_data, addr_len, &addr)) {
peer_log(peer, BLOG_WARNING, "msg_youconnect: failed to read address");
Expand Down Expand Up @@ -2082,13 +2082,13 @@ void peer_msg_seed (struct peer_data *peer, uint8_t *data, int data_len)
}

// read message
uint16_t seed_id;
uint16_t seed_id = 0; // to remove warning
ASSERT_EXECUTE(msg_seedParser_Getseed_id(&parser, &seed_id))
uint8_t *key;
int key_len;
uint8_t *key = NULL; // to remove warning
int key_len = 0; // to remove warning
ASSERT_EXECUTE(msg_seedParser_Getkey(&parser, &key, &key_len))
uint8_t *iv;
int iv_len;
uint8_t *iv = NULL; // to remove warning
int iv_len = 0; // to remove warning
ASSERT_EXECUTE(msg_seedParser_Getiv(&parser, &iv, &iv_len))

if (options.transport_mode != TRANSPORT_MODE_UDP) {
Expand Down Expand Up @@ -2134,7 +2134,7 @@ void peer_msg_confirmseed (struct peer_data *peer, uint8_t *data, int data_len)
}

// read message
uint16_t seed_id;
uint16_t seed_id = 0; // to remove warning
ASSERT_EXECUTE(msg_confirmseedParser_Getseed_id(&parser, &seed_id))

if (options.transport_mode != TRANSPORT_MODE_UDP) {
Expand Down Expand Up @@ -2468,7 +2468,7 @@ void peer_send_conectinfo (struct peer_data *peer, int addr_index, int port_adju
struct bind_addr *bind_addr = &bind_addrs[addr_index];

// remember encryption key size
int key_size;
int key_size = 0; // to remove warning
if (options.transport_mode == TRANSPORT_MODE_UDP && SPPROTO_HAVE_ENCRYPTION(sp_params)) {
key_size = BEncryption_cipher_key_size(sp_params.encryption_mode);
}
Expand Down
8 changes: 4 additions & 4 deletions dhcpclient/BDHCPClientCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,16 @@ static void recv_handler_done (BDHCPClientCore *o, int data_len)
int dhcp_message_type = -1;

int have_dhcp_server_identifier = 0;
uint32_t dhcp_server_identifier;
uint32_t dhcp_server_identifier = 0; // to remove warning

int have_ip_address_lease_time = 0;
uint32_t ip_address_lease_time;
uint32_t ip_address_lease_time = 0; // to remove warning

int have_subnet_mask = 0;
uint32_t subnet_mask;
uint32_t subnet_mask = 0; // to remove warning

int have_router = 0;
uint32_t router;
uint32_t router = 0; // to remove warning

int domain_name_servers_count = 0;
uint32_t domain_name_servers[BDHCPCLIENTCORE_MAX_DOMAIN_NAME_SERVERS];
Expand Down
4 changes: 3 additions & 1 deletion examples/RandomPacketSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <stdio.h>

#include <misc/debug.h>
#include <security/BRandom.h>
#include <system/BReactor.h>
#include <base/DebugObject.h>
Expand All @@ -49,7 +50,8 @@ static void _RandomPacketSink_input_handler_send (RandomPacketSink *s, uint8_t *
DebugObject_Access(&s->d_obj);

printf("sink: send '");
fwrite(data, data_len, 1, stdout);
size_t res = fwrite(data, data_len, 1, stdout);
B_USE(res)

uint8_t r;
BRandom_randomize(&r, sizeof(r));
Expand Down
4 changes: 3 additions & 1 deletion examples/TimerPacketSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <stdio.h>

#include <misc/debug.h>
#include <system/BReactor.h>
#include <flow/PacketPassInterface.h>

Expand All @@ -44,7 +45,8 @@ typedef struct {
static void _TimerPacketSink_input_handler_send (TimerPacketSink *s, uint8_t *data, int data_len)
{
printf("sink: send '");
fwrite(data, data_len, 1, stdout);
size_t res = fwrite(data, data_len, 1, stdout);
B_USE(res)
printf("'\n");

BReactor_SetTimer(s->reactor, &s->timer);
Expand Down
6 changes: 4 additions & 2 deletions flow/PacketPassFairQueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static uint64_t get_current_time (PacketPassFairQueue *m)
return m->sending_flow->time;
}

uint64_t time;
uint64_t time = 0; // to remove warning
int have = 0;

PacketPassFairQueueFlow *first_flow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0);
Expand Down Expand Up @@ -171,7 +171,7 @@ static void input_handler_send (PacketPassFairQueueFlow *flow, uint8_t *data, in
flow->queued.data = data;
flow->queued.data_len = data_len;
int res = PacketPassFairQueue__Tree_Insert(&m->queued_tree, 0, flow, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)
flow->is_queued = 1;

if (!m->sending_flow && !BPending_IsSet(&m->schedule_job)) {
Expand Down Expand Up @@ -353,6 +353,7 @@ void PacketPassFairQueueFlow_Free (PacketPassFairQueueFlow *flow)
void PacketPassFairQueueFlow_AssertFree (PacketPassFairQueueFlow *flow)
{
PacketPassFairQueue *m = flow->m;
B_USE(m)

ASSERT(m->freeing || flow != m->sending_flow)
DebugObject_Access(&flow->d_obj);
Expand Down Expand Up @@ -385,6 +386,7 @@ void PacketPassFairQueueFlow_RequestCancel (PacketPassFairQueueFlow *flow)
void PacketPassFairQueueFlow_SetBusyHandler (PacketPassFairQueueFlow *flow, PacketPassFairQueue_handler_busy handler, void *user)
{
PacketPassFairQueue *m = flow->m;
B_USE(m)

ASSERT(flow == m->sending_flow)
ASSERT(!m->freeing)
Expand Down
2 changes: 2 additions & 0 deletions flow/PacketPassFifoQueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ void PacketPassFifoQueueFlow_Free (PacketPassFifoQueueFlow *o)
void PacketPassFifoQueueFlow_AssertFree (PacketPassFifoQueueFlow *o)
{
PacketPassFifoQueue *queue = o->queue;
B_USE(queue)
DebugObject_Access(&o->d_obj);
ASSERT(queue->freeing || o != queue->sending_flow)
}
Expand All @@ -222,6 +223,7 @@ int PacketPassFifoQueueFlow_IsBusy (PacketPassFifoQueueFlow *o)
void PacketPassFifoQueueFlow_SetBusyHandler (PacketPassFifoQueueFlow *o, PacketPassFifoQueue_handler_busy handler_busy, void *user)
{
PacketPassFifoQueue *queue = o->queue;
B_USE(queue)
DebugObject_Access(&o->d_obj);
ASSERT(!queue->freeing)
ASSERT(o == queue->sending_flow)
Expand Down
4 changes: 3 additions & 1 deletion flow/PacketPassPriorityQueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static void input_handler_send (PacketPassPriorityQueueFlow *flow, uint8_t *data
flow->queued.data = data;
flow->queued.data_len = data_len;
int res = PacketPassPriorityQueue__Tree_Insert(&m->queued_tree, 0, flow, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)
flow->is_queued = 1;

if (!m->sending_flow && !BPending_IsSet(&m->schedule_job)) {
Expand Down Expand Up @@ -231,6 +231,7 @@ void PacketPassPriorityQueueFlow_Free (PacketPassPriorityQueueFlow *flow)
void PacketPassPriorityQueueFlow_AssertFree (PacketPassPriorityQueueFlow *flow)
{
PacketPassPriorityQueue *m = flow->m;
B_USE(m)

ASSERT(m->freeing || flow != m->sending_flow)
DebugObject_Access(&flow->d_obj);
Expand Down Expand Up @@ -263,6 +264,7 @@ void PacketPassPriorityQueueFlow_RequestCancel (PacketPassPriorityQueueFlow *flo
void PacketPassPriorityQueueFlow_SetBusyHandler (PacketPassPriorityQueueFlow *flow, PacketPassPriorityQueue_handler_busy handler, void *user)
{
PacketPassPriorityQueue *m = flow->m;
B_USE(m)

ASSERT(flow == m->sending_flow)
ASSERT(!m->freeing)
Expand Down
2 changes: 1 addition & 1 deletion ncd/NCDInterpProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static int convert_value_recurser (NCDPlaceholderDb *pdb, NCDValue *value, NCDVa
}

int res = NCDVal_MapInsert(*out, vkey, vval);
ASSERT(res) // we assume different variables get different placeholder ids
ASSERT_EXECUTE(res) // we assume different variables get different placeholder ids
}
} break;

Expand Down
2 changes: 1 addition & 1 deletion ncd/NCDMethodIndex.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static int add_method_name (NCDMethodIndex *o, const char *method_name, int *out

NCDMethodIndex__HashRef ref = {name_entry, o->num_names};
int res = NCDMethodIndex__Hash_Insert(&o->hash, o->names, ref, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

o->num_entries++;
o->num_names++;
Expand Down
2 changes: 1 addition & 1 deletion ncd/NCDModuleIndex.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int NCDModuleIndex_AddGroup (NCDModuleIndex *o, const struct NCDModuleGroup *gro

NCDModuleIndex__MHashRef ref = {m, o->num_modules};
int res = NCDModuleIndex__MHash_Insert(&o->modules_hash, o->modules, ref, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

const char *base_type = (nm->base_type ? nm->base_type : nm->type);

Expand Down
2 changes: 1 addition & 1 deletion ncd/NCDRequestClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ int NCDRequestClientRequest_Init (NCDRequestClientRequest *o, NCDRequestClient *

// insert to reqs tree
int res = BAVL_Insert(&client->reqs_tree, &req->reqs_tree_node, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

// set pointers
o->req = req;
Expand Down
4 changes: 3 additions & 1 deletion ncd/NCDVal.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ static void NCDVal__AssertMem (NCDValMem *mem)

static void NCDVal_AssertExternal (NCDValMem *mem, const void *e_buf, size_t e_len)
{
#ifndef NDEBUG
const char *e_cbuf = e_buf;
char *buf = (mem->buf ? mem->buf : mem->fastbuf);
ASSERT(e_cbuf >= buf + mem->size || e_cbuf + e_len <= buf)
#endif
}

static void NCDVal__AssertValOnly (NCDValMem *mem, NCDVal__idx idx)
Expand Down Expand Up @@ -378,7 +380,7 @@ NCDValRef NCDVal_NewCopy (NCDValMem *mem, NCDValRef val)
}

int res = NCDVal_MapInsert(copy, key_copy, val_copy);
ASSERT(res)
ASSERT_EXECUTE(res)
}

return copy;
Expand Down
2 changes: 1 addition & 1 deletion ncd/NCDValCompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int NCDValCompat_ValueToVal (NCDValue *value, NCDValMem *mem, NCDValRef *out)
}

int res = NCDVal_MapInsert(*out, vkey, vval);
ASSERT(res)
ASSERT_EXECUTE(res)
}
} break;

Expand Down
2 changes: 1 addition & 1 deletion ncd/NCDValue.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ NCDValue * NCDValue_MapInsert (NCDValue *o, NCDValue key, NCDValue val)
e->key = key;
e->val = val;
int res = NCDValue__MapTree_Insert(&o->map_tree, 0, e, NULL);
ASSERT(res)
ASSERT_EXECUTE(res)

o->map_count++;

Expand Down
5 changes: 3 additions & 2 deletions ncd/modules/net_ipv4_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <stdlib.h>
#include <string.h>

#include <misc/debug.h>
#include <ncd/NCDModule.h>
#include <ncd/NCDIfConfig.h>

Expand Down Expand Up @@ -129,7 +130,7 @@ static void func_new (void *vo, NCDModuleInst *i)
o->ifname = NCDVal_StringValue(ifname_arg);

// add route
int res;
int res = 0; // to remove warning
switch (o->type) {
case TYPE_NORMAL:
res = NCDIfConfig_add_ipv4_route(o->dest, &o->gateway, o->metric, o->ifname);
Expand Down Expand Up @@ -161,7 +162,7 @@ static void func_die (void *vo)
struct instance *o = vo;

// remove route
int res;
int res = 0; // to remove warning
switch (o->type) {
case TYPE_NORMAL:
res = NCDIfConfig_remove_ipv4_route(o->dest, &o->gateway, o->metric, o->ifname);
Expand Down
4 changes: 2 additions & 2 deletions ncd/modules/net_ipv6_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void func_new (void *vo, NCDModuleInst *i)
o->ifname = NCDVal_StringValue(ifname_arg);

// add route
int res;
int res = 0; // to remove warning
switch (o->type) {
case TYPE_NORMAL:
res = NCDIfConfig_add_ipv6_route(o->dest, &o->gateway, o->metric, o->ifname);
Expand Down Expand Up @@ -164,7 +164,7 @@ static void func_die (void *vo)
struct instance *o = vo;

// remove route
int res;
int res = 0; // to remove warning
switch (o->type) {
case TYPE_NORMAL:
res = NCDIfConfig_remove_ipv6_route(o->dest, &o->gateway, o->metric, o->ifname);
Expand Down
2 changes: 2 additions & 0 deletions ncd/modules/process_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <string.h>

#include <misc/offset.h>
#include <misc/debug.h>
#include <structure/LinkedList1.h>
#include <ncd/NCDModule.h>

Expand Down Expand Up @@ -203,6 +204,7 @@ void process_free (struct process *p)
void process_retry_timer_handler (struct process *p)
{
struct instance *o = p->manager;
B_USE(o)
ASSERT(p->state == PROCESS_STATE_RETRYING)
ASSERT(!o->dying)
ASSERT(p->have_params)
Expand Down
Loading

0 comments on commit 93bc612

Please sign in to comment.