Skip to content

Commit

Permalink
tools: remove strncpy() use
Browse files Browse the repository at this point in the history
`checkpatch` has sufficiently annoyed me to fix this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
  • Loading branch information
eqvinox committed Oct 22, 2024
1 parent 4606612 commit cf4fc9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tools/start-stop-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
#include <linux/sched.h>
#endif

/* this is in zebra.h, but including that here isn't a good fit... */
#ifndef HAVE_STRLCPY
size_t strlcpy(char *__restrict dest,
const char *__restrict src, size_t destsize);
#endif

static int testmode = 0;
static int quietmode = 0;
static int exitnodo = 1;
Expand Down Expand Up @@ -749,8 +755,7 @@ static void do_stop(int signal_nr, int quietmode, int *n_killed,

static void set_what_stop(const char *str)
{
strncpy(what_stop, str, sizeof(what_stop));
what_stop[sizeof(what_stop) - 1] = '\0';
strlcpy(what_stop, str, sizeof(what_stop));
}

static int run_stop_schedule(void)
Expand Down
2 changes: 1 addition & 1 deletion tools/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tools_gen_northbound_callbacks_LDADD = lib/libfrr.la $(LIBYANG_LIBS)
tools_gen_yang_deviations_SOURCES = tools/gen_yang_deviations.c
tools_gen_yang_deviations_LDADD = lib/libfrr.la $(LIBYANG_LIBS)

tools_ssd_SOURCES = tools/start-stop-daemon.c
tools_ssd_SOURCES = tools/start-stop-daemon.c lib/strlcpy.c
tools_ssd_CPPFLAGS =

# don't bother autoconf'ing these for a simple optional tool
Expand Down

0 comments on commit cf4fc9c

Please sign in to comment.