subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1241687 - /subversion/trunk/subversion/libsvn_delta/editor.c
Date Tue, 07 Feb 2012 23:03:47 GMT
Author: gstein
Date: Tue Feb  7 23:03:47 2012
New Revision: 1241687

URL: http://svn.apache.org/viewvc?rev=1241687&view=rev
Log:
Clean up some of the Ev2 driver ordering checks. Use macros to make
the code more readable.

* subversion/libsvn_delta/editor.c:
  (SHOULD_NOT_BE_FINISHED, MARK_COMPLETED, SHOULD_NOT_BE_COMPLETED):
    new macros to check or mark off various actions. they are
    functional when ENABLE_ORDERING_CHECK is on, and disabled otherwise
  (...): use new macros

Modified:
    subversion/trunk/subversion/libsvn_delta/editor.c

Modified: subversion/trunk/subversion/libsvn_delta/editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/editor.c?rev=1241687&r1=1241686&r2=1241687&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/editor.c (original)
+++ subversion/trunk/subversion/libsvn_delta/editor.c Tue Feb  7 23:03:47 2012
@@ -63,6 +63,33 @@ struct svn_editor_t
 #endif
 };
 
+#ifdef ENABLE_ORDERING_CHECK
+
+static const int singleton;
+
+#define SHOULD_NOT_BE_FINISHED(editor)  SVN_ERR_ASSERT(!(editor)->finished)
+
+#define MARK_COMPLETED(editor, relpath)   \
+  apr_hash_set((editor)->completed_nodes, \
+               apr_pstrdup((editor)->result_pool, relpath), \
+               APR_HASH_KEY_STRING, &singleton)
+#define SHOULD_NOT_BE_COMPLETED(editor, relpath) \
+  SVN_ERR_ASSERT(!apr_hash_get((editor)->completed_nodes, relpath, \
+                               APR_HASH_KEY_STRING));
+
+
+#else
+
+/* Be wary with the definition of these macros so that we don't
+   end up with "statement with no effect" warnings. Obviously, this
+   depends upon particular usage, which is easy to verify.  */
+#define SHOULD_NOT_BE_FINISHED(editor)  /* empty */
+
+#define MARK_COMPLETED(editor, relpath)  /* empty */
+#define SHOULD_NOT_BE_COMPLETED(editor, relpath)  /* empty */
+
+#endif /* ENABLE_ORDERING_CHECK */
+
 
 svn_error_t *
 svn_editor_create(svn_editor_t **editor,
@@ -257,11 +284,8 @@ svn_editor_add_directory(svn_editor_t *e
 
   SVN_ERR_ASSERT(children != NULL);
   SVN_ERR_ASSERT(props != NULL);
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -271,9 +295,7 @@ svn_editor_add_directory(svn_editor_t *e
                                          props, replaces_rev,
                                          editor->scratch_pool);
 #ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+  MARK_COMPLETED(editor, relpath);
   apr_hash_set(editor->pending_incomplete_children, relpath,
                APR_HASH_KEY_STRING, NULL);
   {
@@ -285,7 +307,7 @@ svn_editor_add_directory(svn_editor_t *e
                                              editor->result_pool);
 
         apr_hash_set(editor->pending_incomplete_children, child,
-                     APR_HASH_KEY_STRING, (void *)0xdeadbeef);
+                     APR_HASH_KEY_STRING, &singleton);
       }
   }
 #endif
