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

Re: Infinite loop in cascade_filter_fn()

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 26, 2011, 22:48 UTC
Message-ID
<7vy5v2wleb.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20111125170219.GD10417@beez.lab.cmartin.tk>
Carlos Martín Nieto <cmn@elego.de> writes:
Show 11 quoted lines
> diff --git a/convert.c b/convert.c
> index 86e9c29..c050b86 100644
> --- a/convert.c
> +++ b/convert.c
> @@ -880,20 +880,29 @@ static int lf_to_crlf_filter_fn(struct stream_filter *filter,
>  				const char *input, size_t *isize_p,
>  				char *output, size_t *osize_p)
>  {
> -	size_t count;
> +	size_t count, o = 0;
> +	static int want_lf = 0;

I do not think we want function scope static state anywhere in the cascade filter chain, as it will forbid us from running more than one output chain at the same time in the future. I think the correct way to structure it would be to create lf_to_crlf_filter as a proper subclass of stream_filter (see how cascade_filter_fn() casts its filter argument down to an instance of the cascade_filter class and uses it to keep track of its state) and keep this variable as its own filter state [*1*].

[Footnote]

*1* We currently use a singleton instance of lf_to_crlf_filter object because the implementation assumed there is no need for per-instance state.

Previous: Carlos Martín NietoNext: Carlos Martín Nieto
Message 6 of 16 in “Infinite loop in cascade_filter_fn()”
  1. Henrik GrubbströmNov 23, 2011
  2. Carlos Martín NietoNov 25, 2011
  3. Carlos Martín NietoNov 25, 2011
  4. Henrik GrubbströmNov 25, 2011
  5. Carlos Martín NietoNov 25, 2011
  6. Junio C HamanoNov 26, 2011
  7. Carlos Martín NietoNov 28, 2011
  8. Junio C HamanoNov 28, 2011
  9. Junio C HamanoDec 16, 2011
  10. lf_to_crlf_filter(): tell the caller we added "\n" when drainingJunio C Hamano, Dec 16, 2011
  11. Henrik GrubbströmDec 19, 2011
  12. Junio C HamanoDec 19, 2011
  13. Carlos Martín NietoDec 19, 2011
  14. Henrik GrubbströmNov 25, 2011
  15. Carlos Martín NietoNov 25, 2011
  16. Henrik GrubbströmNov 25, 2011

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.