diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-07-14 13:52:58 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-07-14 13:53:22 +0200 |
commit | 5efa7d64818114bbef4896d3824425917b45e909 (patch) | |
tree | 166bb14196a233382b80570c746ae20cf3723fe0 /gl/tests | |
parent | 142eddc0b8eb696fcadedd9d9c6f387fafa560f8 (diff) | |
download | gnutls-5efa7d64818114bbef4896d3824425917b45e909.tar.gz |
updated gnulib
Diffstat (limited to 'gl/tests')
-rw-r--r-- | gl/tests/Makefile.am | 2 | ||||
-rw-r--r-- | gl/tests/getcwd-lgpl.c | 1 | ||||
-rw-r--r-- | gl/tests/ignore-value.h | 13 | ||||
-rw-r--r-- | gl/tests/malloca.c | 29 | ||||
-rw-r--r-- | gl/tests/test-getaddrinfo.c | 5 | ||||
-rw-r--r-- | gl/tests/test-snprintf.c | 2 | ||||
-rw-r--r-- | gl/tests/test-sys_socket.c | 2 | ||||
-rw-r--r-- | gl/tests/test-vasnprintf.c | 2 | ||||
-rw-r--r-- | gl/tests/test-vsnprintf.c | 2 |
9 files changed, 35 insertions, 23 deletions
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index 0b3462cbb8..5eeffe6c67 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -22,7 +22,7 @@ # # Generated by gnulib-tool. -AUTOMAKE_OPTIONS = 1.5 foreign subdir-objects +AUTOMAKE_OPTIONS = 1.9.6 foreign subdir-objects SUBDIRS = . TESTS = diff --git a/gl/tests/getcwd-lgpl.c b/gl/tests/getcwd-lgpl.c index d550f35c4e..cebe8f7b3d 100644 --- a/gl/tests/getcwd-lgpl.c +++ b/gl/tests/getcwd-lgpl.c @@ -20,6 +20,7 @@ #include <unistd.h> #include <errno.h> +#include <stdlib.h> #include <string.h> #if GNULIB_GETCWD diff --git a/gl/tests/ignore-value.h b/gl/tests/ignore-value.h index 63ecde8513..ebd6bf42f5 100644 --- a/gl/tests/ignore-value.h +++ b/gl/tests/ignore-value.h @@ -33,15 +33,16 @@ declared with attribute warn_unused_result". */ #ifndef _GL_IGNORE_VALUE_H -# define _GL_IGNORE_VALUE_H +#define _GL_IGNORE_VALUE_H /* The __attribute__((__warn_unused_result__)) feature is available in gcc versions 3.4 and newer, while the typeof feature has been available since 2.7 at least. */ -# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) -# define ignore_value(x) ((void) (x)) -# else -# define ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; })) -# endif +#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__) +# define ignore_value(x) \ + (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; })) +#else +# define ignore_value(x) ((void) (x)) +#endif #endif diff --git a/gl/tests/malloca.c b/gl/tests/malloca.c index 3cd2f6d99e..311be569bc 100644 --- a/gl/tests/malloca.c +++ b/gl/tests/malloca.c @@ -49,12 +49,18 @@ #define MAGIC_SIZE sizeof (int) /* This is how the header info would look like without any alignment considerations. */ -struct preliminary_header { void *next; char room[MAGIC_SIZE]; }; +struct preliminary_header { void *next; int magic; }; /* But the header's size must be a multiple of sa_alignment_max. */ #define HEADER_SIZE \ (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max) -struct header { void *next; char room[HEADER_SIZE - sizeof (struct preliminary_header) + MAGIC_SIZE]; }; -verify (HEADER_SIZE == sizeof (struct header)); +union header { + void *next; + struct { + char room[HEADER_SIZE - MAGIC_SIZE]; + int word; + } magic; +}; +verify (HEADER_SIZE == sizeof (union header)); /* We make the hash table quite big, so that during lookups the probability of empty hash buckets is quite high. There is no need to make the hash table resizable, because when the hash table gets filled so much that the @@ -74,20 +80,21 @@ mmalloca (size_t n) if (nplus >= n) { - char *p = (char *) malloc (nplus); + void *p = malloc (nplus); if (p != NULL) { size_t slot; + union header *h = p; - p += HEADER_SIZE; + p = h + 1; /* Put a magic number into the indicator word. */ - ((int *) p)[-1] = MAGIC_NUMBER; + h->magic.word = MAGIC_NUMBER; /* Enter p into the hash table. */ slot = (uintptr_t) p % HASH_TABLE_SIZE; - ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot]; + h->next = mmalloca_results[slot]; mmalloca_results[slot] = p; return p; @@ -123,15 +130,17 @@ freea (void *p) void **chain = &mmalloca_results[slot]; for (; *chain != NULL;) { + union header *h = p; if (*chain == p) { /* Found it. Remove it from the hash table and free it. */ - char *p_begin = (char *) p - HEADER_SIZE; - *chain = ((struct header *) p_begin)->next; + union header *p_begin = h - 1; + *chain = p_begin->next; free (p_begin); return; } - chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next; + h = *chain; + chain = &h[-1].next; } } /* At this point, we know it was not a mmalloca() result. */ diff --git a/gl/tests/test-getaddrinfo.c b/gl/tests/test-getaddrinfo.c index 1b9892f410..5c27d3bef8 100644 --- a/gl/tests/test-getaddrinfo.c +++ b/gl/tests/test-getaddrinfo.c @@ -114,6 +114,8 @@ simple (char const *host, char const *service) for (ai = ai0; ai; ai = ai->ai_next) { + void *ai_addr = ai->ai_addr; + struct sockaddr_in *sock_addr = ai_addr; dbgprintf ("\tflags %x\n", ai->ai_flags); dbgprintf ("\tfamily %x\n", ai->ai_family); dbgprintf ("\tsocktype %x\n", ai->ai_socktype); @@ -121,8 +123,7 @@ simple (char const *host, char const *service) dbgprintf ("\taddrlen %ld: ", (unsigned long) ai->ai_addrlen); dbgprintf ("\tFound %s\n", inet_ntop (ai->ai_family, - &((struct sockaddr_in *) - ai->ai_addr)->sin_addr, + &sock_addr->sin_addr, buf, sizeof (buf) - 1)); if (ai->ai_canonname) dbgprintf ("\tFound %s...\n", ai->ai_canonname); diff --git a/gl/tests/test-snprintf.c b/gl/tests/test-snprintf.c index 805735769e..108346e129 100644 --- a/gl/tests/test-snprintf.c +++ b/gl/tests/test-snprintf.c @@ -52,7 +52,7 @@ main (int argc, char *argv[]) #if !CHECK_SNPRINTF_POSIX if (size > 0) #endif - ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); } else { diff --git a/gl/tests/test-sys_socket.c b/gl/tests/test-sys_socket.c index 0ac8a33264..9084b18b6d 100644 --- a/gl/tests/test-sys_socket.c +++ b/gl/tests/test-sys_socket.c @@ -47,7 +47,7 @@ main (void) sa_family_t i; /* Check some errno values. */ - switch (0) + switch (ENOTSOCK) { case ENOTSOCK: case EADDRINUSE: diff --git a/gl/tests/test-vasnprintf.c b/gl/tests/test-vasnprintf.c index f29b05aeb5..4cce0a947a 100644 --- a/gl/tests/test-vasnprintf.c +++ b/gl/tests/test-vasnprintf.c @@ -55,7 +55,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) ASSERT (length == 5); if (size < 6) ASSERT (result != buf); - ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); if (result != buf) free (result); } diff --git a/gl/tests/test-vsnprintf.c b/gl/tests/test-vsnprintf.c index 3353b2eb47..84b5d89676 100644 --- a/gl/tests/test-vsnprintf.c +++ b/gl/tests/test-vsnprintf.c @@ -65,7 +65,7 @@ main (int argc, char *argv[]) #if !CHECK_VSNPRINTF_POSIX if (size > 0) #endif - ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); } else { |