From patchwork Thu Nov 27 15:37:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: wizard X-Patchwork-Id: 3980 Received: (qmail 22738 invoked by alias); 27 Nov 2014 15:37:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 22728 invoked by uid 89); 27 Nov 2014 15:37:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL, BAYES_50 autolearn=ham version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Thu, 27 Nov 2014 16:37:40 +0100 To: Andreas Schwab Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2][BZ #14799] Allow to disable options in RES_OPTIONS Message-ID: <20141127153740.GA10402@domone> References: <20141126001713.GA27914@domone> <87a93eqns0.fsf@igel.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87a93eqns0.fsf@igel.home> rrom: =?utf-8?B?T25kxZllaiBCw61saw==?= =?utf-8?Q?a?= User-Agent: Mutt/1.5.20 (2009-06-14) From: wizard@domone (wizard) On Wed, Nov 26, 2014 at 11:06:23AM +0100, Andreas Schwab wrote: > Ondřej Bílka writes: > > > + int invert = 0; > > + if (strncmp (cp, "no-", 3)) > > + { > > + cp += 3; > > + invert = 1; > > + } > > + > > for (i = 0; i < noptions; ++i) > > if (strncmp (cp, options[i].str, options[i].len) == 0) > > { > > - if (options[i].clear) > > - statp->options &= options[i].flag; > > + if (options[i].clear ^ invert) > > + statp->options &= options[i].flag ^ invert; > > else > > - statp->options |= options[i].flag; > > + statp->options |= options[i].flag ^ invert; > > That doesn't work. > Oops, somewhat included older patch. I meant to send this. [BZ #14799] * resolv/res_init.c (res_setoptions): Detect no- prefix to disable option. diff --git a/resolv/res_init.c b/resolv/res_init.c index ea133f8..9ea43e9 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -533,26 +533,32 @@ res_setoptions(res_state statp, const char *options, const char *source) { #define STRnLEN(str) str, sizeof (str) - 1 { STRnLEN ("inet6"), 0, RES_USE_INET6 }, { STRnLEN ("ip6-bytestring"), 0, RES_USEBSTRING }, - { STRnLEN ("no-ip6-dotint"), 0, RES_NOIP6DOTINT }, { STRnLEN ("ip6-dotint"), 1, ~RES_NOIP6DOTINT }, { STRnLEN ("rotate"), 0, RES_ROTATE }, - { STRnLEN ("no-check-names"), 0, RES_NOCHECKNAME }, + { STRnLEN ("check-names"), 1, ~RES_NOCHECKNAME }, { STRnLEN ("edns0"), 0, RES_USE_EDNS0 }, { STRnLEN ("single-request-reopen"), 0, RES_SNGLKUPREOP }, { STRnLEN ("single-request"), 0, RES_SNGLKUP }, { STRnLEN ("no_tld_query"), 0, RES_NOTLDQUERY }, - { STRnLEN ("no-tld-query"), 0, RES_NOTLDQUERY }, + { STRnLEN ("tld-query"), 1, ~RES_NOTLDQUERY }, { STRnLEN ("use-vc"), 0, RES_USEVC } }; #define noptions (sizeof (options) / sizeof (options[0])) int i; + unsigned long int invert = 0; + if (strncmp (cp, "no-", 3) == 0) + { + cp += 3; + invert = ~0; + } + for (i = 0; i < noptions; ++i) if (strncmp (cp, options[i].str, options[i].len) == 0) { - if (options[i].clear) - statp->options &= options[i].flag; + if (options[i].clear ^ invert) + statp->options &= options[i].flag ^ invert; else - statp->options |= options[i].flag; + statp->options |= options[i].flag ^ invert; break; } if (i == noptions) {