Bug 1641226 - #define GF_SQL_COMPACT_DEF GF_SQL_COMPACT_INCR makes lots of the code unneeded
Summary: #define GF_SQL_COMPACT_DEF GF_SQL_COMPACT_INCR makes lots of the code unneeded
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: unclassified
Version: mainline
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Iraj Jamali
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-10-20 04:38 UTC by Yaniv Kaul
Modified: 2019-03-07 08:08 UTC (History)
4 users (show)

Fixed In Version: glusterfs-6.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-03-07 08:08:16 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Yaniv Kaul 2018-10-20 04:38:20 UTC
Description of problem:
In gfdb_sqlite3.h, there's the definition:
#define GF_SQL_COMPACT_DEF GF_SQL_COMPACT_INCR

This makes lot of other code, which compares GF_SQL_COMPACT_DEF to other values, quite useless.
For example, in gfdb_sqlite3.c, the whole switch is useless:
            ret = 0;
            switch (GF_SQL_COMPACT_DEF) {
                case GF_SQL_COMPACT_FULL:
                    ret = gf_sqlite3_set_pragma(db_conn, "auto_vacuum",
                                                GF_SQL_AV_FULL);
                    break;
                case GF_SQL_COMPACT_INCR:
                    ret = gf_sqlite3_set_pragma(db_conn, "auto_vacuum",
                                                GF_SQL_AV_INCR);
                    break;
                case GF_SQL_COMPACT_MANUAL:
                    changing_pragma = _gf_false;
                    break;
                default:
                    ret = -1;
                    gf_msg(GFDB_STR_SQLITE3, GF_LOG_ERROR, 0,
                           LG_MSG_COMPACT_FAILED, "VACUUM type undefined");
                    goto out;
                    break;
            }

It's quite clear where it'll go. The rest is dead code. As such, the compiler complains that the initial 'ret = 0' is not needed - this value set to 'ret' is never read - which is true, as the switch goes to:
ret = gf_sqlite3_set_pragma(db_conn, "auto_vacuum",
                                                GF_SQL_AV_INCR);

Comment 3 Worker Ant 2018-10-26 11:53:50 UTC
REVIEW: https://review.gluster.org/21500 (libglusterfs: Cleanup dead code) posted (#1) for review on master by Iraj Jamali

Comment 4 Amar Tumballi 2019-03-07 08:08:16 UTC
Also note that, this part of the code itself is completely removed now.


Note You need to log in before you can comment on or make changes to this bug.