[PATCH 2/5] Cygwin: resolver: Process options forward (not backwards)

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jan 18 10:32:49 GMT 2022


Hi Anton,

I pushed patches 1 and 3 to 5.  I fixed the consitency typo
throughout.

As for this path 2:

On Jan 17 13:03, Anton Lavrentiev via Cygwin-patches wrote:
> ---
>  winsup/cygwin/libc/minires.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/winsup/cygwin/libc/minires.c b/winsup/cygwin/libc/minires.c
> index 0cf9efd9b..fdc6087f5 100644
> --- a/winsup/cygwin/libc/minires.c
> +++ b/winsup/cygwin/libc/minires.c
> @@ -86,12 +86,12 @@ Read options
>  
>  
>  ***********************************************************************/
> -static void get_options(res_state statp, int i, char **words)
> +static void get_options(res_state statp, int n, char **words)
>  {
>    char *ptr;
> -  int value;
> +  int i, value;
>  
> -  while (i-- > 0) {
> +  for (i = 0;  i < n;  ++i) {
>      if (!strcasecmp("debug", words[i])) {
>        statp->options |= RES_DEBUG;
>        DPRINTF(statp->options & RES_DEBUG, "%s: 1\n", words[i]);
> @@ -208,8 +208,10 @@ static void get_resolv(res_state statp)
>  	}
>        }
>        /* Options line */
> -      else if (!strncasecmp("options", words[0], sizes[0]))
> +      else if (!strncasecmp("options", words[0], sizes[0])) {
>  	get_options(statp, i - 1, &words[1]);
> +	debug = statp->options & RES_DEBUG;

This addition setting the debug flag needs a bit of explaining in the
log message, me thinks.  Why was it necessary or why is it better to do
it here?

Right now, the debug flag gets set in several places throughout the
code.  Given you set the debug flag above, doesn't that mean several
code snippets setting the debug flag later in the code can go away?


Thanks,
Corinna


More information about the Cygwin-patches mailing list