Date: Mon, 29 Jun 2026 15:54:23 +0000 From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 4fd9dffb2514 - main - Revert "libc/resolv: Dead code and style cleanup" Message-ID: <6a42952f.3b734.756f7205@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4fd9dffb2514b1d62ce9618c87a9700606f12db3 commit 4fd9dffb2514b1d62ce9618c87a9700606f12db3 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-06-29 15:53:57 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-06-29 15:53:57 +0000 Revert "libc/resolv: Dead code and style cleanup" This reverts commit 5028a8489f54fcf0a96399059c14e28c6a69d159. --- lib/libc/resolv/res_init.c | 59 +++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c index 64522ef8f562..c7eda833f3d5 100644 --- a/lib/libc/resolv/res_init.c +++ b/lib/libc/resolv/res_init.c @@ -4,7 +4,7 @@ * Copyright (c) 1985, 1989, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 2026 Dag-Erling Smørgrav - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -32,14 +32,14 @@ /* * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. - * + * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT @@ -133,8 +133,9 @@ static int res_setsortlist(res_state, int, const char *, const char *); * Return 0 if completes successfully, -1 on error */ int -res_ninit(res_state statp) -{ +res_ninit(res_state statp) { + extern int __res_vinit(res_state, int); + return (__res_vinit(statp, 0)); } @@ -152,6 +153,7 @@ __res_vinit(res_state statp, int preinit) .sin_port = htons(NAMESERVER_PORT), .sin_addr = { htonl(INADDR_LOOPBACK) }, } }, +#ifdef HAS_INET6_STRUCTS { .sin6 = { .sin6_family = AF_INET6, #ifdef HAVE_SA_LEN @@ -160,6 +162,7 @@ __res_vinit(res_state statp, int preinit) .sin6_port = htons(NAMESERVER_PORT), .sin6_addr = IN6ADDR_LOOPBACK_INIT, } }, +#endif }; char *cp, **pp; int dots; @@ -187,7 +190,7 @@ __res_vinit(res_state statp, int preinit) statp->_u._ext.nscount = 0; statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext)); if (statp->_u._ext.ext != NULL) { - memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext)); + memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext)); statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr; strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa"); strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int"); @@ -826,8 +829,7 @@ freebsd15_res_rndinit(res_state statp) __sym_compat(__res_rndinit, freebsd15_res_rndinit, FBSD_1.4); u_int -res_nrandomid(res_state statp) -{ +res_nrandomid(res_state statp) { (void) statp; return ((u_int)(arc4random() & 0xffff)); @@ -841,11 +843,10 @@ res_nrandomid(res_state statp) * This routine is not expected to be user visible. */ void -res_nclose(res_state statp) -{ +res_nclose(res_state statp) { int ns; - if (statp->_vcsock >= 0) { + if (statp->_vcsock >= 0) { (void) _close(statp->_vcsock); statp->_vcsock = -1; statp->_flags &= ~(RES_F_VC | RES_F_CONN); @@ -859,8 +860,7 @@ res_nclose(res_state statp) } void -res_ndestroy(res_state statp) -{ +res_ndestroy(res_state statp) { res_nclose(statp); if (statp->_u._ext.ext != NULL) { free(statp->_u._ext.ext); @@ -869,6 +869,22 @@ res_ndestroy(res_state statp) statp->options &= ~RES_INIT; } +#ifndef _LIBC +const char * +res_get_nibblesuffix(res_state statp) { + if (statp->_u._ext.ext) + return (statp->_u._ext.ext->nsuffix); + return ("ip6.arpa"); +} + +const char * +res_get_nibblesuffix2(res_state statp) { + if (statp->_u._ext.ext) + return (statp->_u._ext.ext->nsuffix2); + return ("ip6.int"); +} +#endif + void res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) { @@ -896,6 +912,8 @@ res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) statp->nsaddr_list[nserv].sin_family = 0; nserv++; break; + +#ifdef HAS_INET6_STRUCTS case AF_INET6: size = sizeof(set->sin6); if (statp->_u._ext.ext) @@ -908,6 +926,8 @@ res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) statp->nsaddr_list[nserv].sin_family = 0; nserv++; break; +#endif + default: break; } @@ -917,8 +937,7 @@ res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) } int -res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) -{ +res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) { int i; size_t size; u_int16_t family; @@ -926,7 +945,7 @@ res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) for (i = 0; i < statp->nscount && i < cnt; i++) { if (statp->_u._ext.ext) family = statp->_u._ext.ext->nsaddrs[i].sin.sin_family; - else + else family = statp->nsaddr_list[i].sin_family; switch (family) { @@ -940,6 +959,8 @@ res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) memcpy(&set->sin, &statp->nsaddr_list[i], size); break; + +#ifdef HAS_INET6_STRUCTS case AF_INET6: size = sizeof(set->sin6); if (statp->_u._ext.ext) @@ -950,6 +971,8 @@ res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) memcpy(&set->sin6, &statp->nsaddr_list[i], size); break; +#endif + default: set->sin.sin_family = 0; break; @@ -958,3 +981,5 @@ res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) } return (statp->nscount); } + +/*! \file */home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a42952f.3b734.756f7205>
