Re: [PATCHv2 1/2] git apply: option to ignore whitespace differences

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

 



[Sorry for the late reply to this; I've been catching up on
email after several days away - so if this has already been
addressed, just ignore and sorry for the noise!]

Giuseppe Bilotta wrote:
[snip]
> + * Compare s1 to s2 up to length n, ignoring whitespace differences.
> + * It is acceptable if s2 is a substring of s1.
> + */
> +static int memcmp_ignore_whitespace(const char *s1, const char *s2, size_t n)
> +{
> +	const char *stop = s2 + n;
> +	int result;

result is uninitialized here...

> +
> +	if (!n)
> +		return 0;
> +
> +	/* skip leading whitespace */
> +	while (isspace(*s1))
> +		s1++;
> +	while (isspace(*s2))
> +		s2++;
> +	while (!result && s2 < stop) {

... and is still uninitialized the first time it hits
the loop condition...

> +		result = *s1++ - *s2++;

... so this may or may not be set...

> +		/*
> +		 * skip whitespace inside if we have whitespace
> +		 * on both buffers
> +		 */
> +		if (isspace(*s1) && isspace(*s2)) {
> +			while (isspace(*s1))
> +				s1++;
> +			while (isspace(*s2))
> +				s2++;
> +		}
> +	}
> +
> +	return result;

... so this may still be uninitialized.
> +}
> +

I haven't been following this thread; I just noticed this problem
as the patch floated past...

ATB,
Ramsay Jones



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]