[tip:tools/kvm] kvm tools: move strlcat() to util/strbuf.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  eb6be0aa3c1e0c1a3d01e8a0112f21607dab87cc
Gitweb:     http://git.kernel.org/tip/eb6be0aa3c1e0c1a3d01e8a0112f21607dab87cc
Author:     Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
AuthorDate: Mon, 12 Dec 2011 15:15:52 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Mon, 12 Dec 2011 23:35:36 +0200

kvm tools: move strlcat() to util/strbuf.c

strlcat() is a string related function.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-run.c        |    1 +
 tools/kvm/include/kvm/strbuf.h |   13 +++++++++++++
 tools/kvm/include/kvm/util.h   |   10 ----------
 tools/kvm/util/strbuf.c        |   26 ++++++++++++++++++++++++++
 tools/kvm/util/util.c          |   25 -------------------------
 5 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 5045278..35245ff 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -21,6 +21,7 @@
 #include "kvm/mutex.h"
 #include "kvm/term.h"
 #include "kvm/util.h"
+#include "kvm/strbuf.h"
 #include "kvm/vesa.h"
 #include "kvm/irq.h"
 #include "kvm/kvm.h"
diff --git a/tools/kvm/include/kvm/strbuf.h b/tools/kvm/include/kvm/strbuf.h
index e67ca20..8fdef7e 100644
--- a/tools/kvm/include/kvm/strbuf.h
+++ b/tools/kvm/include/kvm/strbuf.h
@@ -1,6 +1,19 @@
 #ifndef __STRBUF_H__
 #define __STRBUF_H__
 
+#include <sys/types.h>
+#include <string.h>
+
 int prefixcmp(const char *str, const char *prefix);
 
+extern size_t strlcat(char *dest, const char *src, size_t count);
+
+/* some inline functions */
+
+static inline const char *skip_prefix(const char *str, const char *prefix)
+{
+	size_t len = strlen(prefix);
+	return strncmp(str, prefix, len) ? NULL : str + len;
+}
+
 #endif
diff --git a/tools/kvm/include/kvm/util.h b/tools/kvm/include/kvm/util.h
index dc2e0b9..3e382fc 100644
--- a/tools/kvm/include/kvm/util.h
+++ b/tools/kvm/include/kvm/util.h
@@ -58,16 +58,6 @@ do {								\
 		__stringify(cnd) "\n");				\
 } while (0)
 
-extern size_t strlcat(char *dest, const char *src, size_t count);
-
-/* some inline functions */
-
-static inline const char *skip_prefix(const char *str, const char *prefix)
-{
-	size_t len = strlen(prefix);
-	return strncmp(str, prefix, len) ? NULL : str + len;
-}
-
 #define MSECS_TO_USECS(s) ((s) * 1000)
 
 /* Millisecond sleep */
diff --git a/tools/kvm/util/strbuf.c b/tools/kvm/util/strbuf.c
index ec77ab1..6632a14 100644
--- a/tools/kvm/util/strbuf.c
+++ b/tools/kvm/util/strbuf.c
@@ -1,5 +1,6 @@
 
 /* user defined headers */
+#include <kvm/util.h>
 #include <kvm/strbuf.h>
 
 int prefixcmp(const char *str, const char *prefix)
@@ -11,3 +12,28 @@ int prefixcmp(const char *str, const char *prefix)
 			return (unsigned char)*prefix - (unsigned char)*str;
 	}
 }
+
+/**
+ * strlcat - Append a length-limited, %NUL-terminated string to another
+ * @dest: The string to be appended to
+ * @src: The string to append to it
+ * @count: The size of the destination buffer.
+ */
+size_t strlcat(char *dest, const char *src, size_t count)
+{
+	size_t dsize = strlen(dest);
+	size_t len = strlen(src);
+	size_t res = dsize + len;
+
+	DIE_IF(dsize >= count);
+
+	dest += dsize;
+	count -= dsize;
+	if (len >= count)
+		len = count - 1;
+
+	memcpy(dest, src, len);
+	dest[len] = 0;
+
+	return res;
+}
diff --git a/tools/kvm/util/util.c b/tools/kvm/util/util.c
index 4efbce9..682ed6c 100644
--- a/tools/kvm/util/util.c
+++ b/tools/kvm/util/util.c
@@ -74,28 +74,3 @@ void die_perror(const char *s)
 	perror(s);
 	exit(1);
 }
-
-/**
- * strlcat - Append a length-limited, %NUL-terminated string to another
- * @dest: The string to be appended to
- * @src: The string to append to it
- * @count: The size of the destination buffer.
- */
-size_t strlcat(char *dest, const char *src, size_t count)
-{
-	size_t dsize = strlen(dest);
-	size_t len = strlen(src);
-	size_t res = dsize + len;
-
-	DIE_IF(dsize >= count);
-
-	dest += dsize;
-	count -= dsize;
-	if (len >= count)
-		len = count - 1;
-
-	memcpy(dest, src, len);
-	dest[len] = 0;
-
-	return res;
-}
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux