From bdb71d94c201695b22132d339fe8d1eac9363124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Fri, 19 Jun 2020 15:30:33 +0200 Subject: [PATCH] dde_bsd: pull strlcpy in via contrib code For historical reason the 'strlcpy' implemention was directly pull in into the emulation environment. There is, however, no reason not to use the contrib sources in the usual fashion. Issue #3929. --- repos/dde_bsd/audio.list | 1 + repos/dde_bsd/lib/mk/dde_bsd_audio.inc | 3 ++ repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk | 2 +- repos/dde_bsd/ports/dde_bsd.hash | 2 +- .../dde_bsd/src/lib/audio/include/bsd_emul.h | 8 ++++ repos/dde_bsd/src/lib/audio/misc.cc | 42 ------------------- 6 files changed, 14 insertions(+), 44 deletions(-) diff --git a/repos/dde_bsd/audio.list b/repos/dde_bsd/audio.list index 1e5a583f77..fa48dbcc7a 100644 --- a/repos/dde_bsd/audio.list +++ b/repos/dde_bsd/audio.list @@ -1,3 +1,4 @@ +sys/lib/libkern/strlcpy.c sys/dev/audio.c sys/dev/audio_if.h sys/dev/pci/auich.c diff --git a/repos/dde_bsd/lib/mk/dde_bsd_audio.inc b/repos/dde_bsd/lib/mk/dde_bsd_audio.inc index 9653e62c8d..c8d05a9fe4 100644 --- a/repos/dde_bsd/lib/mk/dde_bsd_audio.inc +++ b/repos/dde_bsd/lib/mk/dde_bsd_audio.inc @@ -25,6 +25,9 @@ CC_OPT += -fno-builtin-printf -fno-builtin-snprintf -fno-builtin-vsnprintf \ CC_OPT += -D_KERNEL +# libkern +SRC_C += lib/libkern/strlcpy.c + # disable false warning in audio.c:786 CC_C_OPT += -Wno-maybe-uninitialized diff --git a/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk b/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk index 7798718adb..2ee4990c18 100644 --- a/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk +++ b/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk @@ -9,7 +9,7 @@ ifeq ($(called_from_lib_mk),yes) BSD_CONTRIB_DIR := $(call select_from_ports,dde_bsd)/src/lib/audio BSD_EMUL_H := $(REP_DIR)/src/lib/audio/include/bsd_emul.h -SCAN_DIRS := $(addprefix $(BSD_CONTRIB_DIR)/, dev sys) +SCAN_DIRS := $(addprefix $(BSD_CONTRIB_DIR)/, dev lib sys) GEN_INCLUDES := $(shell grep -rIh "^\#include .*" $(SCAN_DIRS) |\ sed "s/^\#include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" | sort | uniq) diff --git a/repos/dde_bsd/ports/dde_bsd.hash b/repos/dde_bsd/ports/dde_bsd.hash index e7335ee395..9f302da730 100644 --- a/repos/dde_bsd/ports/dde_bsd.hash +++ b/repos/dde_bsd/ports/dde_bsd.hash @@ -1 +1 @@ -680424ed9e93503999ebf7e3878ba511cbcb8941 +210145e50db8518aeb9d1cbdf1da82f6a9255113 diff --git a/repos/dde_bsd/src/lib/audio/include/bsd_emul.h b/repos/dde_bsd/src/lib/audio/include/bsd_emul.h index e2cdd8603c..acabe4d727 100644 --- a/repos/dde_bsd/src/lib/audio/include/bsd_emul.h +++ b/repos/dde_bsd/src/lib/audio/include/bsd_emul.h @@ -715,6 +715,14 @@ struct timeval void microuptime(struct timeval *); + +/*************************** + ** lib/libkern/libkern.h ** + ***************************/ + +size_t strlcpy(char *, char const *, size_t); + + #include #endif /* _BSD_EMUL_H_ */ diff --git a/repos/dde_bsd/src/lib/audio/misc.cc b/repos/dde_bsd/src/lib/audio/misc.cc index b8b09a7ee0..63ed5cac04 100644 --- a/repos/dde_bsd/src/lib/audio/misc.cc +++ b/repos/dde_bsd/src/lib/audio/misc.cc @@ -452,45 +452,3 @@ extern "C" int strcmp(const char *s1, const char *s2) { return Genode::strcmp(s1, s2); } - - -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -extern "C" size_t strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -}