From fce0aa0a2f06b24f241ead2e74475ea8874394b6 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 4 Apr 2013 17:28:30 +0200 Subject: [PATCH] Fix compiler warnings with -O2. Signed-off-by: Miroslav Lichvar --- clock.c | 2 +- config.c | 2 +- phc2sys.c | 6 ++++-- port.c | 8 +++++--- sk.c | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/clock.c b/clock.c index e4af8f4..bd22de5 100644 --- a/clock.c +++ b/clock.c @@ -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++) { diff --git a/config.c b/config.c index 4727942..4c4a7b1 100644 --- a/config.c +++ b/config.c @@ -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"); diff --git a/phc2sys.c b/phc2sys.c index d210df8..c4486c3 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -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) diff --git a/port.c b/port.c index 4346422..d29a70c 100644 --- a/port.c +++ b/port.c @@ -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) { @@ -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 diff --git a/sk.c b/sk.c index e09d459..786d4d3 100644 --- a/sk.c +++ b/sk.c @@ -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; @@ -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: