subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1331242 - in /subversion/trunk/subversion: include/svn_error.h libsvn_subr/error.c
Date Fri, 27 Apr 2012 06:32:40 GMT
Author: gstein
Date: Fri Apr 27 06:32:40 2012
New Revision: 1331242

URL: http://svn.apache.org/viewvc?rev=1331242&view=rev
Log:
Fix error tracing to record file/line properly.

When code said:
  return svn_error_trace(foo());

It would set the file/line for that location, then call foo() and wrap
any resulting error. However, foo() could potentially set its own
file/line for an inner error. This revision uses a helper function to
reorder execution to: call foo(), then set file/line, then wrap any
resulting error with the trace information.

Prior symptoms were duplicate file/line. They are resolved properly now.

* subversion/include/svn_error.h:
  (svn_error__trace): new helper function
  (svn_error_trace): rewrite in terms of the new helper

* subversion/libsvn_subr/error.c:
  (svn_error__trace): new helper to properly set up file/line

Modified:
    subversion/trunk/subversion/include/svn_error.h
    subversion/trunk/subversion/libsvn_subr/error.c

Modified: subversion/trunk/subversion/include/svn_error.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_error.h?rev=1331242&r1=1331241&r2=1331242&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error.h (original)
+++ subversion/trunk/subversion/include/svn_error.h Fri Apr 27 06:32:40 2012
@@ -317,7 +317,10 @@ svn_handle_warning(FILE *stream,
 #ifdef SVN_ERR__TRACING
 #define SVN_ERR__TRACED "traced call"
 
-#define svn_error_trace(expr)  svn_error_quick_wrap((expr), SVN_ERR__TRACED)
+svn_error_t *
+svn_error__trace(const char *file, long line, svn_error_t *err);
+
+#define svn_error_trace(expr)  svn_error__trace(__FILE__, __LINE__, (expr))
 #else
 #define svn_error_trace(expr)  (expr)
 #endif

Modified: subversion/trunk/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/error.c?rev=1331242&r1=1331241&r2=1331242&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/error.c (original)
+++ subversion/trunk/subversion/libsvn_subr/error.c Fri Apr 27 06:32:40 2012
@@ -218,6 +218,28 @@ svn_error_quick_wrap(svn_error_t *child,
 
 
 svn_error_t *
+svn_error__trace(const char *file, long line, svn_error_t *err)
+{
+#ifndef SVN_DEBUG
+
+  /* We shouldn't even be here, but whatever. Just return the error as-is.  */
+  return err;
+
+#else
+
+  /* Only do the work when an error occurs.  */
+  if (err)
+    {
+      svn_error__locate(file, line);
+      return svn_error_quick_wrap(err, SVN_ERR__TRACED);
+    }
+  return SVN_NO_ERROR;
+
+#endif
+}
+
+
+svn_error_t *
 svn_error_compose_create(svn_error_t *err1,
                          svn_error_t *err2)
 {



Mime
View raw message