git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Jul 5, 2009, 23:21 UTC
Message-ID
<4A513560.5040001@ramsay1.demon.co.uk>
In-Reply-To
<1246708429-21823-2-git-send-email-giuseppe.bilotta@gmail.com>

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

Show 7 quoted lines
> + * 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...
Show 10 quoted lines
> +
> +	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...
Show 13 quoted lines
> +		/*
> +		 * 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

Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 3 of 4 in “[PATCHv2 0/2] git apply: cope with whitespace differences”
  1. Giuseppe BilottaJul 4, 2009
  2. 1/2 git apply: option to ignore whitespace differencesGiuseppe Bilotta, Jul 4, 2009
  3. Ramsay JonesJul 5, 2009
  4. 2/2 git apply: preserve original whitespace with --ignore-whitespaceGiuseppe Bilotta, Jul 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.