subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1543805 - in /subversion/trunk/subversion: svn/svn.c svnadmin/svnadmin.c
Date Wed, 20 Nov 2013 12:44:43 GMT
Author: julianfoad
Date: Wed Nov 20 12:44:43 2013
New Revision: 1543805

URL: http://svn.apache.org/r1543805
Log:
Improve consistency of error reporting in 'svn' and 'svnadmin', mainly by
channeling nearly all errors thrown within sub_main() up to a single handler
in main().

This is a source code improvement: no functional change.

This is a follow-up to r1368252 which initially separated the initilization
and tear-down into a separate function from the bulk of the logic in these
two programs. It was my intention then to follow up with something like
this. Similar factorization of the other command-line tools will follow.

* subversion/svn/svn.c,
  subversion/svnadmin/svnadmin.c
  (EXIT_ERROR, SVN_INT_ERR): Remove.
  (sub_main): Let this return a standard Subversion error object, and add an
    exit_code output parameter for those cases where a non-zero exit code is
    needed without an error message.
  (main): Display any returned error here.

Modified:
    subversion/trunk/subversion/svn/svn.c
    subversion/trunk/subversion/svnadmin/svnadmin.c

Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1543805&r1=1543804&r2=1543805&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Wed Nov 20 12:44:43 2013
@@ -1741,23 +1741,13 @@ add_search_pattern_to_latest_group(svn_c
 
 /*** Main. ***/
 
-/* Report and clear the error ERR, and return EXIT_FAILURE. Suppress the
- * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
-#define EXIT_ERROR(err)                                                 \
-  svn_cmdline_handle_exit_error(err, NULL, "svn: ")
-
-/* A redefinition of the public SVN_INT_ERR macro, that suppresses the
- * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR. */
-#undef SVN_INT_ERR
-#define SVN_INT_ERR(expr)                                        \
-  do {                                                           \
-    svn_error_t *svn_err__temp = (expr);                         \
-    if (svn_err__temp)                                           \
-      return EXIT_ERROR(svn_err__temp);                          \
-  } while (0)
-
-static int
-sub_main(int argc, const char *argv[], apr_pool_t *pool)
+/*
+ * On success, leave *EXIT_CODE untouched and return SVN_NO_ERROR. On error,
+ * either return an error to be displayed, or set *EXIT_CODE to non-zero and
+ * return SVN_NO_ERROR.
+ */
+static svn_error_t *
+sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
 {
   svn_error_t *err;
   int opt_id;
@@ -1784,18 +1774,18 @@ sub_main(int argc, const char *argv[], a
   received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
 
   /* Check library versions */
-  SVN_INT_ERR(check_lib_versions());
+  SVN_ERR(check_lib_versions());
 
 #if defined(WIN32) || defined(__CYGWIN__)
   /* Set the working copy administrative directory name. */
   if (getenv("SVN_ASP_DOT_NET_HACK"))
     {
-      SVN_INT_ERR(svn_wc_set_adm_dir("_svn", pool));
+      SVN_ERR(svn_wc_set_adm_dir("_svn", pool));
     }
 #endif
 
   /* Initialize the RA library. */
-  SVN_INT_ERR(svn_ra_initialize(pool));
+  SVN_ERR(svn_ra_initialize(pool));
 
   /* Init our changelists hash. */
   changelists = apr_hash_make(pool);
@@ -1813,12 +1803,13 @@ sub_main(int argc, const char *argv[], a
   /* No args?  Show usage. */
   if (argc <= 1)
     {
-      SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
-      return EXIT_FAILURE;
+      SVN_ERR(svn_cl__help(NULL, NULL, pool));
+      *exit_code = EXIT_FAILURE;
+      return SVN_NO_ERROR;
     }
 
   /* Else, parse options. */
-  SVN_INT_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
+  SVN_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
 
   os->interleave = 1;
   while (1)
@@ -1833,8 +1824,9 @@ sub_main(int argc, const char *argv[], a
         break;
       else if (apr_err)
         {
-          SVN_INT_ERR(svn_cl__help(NULL, NULL, pool));
-          return EXIT_FAILURE;
+          SVN_ERR(svn_cl__help(NULL, NULL, pool));
+          *exit_code = EXIT_FAILURE;
+          return SVN_NO_ERROR;
         }
 
       /* Stash the option code in an array before parsing it. */
@@ -1843,19 +1835,17 @@ sub_main(int argc, const char *argv[], a
       switch (opt_id) {
       case 'l':
         {
-          SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           err = svn_cstring_atoi(&opt_state.limit, utf8_opt_arg);
           if (err)
             {
-              err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
-                                     _("Non-numeric limit argument given"));
-              return EXIT_ERROR(err);
+              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, err,
+                                      _("Non-numeric limit argument given"));
             }
           if (opt_state.limit <= 0)
             {
-              err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
-                                    _("Argument to --limit must be positive"));
-              return EXIT_ERROR(err);
+              return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
+                                      _("Argument to --limit must be positive"));
             }
         }
         break;
@@ -1868,16 +1858,14 @@ sub_main(int argc, const char *argv[], a
         {
           apr_array_header_t *change_revs;
 
-          SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           change_revs = svn_cstring_split(utf8_opt_arg, ", \n\r\t\v", TRUE,
                                           pool);
 
           if (opt_state.old_target)
             {
-              err = svn_error_create
-                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                 _("Can't specify -c with --old"));
-              return EXIT_ERROR(err);
+              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                      _("Can't specify -c with --old"));
             }
 
           for (i = 0; i < change_revs->nelts; i++)
@@ -1905,12 +1893,11 @@ sub_main(int argc, const char *argv[], a
                 {
                   if (changeno < 0 || is_negative)
                     {
-                      err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
-                                              NULL,
-                                              _("Negative number in range (%s)"
-                                                " not supported with -c"),
-                                              change_str);
-                      return EXIT_ERROR(err);
+                      return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
+                                               NULL,
+                                               _("Negative number in range (%s)"
+                                                 " not supported with -c"),
+                                               change_str);
                     }
                   s = end + 1;
                   while (*s == 'r')
@@ -1919,17 +1906,15 @@ sub_main(int argc, const char *argv[], a
                 }
               if (end == change_str || *end != '\0')
                 {
-                  err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                          _("Non-numeric change argument (%s) "
-                                            "given to -c"), change_str);
-                  return EXIT_ERROR(err);
+                  return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                           _("Non-numeric change argument (%s) "
+                                             "given to -c"), change_str);
                 }
 
               if (changeno == 0)
                 {
-                  err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                         _("There is no change 0"));
-                  return EXIT_ERROR(err);
+                  return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                          _("There is no change 0"));
                 }
 
               if (is_negative)
