svn commit: r319042 - head/lib/libc/tests/nss
Ngie Cooper
ngie at FreeBSD.org
Sun May 28 04:34:58 UTC 2017
Author: ngie
Date: Sun May 28 04:34:57 2017
New Revision: 319042
URL: https://svnweb.freebsd.org/changeset/base/319042
Log:
gethostby_test: fix multiple warning types
- Fix -Wmissing-declaration warning by staticizing run_tests.
- Fix -Wsign-compare warnings by casting size_t types to int
for comparisons.
Reindent some of the code in sdump_hostent(..) to accomodate the
overall changes.
MFC after: 3 days
Sponsored by: Dell EMC Isilon
Modified:
head/lib/libc/tests/nss/gethostby_test.c
Modified: head/lib/libc/tests/nss/gethostby_test.c
==============================================================================
--- head/lib/libc/tests/nss/gethostby_test.c Sun May 28 04:15:57 2017 (r319041)
+++ head/lib/libc/tests/nss/gethostby_test.c Sun May 28 04:34:57 2017 (r319042)
@@ -412,7 +412,7 @@ sdump_hostent(struct hostent *ht, char *
written = snprintf(buffer, buflen, "%s %d %d",
ht->h_name, ht->h_addrtype, ht->h_length);
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
@@ -421,7 +421,7 @@ sdump_hostent(struct hostent *ht, char *
for (cp = ht->h_aliases; *cp; ++cp) {
written = snprintf(buffer, buflen, " %s",*cp);
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
@@ -431,59 +431,61 @@ sdump_hostent(struct hostent *ht, char *
} else {
written = snprintf(buffer, buflen, " noaliases");
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
}
} else {
written = snprintf(buffer, buflen, " (null)");
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
}
written = snprintf(buffer, buflen, " : ");
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
if (ht->h_addr_list != NULL) {
if (*(ht->h_addr_list) != NULL) {
for (cp = ht->h_addr_list; *cp; ++cp) {
- for (i = 0; i < ht->h_length; ++i ) {
- written = snprintf(buffer, buflen,
- i + 1 != ht->h_length ? "%d." : "%d",
- (unsigned char)(*cp)[i]);
- buffer += written;
- if (written > buflen)
- return;
- buflen -= written;
+ for (i = 0; i < (size_t)ht->h_length; ++i) {
+ written = snprintf(buffer, buflen,
+ i + 1 != (size_t)ht->h_length ?
+ "%d." : "%d",
+ (unsigned char)(*cp)[i]);
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
- if (buflen == 0)
- return;
- }
+ if (buflen == 0)
+ return;
+ }
- if (*(cp + 1) ) {
- written = snprintf(buffer, buflen, " ");
- buffer += written;
- if (written > buflen)
- return;
- buflen -= written;
- }
+ if (*(cp + 1)) {
+ written = snprintf(buffer, buflen,
+ " ");
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
+ }
}
} else {
written = snprintf(buffer, buflen, " noaddrs");
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
}
} else {
written = snprintf(buffer, buflen, " (null)");
buffer += written;
- if (written > buflen)
+ if (written > (int)buflen)
return;
buflen -= written;
}
@@ -920,7 +922,7 @@ hostent_test_getnameinfo_eq(struct hoste
return (0);
}
-int
+static int
run_tests(const char *hostlist_file, const char *snapshot_file, int af_type,
enum test_methods method, bool use_ipv6_mapping)
{
More information about the svn-src-head
mailing list