Factor out copy_cmdarg() to common ncmlib header.
This commit is contained in:
parent
f365498188
commit
a73a28588f
14
ndhc/ndhc.c
14
ndhc/ndhc.c
@ -70,6 +70,7 @@
|
||||
#include "seccomp.h"
|
||||
#include "ifchd.h"
|
||||
#include "duiaid.h"
|
||||
#include "copy_cmdarg.h"
|
||||
|
||||
struct client_state_t cs = {
|
||||
.ifchWorking = 0,
|
||||
@ -418,19 +419,6 @@ void background(void)
|
||||
write_pid(pidfile);
|
||||
}
|
||||
|
||||
static void copy_cmdarg(char *dest, char *src, size_t destlen, char *argname)
|
||||
{
|
||||
ssize_t olen = snprintf(dest, destlen, "%s", src);
|
||||
if (olen < 0) {
|
||||
log_error("snprintf failed on %s; your system is broken?", argname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((size_t)olen >= destlen) {
|
||||
log_error("snprintf would truncate %s arg; it's too long", argname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const struct option arg_options[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user