Skip to content

Commit

Permalink
Fix compiler warnings with -O2.
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Lichvar <[email protected]>
  • Loading branch information
mlichvar authored and richardcochran committed Apr 5, 2013
1 parent f856345 commit fce0aa0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ void clock_install_fda(struct clock *c, struct port *p, struct fdarray fda)

static void clock_forward_mgmt_msg(struct clock *c, struct port *p, struct ptp_message *msg)
{
int i, pdulen, msg_ready = 0;
int i, pdulen = 0, msg_ready = 0;
struct port *fwd;
if (forwarding(c, p) && msg->management.boundaryHops) {
for (i = 0; i < c->nports + 1; i++) {
Expand Down
2 changes: 1 addition & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ int config_read(char *name, struct config *cfg)
enum parser_result parser_res;
FILE *fp;
char buf[1024], *line, *c, *option, *value;
int current_port, line_num;
int current_port = 0, line_num;

fp = 0 == strncmp(name, "-", 2) ? stdin : fopen(name, "r");

Expand Down
6 changes: 4 additions & 2 deletions phc2sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,14 @@ static int is_msg_mgt(struct ptp_message *msg)

static int get_mgt_id(struct ptp_message *msg)
{
return ((struct management_tlv *) msg->management.suffix)->id;
struct management_tlv *mgt = (struct management_tlv *) msg->management.suffix;
return mgt->id;
}

static void *get_mgt_data(struct ptp_message *msg)
{
return ((struct management_tlv *) msg->management.suffix)->data;
struct management_tlv *mgt = (struct management_tlv *) msg->management.suffix;
return mgt->data;
}

static int init_pmc(struct clock *clock)
Expand Down
8 changes: 5 additions & 3 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,7 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
{
enum port_state next;
struct fault_interval i;
int fri_asap = 0;

if (clock_slave_only(p->clock)) {
if (event == EV_RS_MASTER || event == EV_RS_GRAND_MASTER) {
Expand All @@ -1839,9 +1840,10 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
next = ptp_fsm(p->state, event, mdiff);
}

fault_interval(p, last_fault_type(p), &i);
int fri_asap = (i.val == FRI_ASAP && i.type == FTMO_LOG2_SECONDS) ||
(i.val == 0 && i.type == FTMO_LINEAR_SECONDS);
if (!fault_interval(p, last_fault_type(p), &i) &&
((i.val == FRI_ASAP && i.type == FTMO_LOG2_SECONDS) ||
(i.val == 0 && i.type == FTMO_LINEAR_SECONDS)))
fri_asap = 1;
if (PS_INITIALIZING == next || (PS_FAULTY == next && fri_asap)) {
/*
* This is a special case. Since we initialize the
Expand Down
4 changes: 2 additions & 2 deletions sk.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int sk_receive(int fd, void *buf, int buflen,
struct hw_timestamp *hwts, int flags)
{
char control[256];
int cnt, level, try_again, type;
int cnt = 0, level, try_again, type;
struct cmsghdr *cm;
struct iovec iov = { buf, buflen };
struct msghdr msg;
Expand Down Expand Up @@ -272,7 +272,7 @@ int sk_receive(int fd, void *buf, int buflen,
int sk_timestamping_init(int fd, char *device, enum timestamp_type type,
enum transport_type transport)
{
int err, filter1, filter2, flags, one_step;
int err, filter1, filter2 = 0, flags, one_step;

switch (type) {
case TS_SOFTWARE:
Expand Down

0 comments on commit fce0aa0

Please sign in to comment.