aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-07-01 18:24:44 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-07-01 18:24:44 +0000
commitd43277c534904dc31d14bfb0dc934f3cfbe2dab5 (patch)
tree272f8131c34141ffc369fbd40e369a02172584e6
parent57a943c41fd8ae23647f34b4b2ff7707561eebe8 (diff)
downloadqemu-d43277c534904dc31d14bfb0dc934f3cfbe2dab5.zip
qemu-d43277c534904dc31d14bfb0dc934f3cfbe2dab5.tar.gz
qemu-d43277c534904dc31d14bfb0dc934f3cfbe2dab5.tar.bz2
Fix missing strnlen problems
Fix missing strnlen (a GNU extension) problems by using qemu_strnlen used for user emulators also for system emulators. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--block.c2
-rw-r--r--bsd-user/uaccess.c11
-rw-r--r--cutils.c13
-rw-r--r--linux-user/uaccess.c11
-rw-r--r--qemu-common.h1
5 files changed, 15 insertions, 23 deletions
diff --git a/block.c b/block.c
index 3fe9317..c7589b1 100644
--- a/block.c
+++ b/block.c
@@ -225,7 +225,7 @@ static BlockDriver *find_protocol(const char *filename)
{
BlockDriver *drv1;
char protocol[128];
- int len = strnlen(filename, 127)+1;
+ int len = qemu_strnlen(filename, 127) + 1;
const char *p;
#ifdef _WIN32
diff --git a/bsd-user/uaccess.c b/bsd-user/uaccess.c
index cc51449..9ec1b23 100644
--- a/bsd-user/uaccess.c
+++ b/bsd-user/uaccess.c
@@ -37,17 +37,6 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len)
return ret;
}
-/* XXX: use host strnlen if available ? */
-static int qemu_strnlen(const char *s, int max_len)
-{
- int i;
- for(i = 0; i < max_len; i++) {
- if (s[i] == '\0')
- break;
- }
- return i;
-}
-
/* Return the length of a string in target memory or -TARGET_EFAULT if
access error */
abi_long target_strlen(abi_ulong guest_addr1)
diff --git a/cutils.c b/cutils.c
index 73d4e1f..6196a90 100644
--- a/cutils.c
+++ b/cutils.c
@@ -109,6 +109,19 @@ int stristart(const char *str, const char *val, const char **ptr)
return 1;
}
+/* XXX: use host strnlen if available ? */
+int qemu_strnlen(const char *s, int max_len)
+{
+ int i;
+
+ for(i = 0; i < max_len; i++) {
+ if (s[i] == '\0') {
+ break;
+ }
+ }
+ return i;
+}
+
time_t mktimegm(struct tm *tm)
{
time_t t;
diff --git a/linux-user/uaccess.c b/linux-user/uaccess.c
index 4d50693..a4d108c 100644
--- a/linux-user/uaccess.c
+++ b/linux-user/uaccess.c
@@ -37,17 +37,6 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len)
return ret;
}
-/* XXX: use host strnlen if available ? */
-static int qemu_strnlen(const char *s, int max_len)
-{
- int i;
- for(i = 0; i < max_len; i++) {
- if (s[i] == '\0')
- break;
- }
- return i;
-}
-
/* Return the length of a string in target memory or -TARGET_EFAULT if
access error */
abi_long target_strlen(abi_ulong guest_addr1)
diff --git a/qemu-common.h b/qemu-common.h
index 5b8ac77..a5d8fff 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -109,6 +109,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
+int qemu_strnlen(const char *s, int max_len);
time_t mktimegm(struct tm *tm);
int qemu_fls(int i);