Bug 1641226

Summary: #define GF_SQL_COMPACT_DEF GF_SQL_COMPACT_INCR makes lots of the code unneeded
Product: [Community] GlusterFS Reporter: Yaniv Kaul <ykaul>
Component: unclassifiedAssignee: Iraj Jamali <ijamali>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: mainlineCC: atumball, bugs, ijamali, ykaul
Target Milestone: ---Keywords: CodeChange
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-6.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-07 08:08:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.