@@ -1965,15 +1950,13 @@ sub_main(int argc, const char *argv[], a
         break;
       case 'r':
         opt_state.used_revision_arg = TRUE;
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         if (svn_opt_parse_revision_to_range(opt_state.revision_ranges,
                                             utf8_opt_arg, pool) != 0)
           {
-            err = svn_error_createf
-                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                  _("Syntax error in revision argument '%s'"),
                  utf8_opt_arg);
-            return EXIT_ERROR(err);
           }
         break;
       case 'v':
@@ -1996,9 +1979,9 @@ sub_main(int argc, const char *argv[], a
         /* We read the raw file content here.  We will convert it to UTF-8
          * later (if it's a log/lock message or an svn:* prop value),
          * according to the value of the '--encoding' option. */
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
-        SVN_INT_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
-                                             utf8_opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
+                                         utf8_opt_arg, pool));
         reading_file_from_stdin = (strcmp(utf8_opt_arg, "-") == 0);
         dash_F_arg = utf8_opt_arg;
         break;
@@ -2006,9 +1989,9 @@ sub_main(int argc, const char *argv[], a
         {
           svn_stringbuf_t *buffer, *buffer_utf8;
 
-          SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
-          SVN_INT_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
-          SVN_INT_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
+          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+          SVN_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
+          SVN_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
           opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r",
                                                 TRUE, pool);
         }
@@ -2034,51 +2017,47 @@ sub_main(int argc, const char *argv[], a
       case opt_depth:
         err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
         if (err)
-          return EXIT_ERROR
-            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
-                               _("Error converting depth "
-                                 "from locale to UTF-8")));
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
+                                   _("Error converting depth "
+                                     "from locale to UTF-8"));
         opt_state.depth = svn_depth_from_word(utf8_opt_arg);
         if (opt_state.depth == svn_depth_unknown
             || opt_state.depth == svn_depth_exclude)
           {
-            return EXIT_ERROR
-              (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a valid depth; try "
-                                   "'empty', 'files', 'immediates', "
-                                   "or 'infinity'"),
-                                 utf8_opt_arg));
+            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                     _("'%s' is not a valid depth; try "
+                                       "'empty', 'files', 'immediates', "
+                                       "or 'infinity'"),
+                                     utf8_opt_arg);
           }
         break;
       case opt_set_depth:
         err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool);
         if (err)
-          return EXIT_ERROR
-            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
-                               _("Error converting depth "
-                                 "from locale to UTF-8")));
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
+                                   _("Error converting depth "
+                                     "from locale to UTF-8"));
         opt_state.set_depth = svn_depth_from_word(utf8_opt_arg);
         /* svn_depth_exclude is okay for --set-depth. */
         if (opt_state.set_depth == svn_depth_unknown)
           {
-            return EXIT_ERROR
-              (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("'%s' is not a valid depth; try "
-                                   "'exclude', 'empty', 'files', "
-                                   "'immediates', or 'infinity'"),
-                                 utf8_opt_arg));
+            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                     _("'%s' is not a valid depth; try "
+                                       "'exclude', 'empty', 'files', "
+                                       "'immediates', or 'infinity'"),
+                                     utf8_opt_arg);
           }
         break;
       case opt_version:
         opt_state.version = TRUE;
         break;
       case opt_auth_username:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
-                                            opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
+                                        opt_arg, pool));
         break;
       case opt_auth_password:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
-                                            opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
+                                        opt_arg, pool));
         break;
       case opt_encoding:
         opt_state.encoding = apr_pstrdup(pool, opt_arg);
