[PULL v2] string handling, unit test & Solaris fixes

Keith Packard keithp at keithp.com
Sun Nov 20 13:01:04 PST 2011


On Tue, 08 Nov 2011 19:47:13 -0800, Alan Coopersmith <alan.coopersmith at oracle.com> wrote:

>        Add fallback implementation of strndup()

The test code doesn't build on Linux. Here's a patch which seems to
help -- you can't use the 'strndup' name with glibc; it's got magic for
that these days...

diff --git a/test/string.c b/test/string.c
index 42a5e9c..e3a5adb 100644
--- a/test/string.c
+++ b/test/string.c
@@ -34,12 +34,18 @@
 #include "os.h"
 
 /* Ensure we're testing our functions, even on platforms with libc versions */
+#include <string.h>
+#undef strndup
+#define strndup my_strndup
+char *
+strndup(const char *str, size_t n);
+
 #include "../os/strndup.c"
 
 static void strndup_checks(void)
 {
-    int rc;
     const char *sample="0123456789abcdef";
+    char *allofit;
 
     char *firsthalf = strndup(sample, 8);
     char *secondhalf = strndup(sample + 8, 8);
@@ -50,7 +56,7 @@ static void strndup_checks(void)
     free(firsthalf);
     free(secondhalf);
 
-    char *allofit = strndup(sample, 20);
+    allofit = strndup(sample, 20);
     assert(strcmp(allofit, sample) == 0);
     free(allofit);
 }


>        Convert strncpy/strncat to strlcpy/strlcat

This breaks the DMX build; I tried to fix this and failed...

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111120/9c2098f7/attachment.pgp>


More information about the xorg-devel mailing list