All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH v2 12/20] lib: move strlcat()
Date: Wed, 21 Apr 2021 16:24:05 +0200	[thread overview]
Message-ID: <e4b59a63-ab9a-33a8-df97-2262ced22a6f@suse.com> (raw)
In-Reply-To: <3ae091ce-6f6c-3ec6-abd3-4490239a707f@suse.com>

Allow the function to be individually linkable, discardable, and
overridable.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/string.c
+++ b/xen/common/string.c
@@ -56,35 +56,6 @@ int (strcasecmp)(const char *s1, const c
 }
 #endif
 
-#ifndef __HAVE_ARCH_STRLCAT
-/**
- * strlcat - Append a %NUL terminated string into a sized buffer
- * @dest: Where to copy the string to
- * @src: Where to copy the string from
- * @size: size of destination buffer
- *
- * Compatible with *BSD: the result is always a valid
- * NUL-terminated string that fits in the buffer (unless,
- * of course, the buffer size is zero).
- */
-size_t strlcat(char *dest, const char *src, size_t size)
-{
-	size_t slen = strlen(src);
-	size_t dlen = strnlen(dest, size);
-	char *p = dest + dlen;
-
-	while ((p - dest) < size)
-		if ((*p++ = *src++) == '\0')
-			break;
-
-	if (dlen < size)
-		*(p-1) = '\0';
-
-	return slen + dlen;
-}
-EXPORT_SYMBOL(strlcat);
-#endif
-
 #ifndef __HAVE_ARCH_STRCHR
 /**
  * strchr - Find the first occurrence of a character in a string
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -15,6 +15,7 @@ lib-y += parse-size.o
 lib-y += rbtree.o
 lib-y += sort.o
 lib-y += strcmp.o
+lib-y += strlcat.o
 lib-y += strlcpy.o
 lib-y += strlen.o
 lib-y += strncmp.o
--- /dev/null
+++ b/xen/lib/strlcat.c
@@ -0,0 +1,41 @@
+/*
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+#include <xen/string.h>
+
+/**
+ * strlcat - Append a %NUL terminated string into a sized buffer
+ * @dest: Where to copy the string to
+ * @src: Where to copy the string from
+ * @size: size of destination buffer
+ *
+ * Compatible with *BSD: the result is always a valid
+ * NUL-terminated string that fits in the buffer (unless,
+ * of course, the buffer size is zero).
+ */
+size_t strlcat(char *dest, const char *src, size_t size)
+{
+	size_t slen = strlen(src);
+	size_t dlen = strnlen(dest, size);
+	char *p = dest + dlen;
+
+	while ((p - dest) < size)
+		if ((*p++ = *src++) == '\0')
+			break;
+
+	if (dlen < size)
+		*(p-1) = '\0';
+
+	return slen + dlen;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ */



  parent reply	other threads:[~2021-04-21 14:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 14:15 [PATCH v2 00/20] further population of xen/lib/ Jan Beulich
2021-04-21 14:18 ` [PATCH v2 01/20] lib: move memset() Jan Beulich
2021-04-21 14:18 ` [PATCH v2 02/20] lib: move memcpy() Jan Beulich
2021-04-21 14:19 ` [PATCH v2 03/20] lib: move memmove() Jan Beulich
2021-04-21 14:19 ` [PATCH v2 04/20] lib: move memcmp() Jan Beulich
2021-04-21 14:20 ` [PATCH v2 05/20] lib: move memchr() Jan Beulich
2021-04-21 14:20 ` [PATCH v2 06/20] lib: move memchr_inv() Jan Beulich
2021-04-21 14:22 ` [PATCH v2 07/20] lib: move strlen() Jan Beulich
2021-04-21 14:22 ` [PATCH v2 08/20] lib: move strnlen() Jan Beulich
2021-04-21 14:22 ` [PATCH v2 09/20] lib: move strcmp() Jan Beulich
2021-04-21 14:23 ` [PATCH v2 10/20] lib: move strncmp() Jan Beulich
2021-04-21 14:23 ` [PATCH v2 11/20] lib: move strlcpy() Jan Beulich
2021-04-21 14:24 ` Jan Beulich [this message]
2021-04-21 14:24 ` [PATCH v2 13/20] lib: move strchr() Jan Beulich
2021-04-21 14:24 ` [PATCH v2 14/20] lib: move strrchr() Jan Beulich
2021-04-21 14:25 ` [PATCH v2 15/20] lib: move strstr() Jan Beulich
2021-04-21 14:25 ` [PATCH v2 16/20] lib: move strcasecmp() Jan Beulich
2021-04-21 14:25 ` [PATCH v2 17/20] lib: move/rename strnicmp() to strncasecmp() Jan Beulich
2021-04-21 19:20   ` Julien Grall
2021-04-21 14:26 ` [PATCH v2 18/20] lib: move strspn() Jan Beulich
2021-04-21 14:26 ` [PATCH v2 19/20] lib: move strpbrk() Jan Beulich
2021-04-21 14:26 ` [PATCH v2 20/20] lib: move strsep() Jan Beulich
2021-04-21 19:21 ` [PATCH v2 00/20] further population of xen/lib/ Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4b59a63-ab9a-33a8-df97-2262ced22a6f@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.