@@ -2132,8 +2111,8 @@ sub_main(int argc, const char *argv[], a
         opt_state.relocate = TRUE;
         break;
       case 'x':
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
-                                            opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
+                                        opt_arg, pool));
         break;
       case opt_diff_cmd:
         opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
@@ -2150,20 +2129,18 @@ sub_main(int argc, const char *argv[], a
       case opt_old_cmd:
         if (opt_state.used_change_arg)
           {
-            err = svn_error_create
-              (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-               _("Can't specify -c with --old"));
-            return EXIT_ERROR(err);
+            return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                    _("Can't specify -c with --old"));
           }
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.old_target = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_new_cmd:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.new_target = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_config_dir:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.config_dir = svn_dirent_internal_style(utf8_opt_arg, pool);
         break;
       case opt_config_options:
@@ -2172,9 +2149,9 @@ sub_main(int argc, const char *argv[], a
                    apr_array_make(pool, 1,
                                   sizeof(svn_cmdline__config_argument_t*));
 
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
-        SVN_INT_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
-                                                     utf8_opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
+                                                 utf8_opt_arg, pool));
         break;
       case opt_autoprops:
         opt_state.autoprops = TRUE;
@@ -2183,17 +2160,15 @@ sub_main(int argc, const char *argv[], a
         opt_state.no_autoprops = TRUE;
         break;
       case opt_native_eol:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         if ( !strcmp("LF", utf8_opt_arg) || !strcmp("CR", utf8_opt_arg) ||
              !strcmp("CRLF", utf8_opt_arg))
           opt_state.native_eol = utf8_opt_arg;
         else
           {
-            err = svn_error_createf
-                (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+            return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                  _("Syntax error in native-eol argument '%s'"),
                  utf8_opt_arg);
-            return EXIT_ERROR(err);
           }
         break;
       case opt_no_unlock:
@@ -2206,12 +2181,11 @@ sub_main(int argc, const char *argv[], a
         opt_state.remove = TRUE;
         break;
       case opt_changelist:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         if (utf8_opt_arg[0] == '\0')
           {
-            err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                   _("Changelist names must not be empty"));
-            return EXIT_ERROR(err);
+            return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                    _("Changelist names must not be empty"));
           }
         svn_hash_sets(changelists, utf8_opt_arg, (void *)1);
         break;
@@ -2230,8 +2204,8 @@ sub_main(int argc, const char *argv[], a
         opt_state.no_revprops = TRUE;
         break;
       case opt_with_revprop:
-        SVN_INT_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
-                                          opt_arg, pool));
+        SVN_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
+                                      opt_arg, pool));
         break;
       case opt_parents:
         opt_state.parents = TRUE;
@@ -2243,22 +2217,20 @@ sub_main(int argc, const char *argv[], a
         opt_state.auto_moves = TRUE;
         break;
       case opt_accept:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.accept_which = svn_cl__accept_from_word(utf8_opt_arg);
         if (opt_state.accept_which == svn_cl__accept_invalid)
-          return EXIT_ERROR
-            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                               _("'%s' is not a valid --accept value"),
-                               utf8_opt_arg));
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                   _("'%s' is not a valid --accept value"),
+                                   utf8_opt_arg);
         break;
       case opt_show_revs:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.show_revs = svn_cl__show_revs_from_word(utf8_opt_arg);
         if (opt_state.show_revs == svn_cl__show_revs_invalid)
-          return EXIT_ERROR
-            (svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                               _("'%s' is not a valid --show-revs value"),
-                               utf8_opt_arg));
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                   _("'%s' is not a valid --show-revs value"),
+                                   utf8_opt_arg);
         break;
       case opt_mergeinfo_log:
         opt_state.mergeinfo_log = TRUE;
@@ -2268,20 +2240,18 @@ sub_main(int argc, const char *argv[], a
         break;
       case opt_strip:
         {
-          SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           err = svn_cstring_atoi(&opt_state.strip, utf8_opt_arg);
           if (err)
             {
-              err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
-                                      _("Invalid strip count '%s'"),
-                                      utf8_opt_arg);
-              return EXIT_ERROR(err);
+              return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, err,
+                                       _("Invalid strip count '%s'"),
+                                       utf8_opt_arg);
             }
           if (opt_state.strip < 0)
             {
-              err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
-                                     _("Argument to --strip must be positive"));
-              return EXIT_ERROR(err);
+              return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
+                                      _("Argument to --strip must be positive"));
             }
         }
         break;
