mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-28 16:06:20 +00:00
Quagga: Fix some more compile warnings
The debian build process under Jessie has a 'newer' gcc compiler that is more stringent on warnings returned. This commit cleans up some more warnings returned. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
8748363d60
commit
7a49a5b51f
@ -246,7 +246,12 @@ main (int argc, char **argv, char **envp)
|
||||
_argc = argc;
|
||||
_argv = argv;
|
||||
_envp = envp;
|
||||
getcwd (_cwd, sizeof (_cwd));
|
||||
if (getcwd (_cwd, sizeof (_cwd)) == NULL)
|
||||
{
|
||||
zlog_err ("ISISd: Unable to determine CWD: %d", errno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (*argv[0] == '.')
|
||||
snprintf (_progpath, sizeof (_progpath), "%s/%s", _cwd, _argv[0]);
|
||||
else
|
||||
@ -348,8 +353,11 @@ main (int argc, char **argv, char **envp)
|
||||
return(0);
|
||||
|
||||
/* demonize */
|
||||
if (daemon_mode)
|
||||
daemon (0, 0);
|
||||
if (daemon_mode && daemon (0, 0) < 0)
|
||||
{
|
||||
zlog_err("ISISd daemon failed: %s", strerror(errno));
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Process ID file creation. */
|
||||
if (pid_file[0] != '\0')
|
||||
|
42
lib/log.c
42
lib/log.c
@ -67,8 +67,36 @@ const char *zlog_priority[] =
|
||||
"debugging",
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* write_wrapper
|
||||
*
|
||||
* glibc has declared that the return value from write *must* not be
|
||||
* ignored.
|
||||
* gcc see's this problem and issues a warning for the line.
|
||||
*
|
||||
* Why is this a big deal you say? Because both of them are right
|
||||
* and if you have -Werror enabled then all calls to write
|
||||
* generate a build error and the build stops.
|
||||
*
|
||||
* clang has helpfully allowed this construct:
|
||||
* (void)write(...)
|
||||
* to tell the compiler yeah I know it has a return value
|
||||
* I don't care about it at this time.
|
||||
* gcc doesn't have this ability.
|
||||
*
|
||||
* This code was written such that it didn't care about the
|
||||
* return value from write. At this time do I want
|
||||
* to go through and fix and test this code for correctness.
|
||||
* So just wrapper the bad behavior and move on.
|
||||
*/
|
||||
static void write_wrapper (int fd, const void *buf, size_t count)
|
||||
{
|
||||
if (write (fd, buf, count) <= 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* For time string format. */
|
||||
|
||||
@ -324,7 +352,7 @@ syslog_sigsafe(int priority, const char *msg, size_t msglen)
|
||||
}
|
||||
s = str_append(LOC,": ");
|
||||
s = str_append(LOC,msg);
|
||||
write(syslog_fd,buf,s-buf);
|
||||
write_wrapper (syslog_fd,buf,s-buf);
|
||||
#undef LOC
|
||||
}
|
||||
|
||||
@ -405,7 +433,7 @@ zlog_signal(int signo, const char *action
|
||||
/* N.B. implicit priority is most severe */
|
||||
#define PRI LOG_CRIT
|
||||
|
||||
#define DUMP(FD) write(FD, buf, s-buf);
|
||||
#define DUMP(FD) write_wrapper(FD, buf, s-buf);
|
||||
/* If no file logging configured, try to write to fallback log file. */
|
||||
if ((logfile_fd >= 0) || ((logfile_fd = open_crashlog()) >= 0))
|
||||
DUMP(logfile_fd)
|
||||
@ -456,17 +484,17 @@ zlog_backtrace_sigsafe(int priority, void *program_counter)
|
||||
#define DUMP(FD) { \
|
||||
if (program_counter) \
|
||||
{ \
|
||||
write(FD, pclabel, sizeof(pclabel)-1); \
|
||||
write_wrapper(FD, pclabel, sizeof(pclabel)-1); \
|
||||
backtrace_symbols_fd(&program_counter, 1, FD); \
|
||||
} \
|
||||
write(FD, buf, s-buf); \
|
||||
write_wrapper(FD, buf, s-buf); \
|
||||
backtrace_symbols_fd(array, size, FD); \
|
||||
}
|
||||
#elif defined(HAVE_PRINTSTACK)
|
||||
#define DUMP(FD) { \
|
||||
if (program_counter) \
|
||||
write((FD), pclabel, sizeof(pclabel)-1); \
|
||||
write((FD), buf, s-buf); \
|
||||
write_wrapper((FD), pclabel, sizeof(pclabel)-1); \
|
||||
write_wrapper((FD), buf, s-buf); \
|
||||
printstack((FD)); \
|
||||
}
|
||||
#endif /* HAVE_GLIBC_BACKTRACE, HAVE_PRINTSTACK */
|
||||
|
@ -336,7 +336,13 @@ main (int argc, char **argv, char **env)
|
||||
|
||||
/* Ignore error messages */
|
||||
if (no_error)
|
||||
freopen("/dev/null", "w", stdout);
|
||||
{
|
||||
if (freopen("/dev/null", "w", stdout) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Exiting: Failed to duplicate stdout with -n option");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we pass authentication before proceeding. */
|
||||
vtysh_auth ();
|
||||
|
Loading…
Reference in New Issue
Block a user