From 9efc8b95af3b3e832d7d3660119c3d487d40d16e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 23 Aug 2001 08:36:47 +0000 Subject: * libio/tst-ungetwc1.c (main): Add a const to quiet a warning. * nss/test-netdb.c (test_hosts): Don't use MAXHOSTNAMELEN. Instead, use dynamic buffer to test gethostname's ENAMETOOLONG error. --- ChangeLog | 7 +++++++ libio/tst-ungetwc1.c | 2 +- nss/test-netdb.c | 12 +++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67bfc323ad..11ccb9634c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-08-23 Roland McGrath + + * libio/tst-ungetwc1.c (main): Add a const to quiet a warning. + + * nss/test-netdb.c (test_hosts): Don't use MAXHOSTNAMELEN. + Instead, use dynamic buffer to test gethostname's ENAMETOOLONG error. + 2001-08-22 Roland McGrath * sysdeps/generic/ldsodefs.h (_dl_load_lock): Declare it here with diff --git a/libio/tst-ungetwc1.c b/libio/tst-ungetwc1.c index eeee7f699b..f74c407893 100644 --- a/libio/tst-ungetwc1.c +++ b/libio/tst-ungetwc1.c @@ -11,7 +11,7 @@ int main (void) { FILE *fp; - char *str ="abcdef"; + const char *str = "abcdef"; wint_t ret, wc, ungetone = 0x00E4; /* 0x00E4 means `a umlaut'. */ char fname[] = "/tmp/tst-ungetwc1.out.XXXXXX"; int fd; diff --git a/nss/test-netdb.c b/nss/test-netdb.c index f52724039d..8ae6d12fc0 100644 --- a/nss/test-netdb.c +++ b/nss/test-netdb.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998,99,2000,01 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1998. @@ -40,6 +40,7 @@ #include #include #include +#include #include "nss.h" /* @@ -138,8 +139,8 @@ static void test_hosts (void) { struct hostent *hptr1, *hptr2; - char name[MAXHOSTNAMELEN]; - size_t namelen = sizeof(name); + char *name = NULL; + size_t namelen = 0; struct in_addr ip; hptr1 = gethostbyname ("localhost"); @@ -176,6 +177,11 @@ test_hosts (void) hptr1 = gethostbyname2 ("localhost", AF_INET); output_hostent ("gethostbyname2 (\"localhost\", AF_INET)", hptr1); + while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG) + { + namelen += 2; /* tiny increments to test a lot */ + name = realloc (name, namelen); + } if (gethostname (name, namelen) == 0) { printf ("Hostname: %s\n", name); -- cgit v1.2.3