@@ -2319,11 +2289,11 @@ sub_main(int argc, const char *argv[], a
         opt_state.diff.properties_only = TRUE;
         break;
       case opt_search:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         add_search_pattern_group(&opt_state, utf8_opt_arg, pool);
         break;
       case opt_search_and:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         add_search_pattern_to_latest_group(&opt_state, utf8_opt_arg, pool);
       case opt_remove_unversioned:
         opt_state.remove_unversioned = TRUE;
@@ -2345,10 +2315,9 @@ sub_main(int argc, const char *argv[], a
    * exclusive. */
   if (opt_state.non_interactive && force_interactive)
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--non-interactive and --force-interactive "
-                               "are mutually exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--non-interactive and --force-interactive "
+                                "are mutually exclusive"));
     }
   else
     opt_state.non_interactive = !svn_cmdline__be_interactive(
@@ -2356,7 +2325,7 @@ sub_main(int argc, const char *argv[], a
                                   force_interactive);
 
   /* Turn our hash of changelists into an array of unique ones. */
-  SVN_INT_ERR(svn_hash_keys(&(opt_state.changelists), changelists, pool));
+  SVN_ERR(svn_hash_keys(&(opt_state.changelists), changelists, pool));
 
   /* ### This really belongs in libsvn_client.  The trouble is,
      there's no one place there to run it from, no
@@ -2368,7 +2337,7 @@ sub_main(int argc, const char *argv[], a
      hand, the alternative is effectively to demand that they call
      svn_config_ensure() instead, so maybe we should have a generic
      init function anyway.  Thoughts?  */
-  SVN_INT_ERR(svn_config_ensure(opt_state.config_dir, pool));
+  SVN_ERR(svn_config_ensure(opt_state.config_dir, pool));
 
   /* If the user asked for help, then the rest of the arguments are
      the names of subcommands to get help on (if any), or else they're
@@ -2402,7 +2371,8 @@ sub_main(int argc, const char *argv[], a
                 (svn_cmdline_fprintf(stderr, pool,
                                      _("Subcommand argument required\n")));
               svn_error_clear(svn_cl__help(NULL, NULL, pool));
-              return EXIT_FAILURE;
+              *exit_code = EXIT_FAILURE;
+              return SVN_NO_ERROR;
             }
         }
       else
@@ -2413,8 +2383,8 @@ sub_main(int argc, const char *argv[], a
           if (subcommand == NULL)
             {
               const char *first_arg_utf8;
-              SVN_INT_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
-                                                  first_arg, pool));
+              SVN_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
+                                              first_arg, pool));
               svn_error_clear
                 (svn_cmdline_fprintf(stderr, pool,
                                      _("Unknown subcommand: '%s'\n"),
@@ -2431,7 +2401,8 @@ sub_main(int argc, const char *argv[], a
                                            "command.\n")));
                 }
 
-              return EXIT_FAILURE;
+              *exit_code = EXIT_FAILURE;
+              return SVN_NO_ERROR;
             }
         }
     }
@@ -2464,7 +2435,8 @@ sub_main(int argc, const char *argv[], a
                (stderr, pool, _("Subcommand '%s' doesn't accept option '%s'\n"
                                 "Type 'svn help %s' for usage.\n"),
                 subcommand->name, optstr, subcommand->name));
-          return EXIT_FAILURE;
+          *exit_code = EXIT_FAILURE;
+          return SVN_NO_ERROR;
         }
     }
 
@@ -2474,11 +2446,10 @@ sub_main(int argc, const char *argv[], a
     {
       if (opt_state.revision_ranges->nelts > 1)
         {
-          err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("Multiple revision arguments "
-                                   "encountered; can't specify -c twice, "
-                                   "or both -c and -r"));
-          return EXIT_ERROR(err);
+          return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                  _("Multiple revision arguments "
+                                    "encountered; can't specify -c twice, "
+                                    "or both -c and -r"));
         }
     }
 
@@ -2486,30 +2457,27 @@ sub_main(int argc, const char *argv[], a
   if ((opt_state.depth != svn_depth_unknown)
       && (opt_state.set_depth != svn_depth_unknown))
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--depth and --set-depth are mutually "
-                               "exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--depth and --set-depth are mutually "
+                                "exclusive"));
     }
 
   /* Disallow simultaneous use of both --with-all-revprops and
      --with-no-revprops.  */
   if (opt_state.all_revprops && opt_state.no_revprops)
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--with-all-revprops and --with-no-revprops "
-                               "are mutually exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--with-all-revprops and --with-no-revprops "
+                                "are mutually exclusive"));
     }
 
   /* Disallow simultaneous use of both --with-revprop and
      --with-no-revprops.  */
   if (opt_state.revprop_table && opt_state.no_revprops)
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--with-revprop and --with-no-revprops "
-                               "are mutually exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--with-revprop and --with-no-revprops "
+                                "are mutually exclusive"));
     }
 
 #ifdef SVN_CL__OPTION_WITH_REVPROP_CAN_SET_PROPERTIES_IN_SVN_NAMESPACE
@@ -2523,9 +2491,9 @@ sub_main(int argc, const char *argv[], a
       for (hi = apr_hash_first(pool, opt_state.revprop_table);
            hi; hi = apr_hash_next(hi))
         {
-          SVN_INT_ERR(svn_cl__check_svn_prop_name(svn__apr_hash_index_key(hi),
-                                                  TRUE, svn_cl__prop_use_use,
-                                                  pool));
+          SVN_ERR(svn_cl__check_svn_prop_name(svn__apr_hash_index_key(hi),
+                                              TRUE, svn_cl__prop_use_use,
+                                              pool));
         }
     }
 #endif /* SVN_CL__OPTION_WITH_REVPROP_CAN_SET_PROPERTIES_IN_SVN_NAMESPACE */