@@ -307,11 +329,8 @@ svn_editor_add_file(svn_editor_t *editor
   SVN_ERR_ASSERT(checksum != NULL);
   SVN_ERR_ASSERT(contents != NULL);
   SVN_ERR_ASSERT(props != NULL);
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -321,9 +340,7 @@ svn_editor_add_file(svn_editor_t *editor
                                     checksum, contents, props,
                                     replaces_rev, editor->scratch_pool);
 #ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+  MARK_COMPLETED(editor, relpath);
   apr_hash_set(editor->pending_incomplete_children, relpath,
                APR_HASH_KEY_STRING, NULL);
 #endif
@@ -342,11 +359,8 @@ svn_editor_add_symlink(svn_editor_t *edi
   svn_error_t *err = SVN_NO_ERROR;
 
   SVN_ERR_ASSERT(props != NULL);
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -355,9 +369,7 @@ svn_editor_add_symlink(svn_editor_t *edi
     err = editor->funcs.cb_add_symlink(editor->baton, relpath, target, props,
                                        replaces_rev, editor->scratch_pool);
 #ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+  MARK_COMPLETED(editor, relpath);
   apr_hash_set(editor->pending_incomplete_children, relpath,
                APR_HASH_KEY_STRING, NULL);
 #endif
@@ -374,11 +386,8 @@ svn_editor_add_absent(svn_editor_t *edit
 {
   svn_error_t *err = SVN_NO_ERROR;
 
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -387,9 +396,7 @@ svn_editor_add_absent(svn_editor_t *edit
     err = editor->funcs.cb_add_absent(editor->baton, relpath, kind,
                                       replaces_rev, editor->scratch_pool);
 #ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+  MARK_COMPLETED(editor, relpath);
   apr_hash_set(editor->pending_incomplete_children, relpath,
                APR_HASH_KEY_STRING, NULL);
 #endif
@@ -407,11 +414,8 @@ svn_editor_alter_directory(svn_editor_t 
   svn_error_t *err = SVN_NO_ERROR;
 
   SVN_ERR_ASSERT(props != NULL);
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -420,11 +424,9 @@ svn_editor_alter_directory(svn_editor_t 
     err = editor->funcs.cb_alter_directory(editor->baton,
                                            relpath, revision, props,
                                            editor->scratch_pool);
-#ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
-#endif
+
+  MARK_COMPLETED(editor, relpath);
+
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -443,11 +445,8 @@ svn_editor_alter_file(svn_editor_t *edit
   SVN_ERR_ASSERT((checksum != NULL && contents != NULL)
                  || (checksum == NULL && contents == NULL));
   SVN_ERR_ASSERT(props != NULL || checksum != NULL);
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -457,11 +456,9 @@ svn_editor_alter_file(svn_editor_t *edit
                                       relpath, revision, props,
                                       checksum, contents,
                                       editor->scratch_pool);
-#ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
-#endif
+
+  MARK_COMPLETED(editor, relpath);
+
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -477,11 +474,8 @@ svn_editor_alter_symlink(svn_editor_t *e
   svn_error_t *err = SVN_NO_ERROR;
 
   SVN_ERR_ASSERT(props != NULL || target != NULL);
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -491,11 +485,9 @@ svn_editor_alter_symlink(svn_editor_t *e
                                          relpath, revision, props,
                                          target,
                                          editor->scratch_pool);
-#ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
-#endif
+
+  MARK_COMPLETED(editor, relpath);
+
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -508,11 +500,8 @@ svn_editor_delete(svn_editor_t *editor,
 {
   svn_error_t *err = SVN_NO_ERROR;
 
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -520,11 +509,9 @@ svn_editor_delete(svn_editor_t *editor,
   if (editor->funcs.cb_delete)
     err = editor->funcs.cb_delete(editor->baton, relpath, revision,
                                   editor->scratch_pool);
-#ifdef ENABLE_ORDERING_CHECK
-  apr_hash_set(editor->completed_nodes,
-               apr_pstrdup(editor->result_pool, relpath),
-               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
-#endif
+
+  MARK_COMPLETED(editor, relpath);
+
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -539,11 +526,8 @@ svn_editor_copy(svn_editor_t *editor,
 {
   svn_error_t *err = SVN_NO_ERROR;
 
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, dst_relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, dst_relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -566,13 +550,9 @@ svn_editor_move(svn_editor_t *editor,
 {
   svn_error_t *err = SVN_NO_ERROR;
 
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, src_relpath,
-                               APR_HASH_KEY_STRING));
-  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, dst_relpath,
-                               APR_HASH_KEY_STRING));
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
+  SHOULD_NOT_BE_COMPLETED(editor, src_relpath);
+  SHOULD_NOT_BE_COMPLETED(editor, dst_relpath);
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -609,8 +589,8 @@ svn_editor_rotate(svn_editor_t *editor,
 {
   svn_error_t *err = SVN_NO_ERROR;
 
+  SHOULD_NOT_BE_FINISHED(editor);
 #ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
   /* ### something more  */
 #endif
 
@@ -633,8 +613,8 @@ svn_editor_complete(svn_editor_t *editor
 {
   svn_error_t *err = SVN_NO_ERROR;
 
+  SHOULD_NOT_BE_FINISHED(editor);
 #ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
   SVN_ERR_ASSERT(apr_hash_count(editor->pending_incomplete_children) == 0);
 #endif
 
@@ -653,9 +633,7 @@ svn_editor_abort(svn_editor_t *editor)
 {
   svn_error_t *err = SVN_NO_ERROR;
 
-#ifdef ENABLE_ORDERING_CHECK
-  SVN_ERR_ASSERT(!editor->finished);
-#endif
+  SHOULD_NOT_BE_FINISHED(editor);
 
   if (editor->funcs.cb_abort)
     err = editor->funcs.cb_abort(editor->baton, editor->scratch_pool);



Mime
View raw message