You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2013/11/20 17:44:16 UTC
svn commit: r1543868 - in /subversion/trunk/subversion: svn/svn.c
svnadmin/svnadmin.c svnauth/svnauth.c svndumpfilter/svndumpfilter.c
svnlook/svnlook.c svnmucc/svnmucc.c svnrdump/svnrdump.c svnserve/svnserve.c
svnsync/svnsync.c svnversion/svnversion.c
Author: julianfoad
Date: Wed Nov 20 16:44:15 2013
New Revision: 1543868
URL: http://svn.apache.org/r1543868
Log:
In all of the command-line programs, flush stdout before exiting, in order
to report consistently if any information written to standard output is
being lost.
Standard output would be flushed on exit anyway, but this makes sure that
output is not silently lost if it fails. We will get both an error message
on stderr and a non-zero exit code.
See issue #780 "Check printf return values" and r1499470 "Also flush stdout
when returning an error".
A flush was present in some of the programs already, but was not guaranteed
to be executed in all cases, and only since r1499470 has an error-returning
code path been subject to a flush. This is now consistent across all the
programs, whether exiting successfully or with an error, except for a few
irregular exit paths that still remain, such as some calls to exit().
* subversion/svnadmin/svnadmin.c,
subversion/svnauth/svnauth.c,
subversion/svndumpfilter/svndumpfilter.c,
subversion/svnlook/svnlook.c,
subversion/svnmucc/svnmucc.c,
subversion/svnrdump/svnrdump.c,
subversion/svnserve/svnserve.c,
subversion/svn/svn.c,
subversion/svnsync/svnsync.c,
subversion/svnversion/svnversion.c
(sub_main): Remove the flush on the main successful code path for
svnadmin, svnauth, svndumpfilter, svnlook, svnmucc, svnversion; on the
main successful and main failure code paths for 'svn'.
(main): Flush here, instead, and report both the main error (if any) and
any flush error.
Modified:
subversion/trunk/subversion/svn/svn.c
subversion/trunk/subversion/svnadmin/svnadmin.c
subversion/trunk/subversion/svnauth/svnauth.c
subversion/trunk/subversion/svndumpfilter/svndumpfilter.c
subversion/trunk/subversion/svnlook/svnlook.c
subversion/trunk/subversion/svnmucc/svnmucc.c
subversion/trunk/subversion/svnrdump/svnrdump.c
subversion/trunk/subversion/svnserve/svnserve.c
subversion/trunk/subversion/svnsync/svnsync.c
subversion/trunk/subversion/svnversion/svnversion.c
Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Wed Nov 20 16:44:15 2013
@@ -2970,20 +2970,10 @@ sub_main(int *exit_code, int argc, const
"Subversion"));
}
- /* Ensure that stdout is flushed, so the user will see any write errors.
- This makes sure that output is not silently lost. */
- err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
-
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_ERR(svn_cmdline_fflush(stdout));
- return SVN_NO_ERROR;
- }
+ return SVN_NO_ERROR;
}
int
@@ -3003,6 +2993,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Wed Nov 20 16:44:15 2013
@@ -2511,13 +2511,8 @@ sub_main(int *exit_code, int argc, const
}
return err;
}
- else
- {
- /* Ensure that everything is written to stdout, so the user will
- see any print errors. */
- SVN_ERR(svn_cmdline_fflush(stdout));
- return EXIT_SUCCESS;
- }
+
+ return SVN_NO_ERROR;
}
int
@@ -2537,6 +2532,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnauth/svnauth.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnauth/svnauth.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnauth/svnauth.c (original)
+++ subversion/trunk/subversion/svnauth/svnauth.c Wed Nov 20 16:44:15 2013
@@ -1003,13 +1003,6 @@ sub_main(int *exit_code, int argc, const
}
return err;
}
- else
- {
- /* Ensure that everything is written to stdout, so the user will
- see any print errors. */
- SVN_ERR(svn_cmdline_fflush(stdout));
- return SVN_NO_ERROR;
- }
return SVN_NO_ERROR;
}
@@ -1031,6 +1024,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svndumpfilter/svndumpfilter.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svndumpfilter/svndumpfilter.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svndumpfilter/svndumpfilter.c (original)
+++ subversion/trunk/subversion/svndumpfilter/svndumpfilter.c Wed Nov 20 16:44:15 2013
@@ -1634,12 +1634,8 @@ sub_main(int *exit_code, int argc, const
}
return err;
}
- else
- {
- /* Flush stdout, making sure the user will see any print errors. */
- SVN_ERR(svn_cmdline_fflush(stdout));
- return SVN_NO_ERROR;
- }
+
+ return SVN_NO_ERROR;
}
int
@@ -1659,6 +1655,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnlook/svnlook.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnlook/svnlook.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnlook/svnlook.c (original)
+++ subversion/trunk/subversion/svnlook/svnlook.c Wed Nov 20 16:44:15 2013
@@ -2815,13 +2815,8 @@ sub_main(int *exit_code, int argc, const
}
return err;
}
- else
- {
- /* Ensure everything is printed on stdout, so the user sees any
- print errors. */
- SVN_ERR(svn_cmdline_fflush(stdout));
- return SVN_NO_ERROR;
- }
+
+ return SVN_NO_ERROR;
}
int
@@ -2841,6 +2836,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnmucc/svnmucc.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnmucc/svnmucc.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnmucc/svnmucc.c (original)
+++ subversion/trunk/subversion/svnmucc/svnmucc.c Wed Nov 20 16:44:15 2013
@@ -1436,9 +1436,6 @@ sub_main(int *exit_code, int argc, const
handle_error(err, pool);
}
- /* Ensure that stdout is flushed, so the user will see all results. */
- svn_error_clear(svn_cmdline_fflush(stdout));
-
return SVN_NO_ERROR;
}
@@ -1459,6 +1456,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnrdump/svnrdump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.c (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.c Wed Nov 20 16:44:15 2013
@@ -1167,6 +1167,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnserve/svnserve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/svnserve.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/svnserve.c (original)
+++ subversion/trunk/subversion/svnserve/svnserve.c Wed Nov 20 16:44:15 2013
@@ -1333,6 +1333,11 @@ main(int argc, const char *argv[])
pool = svn_pool_create(NULL);
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnsync/svnsync.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnsync/svnsync.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnsync/svnsync.c (original)
+++ subversion/trunk/subversion/svnsync/svnsync.c Wed Nov 20 16:44:15 2013
@@ -2293,6 +2293,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;
Modified: subversion/trunk/subversion/svnversion/svnversion.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnversion/svnversion.c?rev=1543868&r1=1543867&r2=1543868&view=diff
==============================================================================
--- subversion/trunk/subversion/svnversion/svnversion.c (original)
+++ subversion/trunk/subversion/svnversion/svnversion.c Wed Nov 20 16:44:15 2013
@@ -277,9 +277,6 @@ sub_main(int *exit_code, int argc, const
if (! no_newline)
SVN_ERR(svn_cmdline_fputs("\n", stdout, pool));
- /* Flush stdout to make sure that the user will see any printing errors. */
- SVN_ERR(svn_cmdline_fflush(stdout));
-
return SVN_NO_ERROR;
}
@@ -300,6 +297,11 @@ main(int argc, const char *argv[])
pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
err = sub_main(&exit_code, argc, argv, pool);
+
+ /* Flush stdout and report if it fails. It would be flushed on exit anyway
+ but this makes sure that output is not silently lost if it fails. */
+ err = svn_error_compose_create(err, svn_cmdline_fflush(stdout));
+
if (err)
{
exit_code = EXIT_FAILURE;