@@ -2537,29 +2505,26 @@ sub_main(int argc, const char *argv[], a
   if (opt_state.filedata && opt_state.message
       && subcommand->cmd_func != svn_cl__propset)
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--message (-m) and --file (-F) "
-                               "are mutually exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--message (-m) and --file (-F) "
+                                "are mutually exclusive"));
     }
 
   /* --trust-server-cert can only be used with --non-interactive */
   if (opt_state.trust_server_cert && !opt_state.non_interactive)
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--trust-server-cert requires "
-                               "--non-interactive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--trust-server-cert requires "
+                                "--non-interactive"));
     }
 
   /* Disallow simultaneous use of both --diff-cmd and
      --internal-diff.  */
   if (opt_state.diff.diff_cmd && opt_state.diff.internal_diff)
     {
-      err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                             _("--diff-cmd and --internal-diff "
-                               "are mutually exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                              _("--diff-cmd and --internal-diff "
+                                "are mutually exclusive"));
     }
 
   /* Ensure that 'revision_ranges' has at least one item, and make
@@ -2590,7 +2555,7 @@ sub_main(int argc, const char *argv[], a
           cfg_hash = NULL;
         }
       else
-        return EXIT_ERROR(err);
+        return err;
     }
 
   /* Relocation is infinite-depth only. */
@@ -2598,18 +2563,16 @@ sub_main(int argc, const char *argv[], a
     {
       if (opt_state.depth != svn_depth_unknown)
         {
-          err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
-                                 _("--relocate and --depth are mutually "
-                                   "exclusive"));
-          return EXIT_ERROR(err);
+          return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
+                                  _("--relocate and --depth are mutually "
+                                    "exclusive"));
         }
       if (! descend)
         {
-          err = svn_error_create(
+          return svn_error_create(
                     SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
                     _("--relocate and --non-recursive (-N) are mutually "
                       "exclusive"));
-          return EXIT_ERROR(err);
         }
     }
 
@@ -2623,8 +2586,7 @@ sub_main(int argc, const char *argv[], a
     {
       if (opt_state.end_revision.kind != svn_opt_revision_unspecified)
         {
-          err = svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL);
-          return EXIT_ERROR(err);
+          return svn_error_create(SVN_ERR_CLIENT_REVISION_RANGE, NULL, NULL);
         }
     }
 
@@ -2691,7 +2653,7 @@ sub_main(int argc, const char *argv[], a
 
   /* Create a client context object. */
   command_baton.opt_state = &opt_state;
-  SVN_INT_ERR(svn_client_create_context2(&ctx, cfg_hash, pool));
+  SVN_ERR(svn_client_create_context2(&ctx, cfg_hash, pool));
   command_baton.ctx = ctx;
 
   /* If we're running a command that could result in a commit, verify
@@ -2727,19 +2689,18 @@ sub_main(int argc, const char *argv[], a
                 {
                   if (subcommand->cmd_func != svn_cl__lock)
                     {
-                      err = svn_error_create(
+                      return svn_error_create(
                          SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
                          _("Log message file is a versioned file; "
                            "use '--force-log' to override"));
                     }
                   else
                     {
-                      err = svn_error_create(
+                      return svn_error_create(
                          SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, NULL,
                          _("Lock comment file is a versioned file; "
                            "use '--force-log' to override"));
                     }
-                  return EXIT_ERROR(err);
                 }
             }
           svn_error_clear(err);
@@ -2755,19 +2716,18 @@ sub_main(int argc, const char *argv[], a
             {
               if (subcommand->cmd_func != svn_cl__lock)
                 {
-                  err = svn_error_create
+                  return svn_error_create
                     (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
                      _("The log message is a pathname "
                        "(was -F intended?); use '--force-log' to override"));
                 }
               else
                 {
-                  err = svn_error_create
+                  return svn_error_create
                     (SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, NULL,
                      _("The lock comment is a pathname "
                        "(was -F intended?); use '--force-log' to override"));
                 }
-              return EXIT_ERROR(err);
             }
         }
     }
@@ -2787,10 +2747,9 @@ sub_main(int argc, const char *argv[], a
   /* Check for mutually exclusive args --auto-props and --no-auto-props */
   if (opt_state.autoprops && opt_state.no_autoprops)
     {
-      err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
-                             _("--auto-props and --no-auto-props are "
-                               "mutually exclusive"));
-      return EXIT_ERROR(err);
+      return svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL,
+                              _("--auto-props and --no-auto-props are "
+                                "mutually exclusive"));
     }
 
   /* Update auto-props-enable option, and populate the MIME types map,
@@ -2804,8 +2763,8 @@ sub_main(int argc, const char *argv[], a
                      SVN_CONFIG_OPTION_MIMETYPES_FILE, FALSE);
       if (mimetypes_file && *mimetypes_file)
         {
-          SVN_INT_ERR(svn_io_parse_mimetypes_file(&(ctx->mimetypes_map),
-                                                  mimetypes_file, pool));
+          SVN_ERR(svn_io_parse_mimetypes_file(&(ctx->mimetypes_map),
+                                              mimetypes_file, pool));
         }
 
       if (opt_state.autoprops)
@@ -2843,8 +2802,8 @@ sub_main(int argc, const char *argv[], a
     use_notifier = FALSE;
   if (use_notifier)
     {
-      SVN_INT_ERR(svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2,
-                                       conflict_stats, pool));
+      SVN_ERR(svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2,
+                                   conflict_stats, pool));
     }
 
   /* Set up our cancellation support. */
