Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 386D72009FB for ; Fri, 6 May 2016 14:48:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3705D160A0C; Fri, 6 May 2016 12:48:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5AA141609F6 for ; Fri, 6 May 2016 14:48:32 +0200 (CEST) Received: (qmail 40666 invoked by uid 500); 6 May 2016 12:48:31 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 40656 invoked by uid 99); 6 May 2016 12:48:31 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 May 2016 12:48:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2B266CB5AA for ; Fri, 6 May 2016 12:48:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.279 X-Spam-Level: X-Spam-Status: No, score=-0.279 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.079] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id fLw7bVJnviPq for ; Fri, 6 May 2016 12:48:30 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id CA57860D32 for ; Fri, 6 May 2016 12:48:29 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B1BA8E009C for ; Fri, 6 May 2016 12:48:28 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id D65443A019E for ; Fri, 6 May 2016 12:48:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1742540 - in /subversion/trunk/subversion: include/private/svn_sqlite.h libsvn_fs_fs/rep-cache.c libsvn_subr/sqlite.c Date: Fri, 06 May 2016 12:48:27 -0000 To: commits@subversion.apache.org From: kotkov@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160506124827.D65443A019E@svn01-us-west.apache.org> archived-at: Fri, 06 May 2016 12:48:33 -0000 Author: kotkov Date: Fri May 6 12:48:27 2016 New Revision: 1742540 URL: http://svn.apache.org/viewvc?rev=1742540&view=rev Log: Remove code duplication by factoring out a common macro. * subversion/include/private/svn_sqlite.h (SVN_SQLITE__ERR_CLOSE): New, factored out from ... * subversion/libsvn_subr/sqlite.c (SVN_ERR_CLOSE): ...here. (svn_sqlite__open): Use the new macro. * subversion/libsvn_fs_fs/rep-cache.c (SVN_ERR_CLOSE): Remove. (open_rep_cache): Use the new macro. Modified: subversion/trunk/subversion/include/private/svn_sqlite.h subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c subversion/trunk/subversion/libsvn_subr/sqlite.c Modified: subversion/trunk/subversion/include/private/svn_sqlite.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_sqlite.h?rev=1742540&r1=1742539&r2=1742540&view=diff ============================================================================== --- subversion/trunk/subversion/include/private/svn_sqlite.h (original) +++ subversion/trunk/subversion/include/private/svn_sqlite.h Fri May 6 12:48:27 2016 @@ -555,6 +555,15 @@ svn_sqlite__hotcopy(const char *src_path const char *dst_path, apr_pool_t *scratch_pool); +/* Evaluate the expression EXPR. If any error is returned, close + * the connection in DB. */ +#define SVN_SQLITE__ERR_CLOSE(expr, db) do \ +{ \ + svn_error_t *svn__err = (expr); \ + if (svn__err) \ + return svn_error_compose_create(svn__err, svn_sqlite__close(db)); \ +} while (0) + #ifdef __cplusplus } #endif /* __cplusplus */ Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c?rev=1742540&r1=1742539&r2=1742540&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c (original) +++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c Fri May 6 12:48:27 2016 @@ -51,13 +51,6 @@ path_rep_cache_db(const char *fs_path, return svn_dirent_join(fs_path, REP_CACHE_DB_NAME, result_pool); } -#define SVN_ERR_CLOSE(x, db) do \ -{ \ - svn_error_t *svn__err = (x); \ - if (svn__err) \ - return svn_error_compose_create(svn__err, svn_sqlite__close(db)); \ -} while (0) - /** Library-private API's. **/ @@ -107,12 +100,15 @@ open_rep_cache(void *baton, 0, NULL, 0, fs->pool, pool)); - SVN_ERR_CLOSE(svn_sqlite__read_schema_version(&version, sdb, pool), sdb); + SVN_SQLITE__ERR_CLOSE(svn_sqlite__read_schema_version(&version, sdb, pool), + sdb); if (version < REP_CACHE_SCHEMA_FORMAT) { /* Must be 0 -- an uninitialized (no schema) database. Create the schema. Results in schema version of 1. */ - SVN_ERR_CLOSE(svn_sqlite__exec_statements(sdb, STMT_CREATE_SCHEMA), sdb); + SVN_SQLITE__ERR_CLOSE(svn_sqlite__exec_statements(sdb, + STMT_CREATE_SCHEMA), + sdb); } /* This is used as a flag that the database is available so don't Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1742540&r1=1742539&r2=1742540&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/sqlite.c (original) +++ subversion/trunk/subversion/libsvn_subr/sqlite.c Fri May 6 12:48:27 2016 @@ -213,13 +213,6 @@ struct svn_sqlite__value_t sqlite_err__temp, msg); \ } while (0) -#define SVN_ERR_CLOSE(x, db) do \ -{ \ - svn_error_t *svn__err = (x); \ - if (svn__err) \ - return svn_error_compose_create(svn__err, svn_sqlite__close(db)); \ -} while (0) - /* Time (in milliseconds) to wait for sqlite locks before giving up. */ #define BUSY_TIMEOUT 10000 @@ -1141,7 +1134,7 @@ svn_sqlite__open(svn_sqlite__db_t **db, sqlite3_profile((*db)->db3, sqlite_profiler, (*db)->db3); #endif - SVN_ERR_CLOSE(exec_sql(*db, + SVN_SQLITE__ERR_CLOSE(exec_sql(*db, /* The default behavior of the LIKE operator is to ignore case for ASCII characters. Hence, by default 'a' LIKE 'A' is true. The case_sensitive_like pragma installs a new application- @@ -1180,8 +1173,8 @@ svn_sqlite__open(svn_sqlite__db_t **db, /* When running in debug mode, enable the checking of foreign key constraints. This has possible performance implications, so we don't bother to do it for production...for now. */ - SVN_ERR_CLOSE(exec_sql(*db, "PRAGMA foreign_keys=ON;"), - *db); + SVN_SQLITE__ERR_CLOSE(exec_sql(*db, "PRAGMA foreign_keys=ON;"), + *db); #endif #ifdef SVN_SQLITE_REVERSE_UNORDERED_SELECTS @@ -1189,8 +1182,8 @@ svn_sqlite__open(svn_sqlite__db_t **db, clause to emit their results in the reverse order of what they normally would. This can help detecting invalid assumptions about the result order.*/ - SVN_ERR_CLOSE(exec_sql(*db, "PRAGMA reverse_unordered_selects=ON;"), - *db); + SVN_SQLITE__ERR_CLOSE(exec_sql(*db, "PRAGMA reverse_unordered_selects=ON;"), + *db); #endif /* Store temporary tables in RAM instead of in temporary files, but don't