subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1657254 - in /subversion/trunk/subversion: include/ libsvn_client/ libsvn_fs_base/ libsvn_ra_serf/ libsvn_repos/ libsvn_subr/ libsvn_wc/ svnrdump/
Date Wed, 04 Feb 2015 14:32:26 GMT
Author: stefan2
Date: Wed Feb  4 14:32:25 2015
New Revision: 1657254

URL: http://svn.apache.org/r1657254
Log:
Make svn_string_dup() more comfortable to use.  Allow the input string
to be NULL and return NULL for the copy in that case.

Right now, it will segfault for NULL pointers and virtually all callers
check for NULL before calling and emulate the improved logic.

So, this change will not break any legal API user code but save us lots
of duplicated logic.

* subversion/include/svn_string.h
  (svn_string_dup): Update docstring.

* subversion/libsvn_subr/string.c
  (svn_string_dup): Return NULL as copy for NULL inputs.

* subversion/libsvn_client/mtcc.c
  (mtcc_prop_getter): Simplify caller.

* subversion/libsvn_client/repos_diff.c
  (change_file_prop,
   change_dir_prop): Same.

* subversion/libsvn_fs_base/tree.c
  (base_node_prop): Same.

* subversion/libsvn_ra_serf/commit.c
  (change_dir_prop, 
   change_file_prop): Same.

* subversion/libsvn_repos/reporter.c
  (get_revision_info): Same.

* subversion/libsvn_wc/diff_editor.c
  (change_file_prop,
   change_dir_prop): Same.

* subversion/libsvn_wc/externals.c
  (change_file_prop): Same.

* subversion/libsvn_wc/props.c
  (svn_wc__merge_props): Same.

* subversion/libsvn_wc/update_editor.c
  (change_dir_prop,
   change_file_prop): Same.

* subversion/svnrdump/load_editor.c
  (set_node_property): Same.

Modified:
    subversion/trunk/subversion/include/svn_string.h
    subversion/trunk/subversion/libsvn_client/mtcc.c
    subversion/trunk/subversion/libsvn_client/repos_diff.c
    subversion/trunk/subversion/libsvn_fs_base/tree.c
    subversion/trunk/subversion/libsvn_ra_serf/commit.c
    subversion/trunk/subversion/libsvn_repos/reporter.c
    subversion/trunk/subversion/libsvn_subr/string.c
    subversion/trunk/subversion/libsvn_wc/diff_editor.c
    subversion/trunk/subversion/libsvn_wc/externals.c
    subversion/trunk/subversion/libsvn_wc/props.c
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/svnrdump/load_editor.c

