You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2013/05/13 15:09:49 UTC

svn commit: r1481836 - in /subversion/trunk/subversion: include/svn_error.h libsvn_fs/fs-loader.c libsvn_subr/error.c

Author: danielsh
Date: Mon May 13 13:09:49 2013
New Revision: 1481836

URL: http://svn.apache.org/r1481836
Log:
Followup to r1481827: don't spam stderr by default for API consumers who are
not going to 'just abort()'.

This may introduce compiler warnings on windows, but those were deemed to be
acceptable.

Suggested by: rhuijben
Review by: rhuijben

* subversion/include/svn_error.h
  (svn_error_get_malfunction_handler): New API.

* subversion/libsvn_subr/error.c
  (svn_error_get_malfunction_handler): Implement it.

* subversion/libsvn_fs/fs-loader.c
  (default_warning_func):
    Only use stderr if the next line will abort().

Modified:
    subversion/trunk/subversion/include/svn_error.h
    subversion/trunk/subversion/libsvn_fs/fs-loader.c
    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=1481836&r1=1481835&r2=1481836&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error.h (original)
+++ subversion/trunk/subversion/include/svn_error.h Mon May 13 13:09:49 2013
@@ -613,6 +613,11 @@ typedef svn_error_t *(*svn_error_malfunc
 svn_error_malfunction_handler_t
 svn_error_set_malfunction_handler(svn_error_malfunction_handler_t func);
 
+/** Return the malfunction handler that is currently in effect.
+ * @since New in 1.9. */
+svn_error_malfunction_handler_t
+svn_error_get_malfunction_handler(void);
+
 /** Handle a malfunction by returning an error object that describes it.
  *
  * When @a can_return is false, abort()

Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1481836&r1=1481835&r2=1481836&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Mon May 13 13:09:49 2013
@@ -376,9 +376,13 @@ default_warning_func(void *baton, svn_er
      processes, since those may both be equivalent to /dev/null.
 
      That said, be a good citizen and print something anyway, in case it goes
-     somewhere.
+     somewhere, and our caller hasn't overridden the abort() call.
    */
-  svn_handle_error2(err, stderr, FALSE /* fatal */, "svn: fs-loader: ");
+  if (svn_error_get_malfunction_handler()
+      == svn_error_abort_on_malfunction)
+    /* ### TODO: extend the malfunction API such that non-abort()ing consumers
+       ### also get the information on ERR. */
+    svn_handle_error2(err, stderr, FALSE /* fatal */, "svn: fs-loader: ");
   SVN_ERR_MALFUNCTION_NO_RETURN();
 }
 

Modified: subversion/trunk/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/error.c?rev=1481836&r1=1481835&r2=1481836&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/error.c (original)
+++ subversion/trunk/subversion/libsvn_subr/error.c Mon May 13 13:09:49 2013
@@ -771,6 +771,12 @@ svn_error_set_malfunction_handler(svn_er
   return old_malfunction_handler;
 }
 
+svn_error_malfunction_handler_t
+svn_error_get_malfunction_handler(void)
+{
+  return malfunction_handler;
+}
+
 /* Note: Although this is a "__" function, it is in the public ABI, so
  * we can never remove it or change its signature. */
 svn_error_t *