From 4aa2079a01a62ff27cbe90f5eca38137035d34a8 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 26 Mar 2009 09:20:16 -0700 Subject: PR10001: Use the kernel's strlcpy & strlcat We had our own implementations of these which were triggering gcc bug38480 in some particular cases. It's easier for us to use the kernel's strlcpy and strlcat anyway, which avoids the bug. --- runtime/map.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'runtime/map.c') diff --git a/runtime/map.c b/runtime/map.c index de25d6f3..190ba91b 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -38,27 +38,16 @@ static int int64_eq_p (int64_t key1, int64_t key2) static void str_copy(char *dest, char *src) { - int len = 0; - if (src) { - len = strlen(src); - if (len > MAP_STRING_LENGTH - 1) - len = MAP_STRING_LENGTH - 1; - memcpy (dest, src, len); - } - dest[len] = 0; + if (src) + strlcpy(dest, src, MAP_STRING_LENGTH); + else + *dest = 0; } static void str_add(void *dest, char *val) { char *dst = (char *)dest; - int len = strlen(val); - int len1 = strlen(dst); - int num = MAP_STRING_LENGTH - 1 - len1; - - if (len > num) - len = num; - memcpy (&dst[len1], val, len); - dst[len + len1] = 0; + strlcat(dst, val, MAP_STRING_LENGTH); } static int str_eq_p (char *key1, char *key2) -- cgit From 508e476d212146602499c9bf1283e15ee9f2f037 Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Wed, 13 May 2009 22:08:37 +0530 Subject: Initialize aptr in runtime/map.c and keep gcc-4.4 happy --- runtime/map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/map.c') diff --git a/runtime/map.c b/runtime/map.c index 190ba91b..74467f30 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -719,7 +719,7 @@ static MAP _stp_pmap_agg (PMAP pmap) { int i, hash; MAP m, agg; - struct map_node *ptr, *aptr; + struct map_node *ptr, *aptr = NULL; struct hlist_head *head, *ahead; struct hlist_node *e, *f; -- cgit