Skip to content

Commit

Permalink
Linting; Fixed -Wunused-variable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
willemt committed Feb 1, 2015
1 parent 9eacf4d commit 2a50ff7
Show file tree
Hide file tree
Showing 5 changed files with 520 additions and 468 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GCOV_CCFLAGS = -fprofile-arcs -ftest-coverage
SHELL = /bin/bash
CFLAGS += -Iinclude -Werror -Werror=return-type -Werror=uninitialized -Wcast-align \
-Wno-pointer-sign -fno-omit-frame-pointer -fno-common -fsigned-char \
-Wunused-variable \
$(GCOV_CCFLAGS) -I$(LLQUEUE_DIR) -Iinclude -g -O2 -fPIC

UNAME := $(shell uname)
Expand Down
37 changes: 16 additions & 21 deletions src/raft_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Copyright (c) 2013, Willem-Hendrik Thiart
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
* found in the LICENSE file.
*
* @file
* @brief ADT for managing Raft log entries (aka entries)
Expand All @@ -24,13 +24,13 @@
typedef struct
{
/* size of array */
int size;
int size;

/* the amount of elements in the array */
int count;
int count;

/* position of the queue */
int front, back;
int front, back;

/* we compact the log, and thus need to increment the base idx */
int base_log_idx;
Expand All @@ -40,15 +40,15 @@ typedef struct

static void __ensurecapacity(
log_private_t * me
)
)
{
int i, j;
raft_entry_t *temp;

if (me->count < me->size)
return;

temp = calloc(1,sizeof(raft_entry_t) * me->size * 2);
temp = calloc(1, sizeof(raft_entry_t) * me->size * 2);

for (i = 0, j = me->front; i < me->count; i++, j++)
{
Expand All @@ -70,11 +70,11 @@ log_t* log_new()
{
log_private_t* me;

me = calloc(1,sizeof(log_private_t));
me = calloc(1, sizeof(log_private_t));
me->size = INITIAL_CAPACITY;
me->count = 0;
me->back = in(me)->front = 0;
me->entries = calloc(1,sizeof(raft_entry_t) * me->size);
me->entries = calloc(1, sizeof(raft_entry_t) * me->size);
return (void*)me;
}

Expand All @@ -90,7 +90,7 @@ int log_append_entry(log_t* me_, raft_entry_t* c)
// if (hashmap_get(me->log_map, (void*)c->id+1))
// return 0;

memcpy(&me->entries[me->back],c,sizeof(raft_entry_t));
memcpy(&me->entries[me->back], c, sizeof(raft_entry_t));
me->entries[me->back].num_nodes = 0;
me->count++;
me->back++;
Expand Down Expand Up @@ -120,13 +120,13 @@ int log_count(log_t* me_)
void log_delete(log_t* me_, int idx)
{
log_private_t* me = (void*)me_;
int end, i;
int end;

/* idx starts at 1 */
idx -= 1;
idx -= me->base_log_idx;

for (end = log_count(me_); idx<end; idx++)
for (end = log_count(me_); idx < end; idx++)
{
me->back--;
me->count--;
Expand All @@ -145,7 +145,7 @@ void log_delete(log_t* me_, int idx)
in(me)->back = in(me)->size;
elem = me->entries[in(me)->back];

return (void *) elem;
return (void*)elem;
#endif
}

Expand All @@ -160,22 +160,20 @@ void *log_poll(log_t * me_)
me->front++;
me->count--;
me->base_log_idx++;
return (void *) elem;
return (void*)elem;
}

raft_entry_t *log_peektail(log_t * me_)
{
log_private_t* me = (void*)me_;
const void *elem;
int i;

if (0 == log_count(me_))
return NULL;

if (0 == me->back)
return &me->entries[me->size-1];
return &me->entries[me->size - 1];
else
return &me->entries[me->back-1];
return &me->entries[me->back - 1];
}

void log_empty(log_t * me_)
Expand All @@ -197,12 +195,9 @@ void log_free(log_t * me_)

void log_mark_node_has_committed(log_t* me_, int idx)
{
log_private_t* me = (void*)me_;
raft_entry_t* e;

if ((e = log_get_from_idx(me_,idx)))
{
if ((e = log_get_from_idx(me_, idx)))
e->num_nodes += 1;
}
}

Loading

0 comments on commit 2a50ff7

Please sign in to comment.