Modified: subversion/trunk/subversion/include/svn_string.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_string.h?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_string.h (original)
+++ subversion/trunk/subversion/include/svn_string.h Wed Feb  4 14:32:25 2015
@@ -170,7 +170,11 @@ svn_string_createv(apr_pool_t *pool, con
 svn_boolean_t
 svn_string_isempty(const svn_string_t *str);
 
-/** Return a duplicate of @a original_string. */
+/** Return a duplicate of @a original_string.
+ *
+ * @since Since 1.9, @a original_string can be NULL in which case NULL will
+ * be returned.
+ */
 svn_string_t *
 svn_string_dup(const svn_string_t *original_string, apr_pool_t *pool);
 

Modified: subversion/trunk/subversion/libsvn_client/mtcc.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mtcc.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mtcc.c (original)
+++ subversion/trunk/subversion/libsvn_client/mtcc.c Wed Feb  4 14:32:25 2015
@@ -710,8 +710,7 @@ mtcc_prop_getter(const svn_string_t **mi
 
               if (! strcmp(mod->name, SVN_PROP_MIME_TYPE))
                 {
-                  *mime_type = mod->value ? svn_string_dup(mod->value, pool)
-                                          : NULL;
+                  *mime_type = svn_string_dup(mod->value, pool);
                   mime_type = NULL;
                 }
             }

Modified: subversion/trunk/subversion/libsvn_client/repos_diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/repos_diff.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/repos_diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/repos_diff.c Wed Feb  4 14:32:25 2015
@@ -1162,7 +1162,7 @@ change_file_prop(void *file_baton,
 
   propchange = apr_array_push(fb->propchanges);
   propchange->name = apr_pstrdup(fb->pool, name);
-  propchange->value = value ? svn_string_dup(value, fb->pool) : NULL;
+  propchange->value = svn_string_dup(value, fb->pool);
 
   return SVN_NO_ERROR;
 }
@@ -1192,7 +1192,7 @@ change_dir_prop(void *dir_baton,
 
   propchange = apr_array_push(db->propchanges);
   propchange->name = apr_pstrdup(db->pool, name);
-  propchange->value = value ? svn_string_dup(value, db->pool) : NULL;
+  propchange->value = svn_string_dup(value, db->pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_fs_base/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/tree.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/tree.c Wed Feb  4 14:32:25 2015
@@ -1237,7 +1237,7 @@ base_node_prop(svn_string_t **value_p,
   args.propname = propname;
   SVN_ERR(svn_fs_base__retry_txn(root->fs, txn_body_node_prop, &args,
                                  FALSE, scratch_pool));
-  *value_p = value ? svn_string_dup(value, pool) : NULL;
+  *value_p = svn_string_dup(value, pool);
   svn_pool_destroy(scratch_pool);
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Wed Feb  4 14:32:25 2015
@@ -1609,7 +1609,7 @@ change_dir_prop(void *dir_baton,
   prop = apr_palloc(dir->pool, sizeof(*prop));
 
   prop->name = apr_pstrdup(dir->pool, name);
-  prop->value = value ? svn_string_dup(value, dir->pool) : NULL;
+  prop->value = svn_string_dup(value, dir->pool);
 
   svn_hash_sets(dir->prop_changes, prop->name, prop);
 
@@ -1879,7 +1879,7 @@ change_file_prop(void *file_baton,
   prop = apr_palloc(file->pool, sizeof(*prop));
 
   prop->name = apr_pstrdup(file->pool, name);
-  prop->value = value ? svn_string_dup(value, file->pool) : NULL;
+  prop->value = svn_string_dup(value, file->pool);
 
   svn_hash_sets(file->prop_changes, prop->name, prop);
 

Modified: subversion/trunk/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/reporter.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/reporter.c (original)
+++ subversion/trunk/subversion/libsvn_repos/reporter.c Wed Feb  4 14:32:25 2015
@@ -495,8 +495,8 @@ get_revision_info(report_baton_t *b,
       /* Create a result object */
       info = apr_palloc(b->pool, sizeof(*info));
       info->rev = rev;
-      info->date = cdate ? svn_string_dup(cdate, b->pool) : NULL;
-      info->author = author ? svn_string_dup(author, b->pool) : NULL;
+      info->date = svn_string_dup(cdate, b->pool);
+      info->author = svn_string_dup(author, b->pool);
 
       /* Cache it */
       apr_hash_set(b->revision_infos, &info->rev, sizeof(info->rev), info);

Modified: subversion/trunk/subversion/libsvn_subr/string.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/string.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/string.c (original)
+++ subversion/trunk/subversion/libsvn_subr/string.c Wed Feb  4 14:32:25 2015
@@ -301,8 +301,9 @@ svn_string_isempty(const svn_string_t *s
 svn_string_t *
 svn_string_dup(const svn_string_t *original_string, apr_pool_t *pool)
 {
-  return (svn_string_ncreate(original_string->data,
-                             original_string->len, pool));
+  return (original_string ? svn_string_ncreate(original_string->data,
+                                               original_string->len, pool)
+                          : NULL);
 }
 
 

Modified: subversion/trunk/subversion/libsvn_wc/diff_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff_editor.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff_editor.c Wed Feb  4 14:32:25 2015
@@ -2192,7 +2192,7 @@ change_file_prop(void *file_baton,
 
   propchange = apr_array_push(fb->propchanges);
   propchange->name = apr_pstrdup(fb->pool, name);
-  propchange->value = value ? svn_string_dup(value, fb->pool) : NULL;
+  propchange->value = svn_string_dup(value, fb->pool);
 
   return SVN_NO_ERROR;
 }
@@ -2217,7 +2217,7 @@ change_dir_prop(void *dir_baton,
 
   propchange = apr_array_push(db->propchanges);
   propchange->name = apr_pstrdup(db->pool, name);
-  propchange->value = value ? svn_string_dup(value, db->pool) : NULL;
+  propchange->value = svn_string_dup(value, db->pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/externals.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/externals.c (original)
+++ subversion/trunk/subversion/libsvn_wc/externals.c Wed Feb  4 14:32:25 2015
@@ -602,7 +602,7 @@ change_file_prop(void *file_baton,
 
   propchange = apr_array_push(eb->propchanges);
   propchange->name = apr_pstrdup(eb->pool, name);
-  propchange->value = value ? svn_string_dup(value, eb->pool) : NULL;
+  propchange->value = svn_string_dup(value, eb->pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Wed Feb  4 14:32:25 2015
@@ -1272,7 +1272,7 @@ svn_wc__merge_props(svn_skel_t **conflic
 
       svn_pool_clear(iterpool);
 
-      to_val = to_val ? svn_string_dup(to_val, result_pool) : NULL;
+      to_val = svn_string_dup(to_val, result_pool);
 
       svn_hash_sets(their_props, propname, to_val);
 

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Wed Feb  4 14:32:25 2015
@@ -2489,7 +2489,7 @@ change_dir_prop(void *dir_baton,
 
   propchange = apr_array_push(db->propchanges);
   propchange->name = apr_pstrdup(db->pool, name);
-  propchange->value = value ? svn_string_dup(value, db->pool) : NULL;
+  propchange->value = svn_string_dup(value, db->pool);
 
   if (!db->edited && svn_property_kind2(name) == svn_prop_regular_kind)
     SVN_ERR(mark_directory_edited(db, pool));
@@ -3805,7 +3805,7 @@ change_file_prop(void *file_baton,
   /* Push a new propchange to the file baton's array of propchanges */
   propchange = apr_array_push(fb->propchanges);
   propchange->name = apr_pstrdup(fb->pool, name);
-  propchange->value = value ? svn_string_dup(value, fb->pool) : NULL;
+  propchange->value = svn_string_dup(value, fb->pool);
 
   if (!fb->edited && svn_property_kind2(name) == svn_prop_regular_kind)
     SVN_ERR(mark_file_edited(fb, scratch_pool));

Modified: subversion/trunk/subversion/svnrdump/load_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/load_editor.c?rev=1657254&r1=1657253&r2=1657254&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/load_editor.c (original)
+++ subversion/trunk/subversion/svnrdump/load_editor.c Wed Feb  4 14:32:25 2015
@@ -786,7 +786,7 @@ set_node_property(void *baton,
 
   prop = apr_palloc(nb->rb->pool, sizeof (*prop));
   prop->name = apr_pstrdup(pool, name);
-  prop->value = value ? svn_string_dup(value, pool) : NULL;
+  prop->value = svn_string_dup(value, pool);
   svn_hash_sets(nb->prop_changes, prop->name, prop);
 
   return SVN_NO_ERROR;



Mime
View raw message