@@ -2874,35 +2833,36 @@ sub_main(int argc, const char *argv[], a
 #endif
 
   /* Set up Authentication stuff. */
-  SVN_INT_ERR(svn_cmdline_create_auth_baton(&ab,
-                                            opt_state.non_interactive,
-                                            opt_state.auth_username,
-                                            opt_state.auth_password,
-                                            opt_state.config_dir,
-                                            opt_state.no_auth_cache,
-                                            opt_state.trust_server_cert,
-                                            cfg_config,
-                                            ctx->cancel_func,
-                                            ctx->cancel_baton,
-                                            pool));
+  SVN_ERR(svn_cmdline_create_auth_baton(&ab,
+                                        opt_state.non_interactive,
+                                        opt_state.auth_username,
+                                        opt_state.auth_password,
+                                        opt_state.config_dir,
+                                        opt_state.no_auth_cache,
+                                        opt_state.trust_server_cert,
+                                        cfg_config,
+                                        ctx->cancel_func,
+                                        ctx->cancel_baton,
+                                        pool));
 
   ctx->auth_baton = ab;
 
   if (opt_state.non_interactive)
     {
       if (opt_state.accept_which == svn_cl__accept_edit)
-        return EXIT_ERROR(
-                 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+        {
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                    _("--accept=%s incompatible with"
                                      " --non-interactive"),
-                                   SVN_CL__ACCEPT_EDIT));
-
+                                   SVN_CL__ACCEPT_EDIT);
+        }
       if (opt_state.accept_which == svn_cl__accept_launch)
-        return EXIT_ERROR(
-                 svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+        {
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                    _("--accept=%s incompatible with"
                                      " --non-interactive"),
-                                   SVN_CL__ACCEPT_LAUNCH));
+                                   SVN_CL__ACCEPT_LAUNCH);
+        }
 
       /* The default action when we're non-interactive is to postpone
        * conflict resolution. */
