Re: [PATCH v2 1/8] t0021/rot13-filter: fix list comparison

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

 



Christian Couder <christian.couder@xxxxxxxxx> writes:

> +sub packet_compare_lists {
> +	my ($expect, @result) = @_;
> +	my $ix;
> +	if (scalar @$expect != scalar @result) {
> +		return undef;
> +	}
> +	for ($ix = 0; $ix < $#result; $ix++) {
> +		if ($expect->[$ix] ne $result[$ix]) {
> +			return undef;
> +		}
> +	}
> +	return 1;
> +}
> +
>  sub packet_bin_read {
>  	my $buffer;
>  	my $bytes_read = read STDIN, $buffer, 4;
> @@ -110,18 +124,25 @@ sub packet_flush {
>  print $debug "START\n";
>  $debug->flush();
>  
> -( packet_txt_read() eq ( 0, "git-filter-client" ) ) || die "bad initialize";
> -( packet_txt_read() eq ( 0, "version=2" ) )         || die "bad version";
> -( packet_bin_read() eq ( 1, "" ) )                  || die "bad version end";
> +packet_compare_lists([0, "git-filter-client"], packet_txt_read()) ||
> +	die "bad initialize";

For now this should do, but the "packet_compare_lists" may later
want to become more specific to the needs of these callers.  It
tries to be a generic comparison function for list of strings, but
what these callers feed is always two-element tuple, whose first
element is an integer (not just a random thing that can be made into
a string to be compared with "ne") and whose second element is a
string.




[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