Re: [PATCH] http-backend: remove a duplicated code branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:

> diff --git a/http-backend.c b/http-backend.c
> index e7c0eeab230..13bc421b4e8 100644
> --- a/http-backend.c
> +++ b/http-backend.c
> @@ -462,19 +462,19 @@ static void run_service(const char **argv, int buffer_input)
>  	const char *encoding = getenv("HTTP_CONTENT_ENCODING");
>  	const char *user = getenv("REMOTE_USER");
>  	const char *host = getenv("REMOTE_ADDR");
> -	int gzipped_request = 0;
> +	int gzipped_request;
>  	struct child_process cld = CHILD_PROCESS_INIT;
>  	ssize_t req_len = get_content_length();
>  
> -	if (encoding && !strcmp(encoding, "gzip"))
> -		gzipped_request = 1;
> -	else if (encoding && !strcmp(encoding, "x-gzip"))
> -		gzipped_request = 1;
> -
>  	if (!user || !*user)
>  		user = "anonymous";
>  	if (!host || !*host)
>  		host = "(none)";
> +	if (!encoding)
> +		encoding = "";
> +
> +	gzipped_request = (!strcmp(encoding, "gzip") ||
> +			   !strcmp(encoding, "x-gzip"))

In general, I'd frown upon such a conversion.  In the the current
code, "encoding" might go dead after this point, but we are losing
information for no good reason by making !encoding and !*encoding
indistinguisable after this point.  Compared to that, the rewrite in
the patch that started this discussion would be more preferrable.

Thanks.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux