Fix compiler warnings with -O2.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2013-04-04 17:28:30 +02:00 committed by Richard Cochran
parent f8563452a8
commit fce0aa0a2f
5 changed files with 13 additions and 9 deletions

View File

@ -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) 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; struct port *fwd;
if (forwarding(c, p) && msg->management.boundaryHops) { if (forwarding(c, p) && msg->management.boundaryHops) {
for (i = 0; i < c->nports + 1; i++) { for (i = 0; i < c->nports + 1; i++) {

View File

@ -436,7 +436,7 @@ int config_read(char *name, struct config *cfg)
enum parser_result parser_res; enum parser_result parser_res;
FILE *fp; FILE *fp;
char buf[1024], *line, *c, *option, *value; 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"); fp = 0 == strncmp(name, "-", 2) ? stdin : fopen(name, "r");

View File

@ -330,12 +330,14 @@ static int is_msg_mgt(struct ptp_message *msg)
static int get_mgt_id(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) 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) static int init_pmc(struct clock *clock)

8
port.c
View File

@ -1829,6 +1829,7 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
{ {
enum port_state next; enum port_state next;
struct fault_interval i; struct fault_interval i;
int fri_asap = 0;
if (clock_slave_only(p->clock)) { if (clock_slave_only(p->clock)) {
if (event == EV_RS_MASTER || event == EV_RS_GRAND_MASTER) { 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); next = ptp_fsm(p->state, event, mdiff);
} }
fault_interval(p, last_fault_type(p), &i); if (!fault_interval(p, last_fault_type(p), &i) &&
int fri_asap = (i.val == FRI_ASAP && i.type == FTMO_LOG2_SECONDS) || ((i.val == FRI_ASAP && i.type == FTMO_LOG2_SECONDS) ||
(i.val == 0 && i.type == FTMO_LINEAR_SECONDS); (i.val == 0 && i.type == FTMO_LINEAR_SECONDS)))
fri_asap = 1;
if (PS_INITIALIZING == next || (PS_FAULTY == next && fri_asap)) { if (PS_INITIALIZING == next || (PS_FAULTY == next && fri_asap)) {
/* /*
* This is a special case. Since we initialize the * This is a special case. Since we initialize the

4
sk.c
View File

@ -200,7 +200,7 @@ int sk_receive(int fd, void *buf, int buflen,
struct hw_timestamp *hwts, int flags) struct hw_timestamp *hwts, int flags)
{ {
char control[256]; char control[256];
int cnt, level, try_again, type; int cnt = 0, level, try_again, type;
struct cmsghdr *cm; struct cmsghdr *cm;
struct iovec iov = { buf, buflen }; struct iovec iov = { buf, buflen };
struct msghdr msg; 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, int sk_timestamping_init(int fd, char *device, enum timestamp_type type,
enum transport_type transport) enum transport_type transport)
{ {
int err, filter1, filter2, flags, one_step; int err, filter1, filter2 = 0, flags, one_step;
switch (type) { switch (type) {
case TS_SOFTWARE: case TS_SOFTWARE: