Permalink
Browse files

Fix Debian issue #634393 and GitHub issues #10, #11: Fails to build f…

…rom source

main.c:
        Removed unused variables in main.c, add friendly warning if
        call to system() fails.
vif.c:
        src is not used in start_vif()
route.c:
        Added __attribute__((unused)) to several (yet?) unused constructs
        to instruct GCC to not warn.

pim_proto.c:
        Dito.
  • Loading branch information...
bobek authored and troglobit committed Sep 5, 2011
1 parent 7655b67 commit b6e7f8c5eacbd52211e8b5309f82e3bad8c980e3
Showing with 84 additions and 87 deletions.
  1. +38 −39 main.c
  2. +8 −8 pim_proto.c
  3. +4 −4 route.c
  4. +34 −36 vif.c
View
77 main.c
@@ -167,10 +167,10 @@ int register_input_handler(int fd, ihfunc_t func)
{
if (nhandlers >= NHANDLERS)
return -1;
-
+
ihandlers[nhandlers].fd = fd;
ihandlers[nhandlers++].func = func;
-
+
return 0;
}
@@ -238,11 +238,11 @@ static void killshow(int signo, char *file)
remove(file);
kill(pid, signo);
if (file) {
- int result;
-
usleep(200);
snprintf(buf, sizeof(buf), "cat %s", file);
- result = system(buf);
+ if (-1 == system(buf)) {
+ warnx("Failed listing file %s\n", file);
+ }
}
}
}
@@ -287,8 +287,8 @@ static int usage(void)
}
int main(int argc, char *argv[])
-{
- int dummy, dummysigalrm, foreground = 0;
+{
+ int dummysigalrm, foreground = 0;
struct timeval tv, difftime, curtime, lasttime, *timeout;
fd_set rfds, readers;
int nfds, n, i, secs, ch;
@@ -308,7 +308,7 @@ int main(int argc, char *argv[])
/* {"show-debug", 0, 0, 'p'}, */
{0, 0, 0, 0}
};
-
+
snprintf(versionstring, sizeof (versionstring), "pimd version %s", todaysversion);
while ((ch = getopt_long (argc, argv, "c:d::fhlNP::vqr", long_options, NULL)) != EOF) {
@@ -430,7 +430,7 @@ int main(int argc, char *argv[])
}
fprintf(stderr, ")\n");
}
-
+
/*
* Create directory for runtime files
*/
@@ -450,7 +450,7 @@ int main(int argc, char *argv[])
do_randomize();
time(&boottime);
-
+
/* Start up the log rate-limiter */
resetlogging(NULL);
@@ -462,20 +462,20 @@ int main(int argc, char *argv[])
#endif /* HAVE_ROUTING_SOCKETS */
init_pim_mrt();
init_timers();
-
+
/* TODO: check the kernel DVMRP/MROUTED/PIM support version */
-
+
#ifdef SNMP
if (i = snmp_init())
return i;
#endif /* SNMP */
init_vifs();
init_rp_and_bsr(); /* Must be after init_vifs() */
-
+
#ifdef RSRR
rsrr_init();
#endif /* RSRR */
-
+
sa.sa_handler = handler;
sa.sa_flags = 0; /* Interrupt system calls */
sigemptyset(&sa.sa_mask);
@@ -485,7 +485,7 @@ int main(int argc, char *argv[])
sigaction(SIGINT, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
-
+
FD_ZERO(&readers);
FD_SET(igmp_socket, &readers);
nfds = igmp_socket + 1;
@@ -494,15 +494,15 @@ int main(int argc, char *argv[])
if (ihandlers[i].fd >= nfds)
nfds = ihandlers[i].fd + 1;
}
-
+
IF_DEBUG(DEBUG_IF)
dump_vifs(stderr);
IF_DEBUG(DEBUG_PIM_MRT)
dump_pim_mrt(stderr);
-
+
/* schedule first timer interrupt */
timer_setTimer(TIMER_INTERVAL, timer, NULL);
-
+
if (!debug && !foreground) {
/* Detach from the terminal */
haveterminal = 0;
@@ -516,7 +516,7 @@ int main(int argc, char *argv[])
(void)dup2(0, 2);
#ifdef SYSV
(void)setpgrp();
-#else
+#else
#ifdef TIOCNOTTY
n = open("/dev/tty", 2);
if (n >= 0) {
@@ -529,15 +529,14 @@ int main(int argc, char *argv[])
#endif /* TIOCNOTTY */
#endif /* SYSV */
} /* End of child process code */
-
+
if (pidfile(NULL)) {
warn("Cannot create pidfile");
}
/*
* Main receive loop.
*/
- dummy = 0;
dummysigalrm = SIGALRM;
difftime.tv_usec = 0;
gettimeofday(&curtime, NULL);
@@ -569,7 +568,7 @@ int main(int argc, char *argv[])
boottime = 0;
}
}
-
+
if (sighandled) {
if (sighandled & GOT_SIGINT) {
sighandled &= ~GOT_SIGINT;
@@ -578,7 +577,7 @@ int main(int argc, char *argv[])
if (sighandled & GOT_SIGHUP) {
sighandled &= ~GOT_SIGHUP;
restart(SIGHUP);
-
+
/* reconstruct readers and nfds */
FD_ZERO(&readers);
FD_SET(igmp_socket, &readers);
@@ -616,7 +615,7 @@ int main(int argc, char *argv[])
}
}
}
-
+
/*
* Handle timeout queue.
*
@@ -693,10 +692,10 @@ static void timer(void *i __attribute__((unused)))
age_vifs(); /* Timeout neighbors and groups */
age_routes(); /* Timeout routing entries */
age_misc(); /* Timeout the rest (Cand-RP list, etc) */
-
+
virtual_time += TIMER_INTERVAL;
timer_setTimer(TIMER_INTERVAL, timer, NULL);
-}
+}
/*
* Performs all necessary functions to quit gracefully
@@ -706,23 +705,23 @@ static void cleanup(void)
{
vifi_t vifi;
struct uvif *v;
-
+
/* inform all neighbors that I'm going to die */
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if ((v->uv_flags &
(VIFF_DOWN | VIFF_DISABLED | VIFF_REGISTER | VIFF_TUNNEL)) == 0)
send_pim_hello(v, 0);
}
-
+
#ifdef RSRR
rsrr_clean();
#endif /* RSRR */
-
+
/* TODO: XXX (not in the spec): if I am the BSR, somehow inform the
* other routers I am going down and need to elect another BSR?
* (probably by sending a the Cand-RP-set with my_priority=LOWEST?)
*/
-
+
k_stop_pim(igmp_socket);
}
@@ -740,15 +739,15 @@ static void handler(int sig)
case SIGTERM:
sighandled |= GOT_SIGINT;
break;
-
+
case SIGHUP:
sighandled |= GOT_SIGHUP;
break;
-
+
case SIGUSR1:
sighandled |= GOT_SIGUSR1;
break;
-
+
case SIGUSR2:
sighandled |= GOT_SIGUSR2;
break;
@@ -765,9 +764,9 @@ static void restart(int i __attribute__((unused)))
#ifdef SNMP
int s;
#endif /* SNMP */
-
+
logit(LOG_NOTICE, 0, "%s % restart", versionstring);
-
+
/*
* reset all the entries
*/
@@ -791,11 +790,11 @@ static void restart(int i __attribute__((unused)))
#ifdef HAVE_ROUTING_SOCKETS
close(routing_socket);
#endif /* HAVE_ROUTING_SOCKETS */
-
+
/*
* start processing again
*/
-
+
init_igmp();
init_pim();
#ifdef HAVE_ROUTING_SOCKETS
@@ -817,7 +816,7 @@ static void resetlogging(void *arg)
{
int nxttime = 60;
void *narg = NULL;
-
+
if (arg == NULL && log_nmsgs > LOG_MAX_MSGS) {
nxttime = LOG_SHUT_UP;
narg = (void *)&log_nmsgs; /* just need some valid void * */
@@ -826,7 +825,7 @@ static void resetlogging(void *arg)
} else {
log_nmsgs = 0;
}
-
+
timer_setTimer(nxttime, resetlogging, narg);
}
View
@@ -63,7 +63,7 @@ int receive_pim_hello(u_int32 src, u_int32 dst __attribute__((unused)), char *pi
pim_nbr_entry_t *nbr, *prev_nbr, *new_nbr;
u_int16 holdtime = 0;
int bsr_length;
- u_int8 *data_ptr;
+ u_int8 *data_ptr __attribute__((unused));
srcentry_t *srcentry_ptr;
mrtentry_t *mrtentry_ptr;
@@ -225,7 +225,7 @@ void delete_pim_nbr(pim_nbr_entry_t *nbr_delete)
mrtentry_t *mrtentry_ptr;
mrtentry_t *mrtentry_srcs;
grpentry_t *grpentry_ptr;
- pim_nbr_entry_t *new_nbr;
+ pim_nbr_entry_t *new_nbr __attribute__((unused));
cand_rp_t *cand_rp_ptr;
rp_grp_entry_t *rp_grp_entry_ptr;
rpentry_t *rpentry_ptr;
@@ -1024,7 +1024,7 @@ int receive_pim_join_prune(u_int32 src, u_int32 dst __attribute__((unused)), cha
u_int32 s_mask;
u_int32 g_mask;
u_int8 s_flags;
- u_int8 reserved;
+ u_int8 reserved __attribute__((unused));
rpentry_t *rpentry_ptr;
mrtentry_t *mrtentry_ptr;
mrtentry_t *mrtentry_srcs;
@@ -2368,7 +2368,7 @@ static void send_jp_message(pim_nbr_entry_t *pim_nbr)
datalen = pim_nbr->build_jp_message->jp_message_size;
vifi = pim_nbr->vifi;
- memcpy(pim_send_buf + sizeof(struct ip) + sizeof(pim_header_t),
+ memcpy(pim_send_buf + sizeof(struct ip) + sizeof(pim_header_t),
pim_nbr->build_jp_message->jp_message, datalen);
send_pim(pim_send_buf, uvifs[vifi].uv_lcl_addr, allpimrouters_group,
PIM_JOIN_PRUNE, datalen);
@@ -2645,7 +2645,7 @@ int send_pim_assert(u_int32 source, u_int32 group, vifi_t vifi, mrtentry_t *mrte
u_int8 *data_start_ptr;
u_int32 local_preference;
u_int32 local_metric;
- srcentry_t *srcentry_ptr;
+ srcentry_t *srcentry_ptr __attribute__((unused));
/* Don't send assert if the outgoing interface a tunnel or register vif */
/* TODO: XXX: in the code above asserts are accepted over VIFF_TUNNEL.
@@ -2746,18 +2746,18 @@ int receive_pim_bootstrap(u_int32 src, u_int32 dst, char *pim_message, int datal
pim_encod_uni_addr_t new_bsr_uni_addr;
u_int32 new_bsr_address;
struct rpfctl rpfc;
- pim_nbr_entry_t *n, *rpf_neighbor;
+ pim_nbr_entry_t *n, *rpf_neighbor __attribute__((unused));
u_int32 neighbor_addr;
vifi_t vifi, incoming = NO_VIF;
int min_datalen;
pim_encod_grp_addr_t curr_group_addr;
pim_encod_uni_addr_t curr_rp_addr;
u_int8 curr_rp_count;
u_int8 curr_frag_rp_count;
- u_int16 reserved_short;
+ u_int16 reserved_short __attribute__((unused));
u_int16 curr_rp_holdtime;
u_int8 curr_rp_priority;
- u_int8 reserved_byte;
+ u_int8 reserved_byte __attribute__((unused));
u_int32 curr_group_mask;
u_int32 prefix_h;
grp_mask_t *grp_mask_ptr;
View
@@ -464,11 +464,11 @@ int change_interfaces(mrtentry_t *mrtentry_ptr,
u_int16 flags)
{
vifbitmap_t new_joined_oifs; /* The oifs for that particular mrtentry */
- vifbitmap_t old_joined_oifs;
- vifbitmap_t old_pruned_oifs;
- vifbitmap_t old_leaves;
+ vifbitmap_t old_joined_oifs __attribute__ ((unused));
+ vifbitmap_t old_pruned_oifs __attribute__ ((unused));
+ vifbitmap_t old_leaves __attribute__ ((unused));
vifbitmap_t new_leaves;
- vifbitmap_t old_asserted_oifs;
+ vifbitmap_t old_asserted_oifs __attribute__ ((unused));
vifbitmap_t new_real_oifs; /* The result oifs */
vifbitmap_t old_real_oifs;
vifi_t old_iif;
Oops, something went wrong.

0 comments on commit b6e7f8c

Please sign in to comment.