[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] libsvn_client: start using svn_io_file_close where applicable

From: Erik Huelsmann <e.huelsmann_at_gmx.net>
Date: 2003-11-06 21:02:01 CET

Below I attached a patch for libsvn_client to start using the
svn_io_file_close where applicable. There is one case in externals.c which discards the
error output. I did not convert that use to svn_io_file_close, since it would no
longer be possible to ignore the output.

Other libraries will follow in other patches. Also, this patch means that
the other patch (issue #897) is invalidated. I will resubmit that one as soon
as we agree on this patch.

bye,

Erik.
a copy of the patch can be found at

http://encorps.dnsalias.com/patches/libsvn_client-apr_-to-svn_io_file_close.patch

Log:
[[[
Change call sequence apr_file_close, svn_error_create to
SVN_ERR (svn_io_file_close ..).

* subverstion/libsvn_client/blame.c
* subverstion/libsvn_client/commit.c
* subverstion/libsvn_client/copy.c
* subverstion/libsvn_client/diff.c
* subverstion/libsvn_client/export.c
* subverstion/libsvn_client/repos_diff.c

]]]

Index: subversion/libsvn_client/repos_diff.c
===================================================================
--- subversion/libsvn_client/repos_diff.c (revision 7654)
+++ subversion/libsvn_client/repos_diff.c (working copy)
@@ -314,7 +314,6 @@
 static svn_error_t *
 get_file_from_ra (struct file_baton *b)
 {
- apr_status_t status;
   apr_file_t *file;
   svn_stream_t *fstream;
   const char *temp_dir;
@@ -334,12 +333,8 @@
                                             fstream, NULL,
                                             &(b->pristine_props),
                                             b->pool));
+ SVN_ERR (svn_io_file_close (file, b->pool));
 
- status = apr_file_close (file);
- if (status)
- return svn_error_createf (status, NULL, "failed to close file '%s'",
- b->path_start_revision);
-
   return SVN_NO_ERROR;
 }
 
@@ -364,7 +359,6 @@
 create_empty_file (const char **empty_file,
                    apr_pool_t *pool)
 {
- apr_status_t status;
   apr_file_t *file;
   const char *temp_dir;
 
@@ -372,11 +366,8 @@
   SVN_ERR (svn_io_open_unique_file (&file, empty_file,
                                     svn_path_join (temp_dir, "tmp", pool),
                                     "", FALSE, pool));
+ SVN_ERR (svn_io_file_close (file, pool));
 
- status = apr_file_close (file);
- if (status)
- return svn_error_createf (status, NULL,
- "failed to create empty file '%s'",
*empty_file);
   return SVN_NO_ERROR;
 }
 
@@ -686,19 +677,8 @@
 
   if (!window)
     {
- apr_status_t status;
-
- status = apr_file_close (b->file_start_revision);
- if (status)
- return svn_error_createf (status, NULL,
- "failed to close file '%s'",
- b->path_start_revision);
-
- status = apr_file_close (b->file_end_revision);
- if (status)
- return svn_error_createf (status, NULL,
- "failed to close file '%s'",
- b->path_end_revision);
+ SVN_ERR (svn_io_file_close (b->file_start_revision, b->pool));
+ SVN_ERR (svn_io_file_close (b->file_end_revision, b->pool));
     }
 
   return SVN_NO_ERROR;
