subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Martin <philip.mar...@wandisco.com>
Subject Re: [PATCH] svn --version --verbose += /etc/os-release
Date Tue, 27 Jan 2015 11:28:35 GMT
Daniel Shahaf <d.s@daniel.shahaf.name> writes:

> +static const char *
> +systemd_release(apr_pool_t *pool)
> +{
> +  svn_error_t *err;
> +  svn_stream_t *stream;
> +
> +  err = svn_stream_open_readonly(&stream, "/etc/os-release", pool, pool);
> +  if (err && APR_STATUS_IS_ENOENT(err->apr_err))
> +    {
> +      svn_error_clear(err);
> +      err = svn_stream_open_readonly(&stream, "/usr/lib/os-release", pool,
> +                                     pool);
> +    }
> +  if (err)
> +    {
> +      svn_error_clear(err);
> +      return NULL;
> +    }
> +
> +  while (TRUE)
> +    {
> +      svn_stringbuf_t *line;
> +      svn_boolean_t eof;
> +
> +      err = svn_stream_readline(stream, &line, "\n", &eof, pool);
> +      if (err)
> +        {
> +          svn_error_clear(err);
> +          return NULL;
> +        }
> +
> +      if (!strncmp(line->data, "PRETTY_NAME=", 12))
> +        return remove_shell_quoting(line, 12, pool);

The file below the stream is still open and will remain open until the
pool is cleared and that also clears the result.  scratch/result pools
would allow the caller to close the stream and keep the result.  It
might be better to arrange for this function to close the stream,
perhaps just assume the file is small and read it all into memory.

> +
> +      if (eof)
> +        break;
> +    }
> +
> +  return NULL;
> +}
> +

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*

Mime
View raw message