@@ -2913,10 +2873,10 @@ sub_main(int argc, const char *argv[], a
   /* Check whether interactive conflict resolution is disabled by
    * the configuration file. If no --accept option was specified
    * we postpone all conflicts in this case. */
-  SVN_INT_ERR(svn_config_get_bool(cfg_config, &interactive_conflicts,
-                                  SVN_CONFIG_SECTION_MISCELLANY,
-                                  SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS,
-                                  TRUE));
+  SVN_ERR(svn_config_get_bool(cfg_config, &interactive_conflicts,
+                              SVN_CONFIG_SECTION_MISCELLANY,
+                              SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS,
+                              TRUE));
   if (!interactive_conflicts)
     {
       /* Make 'svn resolve' non-interactive. */
@@ -2937,7 +2897,7 @@ sub_main(int argc, const char *argv[], a
     ctx->conflict_baton = NULL;
 
     ctx->conflict_func2 = svn_cl__conflict_func_interactive;
-    SVN_INT_ERR(svn_cl__get_conflict_func_interactive_baton(
+    SVN_ERR(svn_cl__get_conflict_func_interactive_baton(
                 &b,
                 opt_state.accept_which,
                 ctx->config, opt_state.editor_cmd, conflict_stats,
@@ -3014,15 +2974,15 @@ sub_main(int argc, const char *argv[], a
          This makes sure that output is not silently lost. */
       err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
 
-      return EXIT_ERROR(err);
+      return err;
     }
   else
     {
       /* Ensure that stdout is flushed, so the user will see any write errors.
          This makes sure that output is not silently lost. */
-      SVN_INT_ERR(svn_cmdline_fflush(stdout));
+      SVN_ERR(svn_cmdline_fflush(stdout));
 
-      return EXIT_SUCCESS;
+      return SVN_NO_ERROR;
     }
 }
 
@@ -3031,6 +2991,7 @@ main(int argc, const char *argv[])
 {
   apr_pool_t *pool;
   int exit_code;
+  svn_error_t *err;
 
   /* Initialize the app. */
   if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
@@ -3041,7 +3002,12 @@ main(int argc, const char *argv[])
    */
   pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
-  exit_code = sub_main(argc, argv, pool);
+  err = sub_main(&exit_code, argc, argv, pool);
+  if (err)
+    {
+      exit_code = EXIT_FAILURE;
+      svn_cmdline_handle_exit_error(err, NULL, "svn: ");
+    }
 
   svn_pool_destroy(pool);
   return exit_code;

Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1543805&r1=1543804&r2=1543805&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Wed Nov 20 12:44:43 2013
@@ -2135,23 +2135,13 @@ subcommand_upgrade(apr_getopt_t *os, voi
 
 /** Main. **/
 
-/* Report and clear the error ERR, and return EXIT_FAILURE. */
-#define EXIT_ERROR(err)                                                 \
-  svn_cmdline_handle_exit_error(err, NULL, "svnadmin: ")
-
-/* A redefinition of the public SVN_INT_ERR macro, that suppresses the
- * error message if it is SVN_ERR_IO_PIPE_WRITE_ERROR, amd with the
- * program name 'svnadmin' instead of 'svn'. */
-#undef SVN_INT_ERR
-#define SVN_INT_ERR(expr)                                        \
-  do {                                                           \
-    svn_error_t *svn_err__temp = (expr);                         \
-    if (svn_err__temp)                                           \
-      return EXIT_ERROR(svn_err__temp);                          \
-  } while (0)
-
-static int
-sub_main(int argc, const char *argv[], apr_pool_t *pool)
+/*
+ * On success, leave *EXIT_CODE untouched and return SVN_NO_ERROR. On error,
+ * either return an error to be displayed, or set *EXIT_CODE to non-zero and
+ * return SVN_NO_ERROR.
+ */
+static svn_error_t *
+sub_main(int *exit_code, int argc, const char *argv[], apr_pool_t *pool)
 {
   svn_error_t *err;
   apr_status_t apr_err;
@@ -2167,15 +2157,16 @@ sub_main(int argc, const char *argv[], a
   received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
 
   /* Check library versions */
-  SVN_INT_ERR(check_lib_versions());
+  SVN_ERR(check_lib_versions());
 
   /* Initialize the FS library. */
-  SVN_INT_ERR(svn_fs_initialize(pool));
+  SVN_ERR(svn_fs_initialize(pool));
 
   if (argc <= 1)
     {
-      SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
-      return EXIT_FAILURE;
+      SVN_ERR(subcommand_help(NULL, NULL, pool));
+      *exit_code = EXIT_FAILURE;
+      return SVN_NO_ERROR;
     }
 
   /* Initialize opt_state. */
@@ -2184,7 +2175,7 @@ sub_main(int argc, const char *argv[], a
   opt_state.memory_cache_size = svn_cache_config_get()->cache_size;
 
   /* Parse options. */
-  SVN_INT_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
+  SVN_ERR(svn_cmdline__getopt_init(&os, argc, argv, pool));
 
   os->interleave = 1;
 
@@ -2199,8 +2190,9 @@ sub_main(int argc, const char *argv[], a
         break;
       else if (apr_err)
         {
-          SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
-          return EXIT_FAILURE;
+          SVN_ERR(subcommand_help(NULL, NULL, pool));
+          *exit_code = EXIT_FAILURE;
+          return SVN_NO_ERROR;
         }
 
       /* Stash the option code in an array before parsing it. */
@@ -2211,23 +2203,19 @@ sub_main(int argc, const char *argv[], a
         {
           if (opt_state.start_revision.kind != svn_opt_revision_unspecified)
             {
-              err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                 _("Multiple revision arguments encountered; "
-                   "try '-r N:M' instead of '-r N -r M'"));
-              return EXIT_ERROR(err);
+              return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                        _("Multiple revision arguments encountered; "
+                          "try '-r N:M' instead of '-r N -r M'"));
             }
           if (svn_opt_parse_revision(&(opt_state.start_revision),
                                      &(opt_state.end_revision),
                                      opt_arg, pool) != 0)
             {
-              err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg,
-                                            pool);
+              SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
 
-              if (! err)
-                err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+              return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                         _("Syntax error in revision argument '%s'"),
                         utf8_opt_arg);
-              return EXIT_ERROR(err);
             }
         }
         break;
@@ -2247,8 +2235,8 @@ sub_main(int argc, const char *argv[], a
             = 0x100000 * apr_strtoi64(opt_arg, NULL, 0);
         break;
       case 'F':
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
-        SVN_INT_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
                                              utf8_opt_arg, pool));
         dash_F_arg = TRUE;
       case svnadmin__version:
@@ -2289,16 +2277,15 @@ sub_main(int argc, const char *argv[], a
 
           /* Parse the version string which carries our target
              compatibility. */
-          SVN_INT_ERR(svn_version__parse_version_string(&compatible_version,
+          SVN_ERR(svn_version__parse_version_string(&compatible_version,
                                                         opt_arg, pool));
 
           /* We can't create repository with a version older than 1.0.0.  */
           if (! svn_version__at_least(compatible_version, 1, 0, 0))
             {
-              err = svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-                                      _("Cannot create pre-1.0-compatible "
-                                        "repositories"));
-              return EXIT_ERROR(err);
+              return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
+                                       _("Cannot create pre-1.0-compatible "
+                                         "repositories"));
             }
 
           /* We can't create repository with a version newer than what
@@ -2308,12 +2295,11 @@ sub_main(int argc, const char *argv[], a
                                       compatible_version->minor,
                                       compatible_version->patch))
             {
-              err = svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-                                      _("Cannot guarantee compatibility "
-                                        "beyond the current running version "
-                                        "(%s)"),
-                                      SVN_VER_NUM );
-              return EXIT_ERROR(err);
+              return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
+                                       _("Cannot guarantee compatibility "
+                                         "beyond the current running version "
+                                         "(%s)"),
+                                       SVN_VER_NUM);
             }
 
           opt_state.compatible_version = compatible_version;
@@ -2323,10 +2309,10 @@ sub_main(int argc, const char *argv[], a
         opt_state.keep_going = TRUE;
         break;
       case svnadmin__fs_type:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.fs_type, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.fs_type, opt_arg, pool));
         break;
       case svnadmin__parent_dir:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.parent_dir, opt_arg,
+        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.parent_dir, opt_arg,
                                             pool));
         opt_state.parent_dir
           = svn_dirent_internal_style(opt_state.parent_dir, pool);
@@ -2359,7 +2345,7 @@ sub_main(int argc, const char *argv[], a
         opt_state.clean_logs = TRUE;
         break;
       case svnadmin__config_dir:
-        SVN_INT_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.config_dir =
             apr_pstrdup(pool, svn_dirent_canonicalize(utf8_opt_arg, pool));
         break;
@@ -2368,8 +2354,9 @@ sub_main(int argc, const char *argv[], a
         break;
       default:
         {
-          SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
-          return EXIT_FAILURE;
+          SVN_ERR(subcommand_help(NULL, NULL, pool));
+          *exit_code = EXIT_FAILURE;
+          return SVN_NO_ERROR;
         }
       }  /* close `switch' */
     }  /* close `while' */
@@ -2402,8 +2389,9 @@ sub_main(int argc, const char *argv[], a
             {
               svn_error_clear(svn_cmdline_fprintf(stderr, pool,
                                         _("subcommand argument required\n")));
-              SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
-              return EXIT_FAILURE;
+              SVN_ERR(subcommand_help(NULL, NULL, pool));
+              *exit_code = EXIT_FAILURE;
+              return SVN_NO_ERROR;
             }
         }
       else
@@ -2413,14 +2401,15 @@ sub_main(int argc, const char *argv[], a
           if (subcommand == NULL)
             {
               const char *first_arg_utf8;
-              SVN_INT_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
+              SVN_ERR(svn_utf_cstring_to_utf8(&first_arg_utf8,
                                                   first_arg, pool));
               svn_error_clear(
                 svn_cmdline_fprintf(stderr, pool,
                                     _("Unknown subcommand: '%s'\n"),
                                     first_arg_utf8));
-              SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
-              return EXIT_FAILURE;
+              SVN_ERR(subcommand_help(NULL, NULL, pool));
+              *exit_code = EXIT_FAILURE;
+              return SVN_NO_ERROR;
             }
         }
     }
@@ -2435,23 +2424,17 @@ sub_main(int argc, const char *argv[], a
 
       if (os->ind >= os->argc)
         {
-          err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                 _("Repository argument required"));
-          return EXIT_ERROR(err);
+          return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                  _("Repository argument required"));
         }
 
-      if ((err = svn_utf_cstring_to_utf8(&repos_path,
-                                         os->argv[os->ind++], pool)))
-        {
-          return EXIT_ERROR(err);
-        }
+      SVN_ERR(svn_utf_cstring_to_utf8(&repos_path, os->argv[os->ind++], pool));
 
       if (svn_path_is_url(repos_path))
         {
-          err = svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
-                                  _("'%s' is a URL when it should be a "
-                                    "local path"), repos_path);
-          return EXIT_ERROR(err);
+          return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+                                   _("'%s' is a URL when it should be a "
+                                     "local path"), repos_path);
         }
 
       opt_state.repository_path = svn_dirent_internal_style(repos_path, pool);
@@ -2477,13 +2460,14 @@ sub_main(int argc, const char *argv[], a
                                           pool);
           svn_opt_format_option(&optstr, badopt, FALSE, pool);
           if (subcommand->name[0] == '-')
-            SVN_INT_ERR(subcommand_help(NULL, NULL, pool));
+            SVN_ERR(subcommand_help(NULL, NULL, pool));
           else
             svn_error_clear(svn_cmdline_fprintf(stderr, pool
                             , _("Subcommand '%s' doesn't accept option '%s'\n"
                                 "Type 'svnadmin help %s' for usage.\n"),
                 subcommand->name, optstr, subcommand->name));
-          return EXIT_FAILURE;
+          *exit_code = EXIT_FAILURE;
+          return SVN_NO_ERROR;
         }
     }
 
@@ -2525,17 +2509,13 @@ sub_main(int argc, const char *argv[], a
           err = svn_error_quick_wrap(err,
                                      _("Try 'svnadmin help' for more info"));
         }
-      return EXIT_ERROR(err);
+      return err;
     }
   else
     {
       /* Ensure that everything is written to stdout, so the user will
          see any print errors. */
-      err = svn_cmdline_fflush(stdout);
-      if (err)
-        {
-          return EXIT_ERROR(err);
-        }
+      SVN_ERR(svn_cmdline_fflush(stdout));
       return EXIT_SUCCESS;
     }
 }
@@ -2545,6 +2525,7 @@ main(int argc, const char *argv[])
 {
   apr_pool_t *pool;
   int exit_code;
+  svn_error_t *err;
 
   /* Initialize the app. */
   if (svn_cmdline_init("svnadmin", stderr) != EXIT_SUCCESS)
@@ -2555,7 +2536,12 @@ main(int argc, const char *argv[])
    */
   pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
-  exit_code = sub_main(argc, argv, pool);
+  err = sub_main(&exit_code, argc, argv, pool);
+  if (err)
+    {
+      exit_code = EXIT_FAILURE;
+      svn_cmdline_handle_exit_error(err, NULL, "svnadmin: ");
+    }
 
   svn_pool_destroy(pool);
   return exit_code;



Mime
View raw message