[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [Issue 1952] Const-ify some API parameters.

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Thu, 10 Jul 2008 18:46:24 +0100

On Thu, 2008-07-10 at 17:08 +0000, bhuvan_at_tigris.org wrote:
> http://subversion.tigris.org/issues/show_bug.cgi?id=1952

> ------- Additional comments from bhuvan_at_tigris.org Thu Jul 10 10:08:06 -0700 2008 -------
> Please find attached the patch for review. Pre-commit log message:
>
> Fix for issue 1952. Make the read-only variables visible by changing it
> to const pointer.
>
> * subversion/include/svn_repos.h
> (svn_repos_trace_node_locations): Mark location_revisions as const
> pointer.

This might be safe. Can you search the mailing lists or somewhere and
see if we decided on a previous occasion that adding "const" to a
pointer in the public API was or was not permissible?

  
> * subversion/include/svn_client.h
> (svn_client_get_commit_log_t): Mark commit_items as const pointer.

This type was deprecated after v1.2 and the replacement does not have
this problem.

We should not change this type, as this will lead to pointer type mismatches in any code that may be using it. I'm not sure if this would be an error on any systems; my version of GCC just gives a warning. (To get this warning, I had to write some code to use this type, because there isn't any code using it in Subversion.)

My test code:
[[[
/* This is an example of some third-party's old source code. */
static svn_error_t *myfunc
  (const char **log_msg,
   const char **tmp_file,
   apr_array_header_t *commit_items, /* This line has no "const". */
   void *baton,
   apr_pool_t *pool)
{
  return SVN_NO_ERROR;
}

static void test(void)
{
  svn_client_ctx_t *p;

  p->log_msg_func = myfunc; /* I get a warning here */
}
]]]

On the assignment, I get "warning: assignment from incompatible pointer
type".

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-07-10 19:47:16 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.