Index: subversion/libsvn_client/export.c
===================================================================
--- subversion/libsvn_client/export.c (revision 7654)
+++ subversion/libsvn_client/export.c (working copy)
@@ -505,16 +505,12 @@
             apr_pool_t *pool)
 {
   struct file_baton *fb = file_baton;
- apr_status_t apr_err;
 
   /* Was a txdelta even sent? */
   if (! fb->tmppath)
     return SVN_NO_ERROR;
 
- apr_err = apr_file_close (fb->tmp_file);
- if (apr_err)
- return svn_error_createf (apr_err, NULL, "error closing file '%s'",
- fb->tmppath);
+ SVN_ERR (svn_io_file_close (fb->tmp_file, fb->pool));
 
   if (text_checksum)
     {
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 7654)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -1300,7 +1300,6 @@
   svn_ra_plugin_t *ra_lib;
   void *session;
   apr_file_t *fp;
- apr_status_t status;
 
   SVN_ERR (svn_ra_get_ra_library (&ra_lib, ra_baton, url, pool));
   SVN_ERR (svn_client__open_ra_session (&session, ra_lib, url, auth_dir,
@@ -1314,9 +1313,7 @@
   SVN_ERR (ra_lib->get_file (session, "", *rev,
                              svn_stream_from_aprfile (fp, pool),
                              NULL, props, pool));
- status = apr_file_close (fp);
- if (status)
- return svn_error_createf (status, NULL, "failed to close '%s'",
*filename);
+ SVN_ERR (svn_io_file_close (fp, pool));
 
   return SVN_NO_ERROR;
 }
Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c (revision 7654)
+++ subversion/libsvn_client/copy.c (working copy)
@@ -949,7 +949,6 @@
       svn_revnum_t real_rev;
       const char *new_text_path;
       apr_hash_t *new_props;
- apr_status_t status;
 
       SVN_ERR (svn_io_open_unique_file
                (&fp, &new_text_path, dst_path, ".tmp", FALSE, pool));
@@ -958,12 +957,8 @@
       SVN_ERR (ra_lib->get_file
                (sess, "", src_revnum, fstream, &real_rev, &new_props,
pool));
       svn_stream_close (fstream);
+ SVN_ERR (svn_io_file_close (fp, pool));
 
- status = apr_file_close (fp);
- if (status)
- return svn_error_createf
- (status, NULL, "failed to close file '%s'", dst_path);
-
       /* If SRC_REVNUM is invalid (HEAD), then REAL_REV is now the
          revision that was actually retrieved. This is the value we
          want to use as 'copyfrom_rev' below. */
Index: subversion/libsvn_client/blame.c
===================================================================
--- subversion/libsvn_client/blame.c (revision 7654)
+++ subversion/libsvn_client/blame.c (working copy)
@@ -448,10 +448,8 @@
       SVN_ERR (ra_lib->get_file (session, rev->path + 1, rev->revision,
                                  stream, NULL, NULL, iterpool));
       SVN_ERR (svn_stream_close (stream));
- apr_err = apr_file_close (file);
- if (apr_err != APR_SUCCESS)
- return svn_error_createf (apr_err, NULL, "error closing %s",
- rev->path);
+ SVN_ERR (svn_io_file_close (file, iterpool));
+
       if (last)
         {
           svn_diff_t *diff;
@@ -493,9 +491,7 @@
     }
 
   SVN_ERR (svn_stream_close (stream));
- apr_err = apr_file_close (file);
- if (apr_err != APR_SUCCESS)
- return svn_error_createf (apr_err, NULL, "error closing %s", last);
+ SVN_ERR (svn_io_file_close (file, pool));
   apr_err = apr_file_remove (last, pool);
   if (apr_err != APR_SUCCESS)
     return svn_error_createf (apr_err, NULL, "error removing %s", last);
Index: subversion/libsvn_client/commit.c
===================================================================
--- subversion/libsvn_client/commit.c (revision 7654)
+++ subversion/libsvn_client/commit.c (working copy)
@@ -59,7 +59,6 @@
   svn_txdelta_window_handler_t handler;
   void *handler_baton;
   apr_file_t *f = NULL;
- apr_status_t apr_err;
 
   /* Get an apr file for PATH. */
   SVN_ERR (svn_io_file_open (&f, path, APR_READ, APR_OS_DEFAULT, pool));
@@ -76,10 +75,7 @@
                                     digest, pool));
 
   /* Close the file. */
- apr_err = apr_file_close (f);
- if (apr_err)
- return svn_error_createf
- (apr_err, NULL, "error closing '%s'", path);
+ SVN_ERR (svn_io_file_close (f, pool));
 
   return SVN_NO_ERROR;
 }

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse für Mail, Message, More! +++
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Nov 6 21:02:48 2003

This is an archived mail posted to the Subversion Dev mailing list.