Misc cleanup.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 2 Dec 2014 11:00:28 +0000 (13:00 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 2 Dec 2014 11:00:28 +0000 (13:00 +0200)
Fix some misc issues pointed out by clang's static analyzer, scan-build.
Mostly dead assignments.

convert.c
dlg_specific.c
dlg_specific.h
execute.c
info.c
results.c

index 5070711b04137ab4cbd760c73228c39a3fa4b9d0..dd8dd6b1a7e013d89e43397877e4813741b57344 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -2762,7 +2762,6 @@ inolog("type=%d concur=%d\n", stmt->options.cursor_type, stmt->options.scroll_co
        goto cleanup;
    }
    SC_forget_unnamed(stmt);
-   buildPrepareStatement = FALSE;
 
    if (ci->disallow_premature)
        prepare_dummy_cursor = stmt->pre_executing;
@@ -5007,7 +5006,7 @@ mylog("%d-%d num=%s SQL_BIT=%d\n", to, from, num, SQL_BIT);
            SQLLEN  paramlen;
            int pidx;
 
-           for (prtlen = 0, mapptr = mapExpr; *mapptr; mapptr++)
+           for (mapptr = mapExpr; *mapptr; mapptr++)
            {
                if (*mapptr != '$')
                {
index 07eff5a480f6eba1aeffac9adc483e8591eb53bf..2555b17a339e8dd9555d4c61f58ddc7644a8e303 100644 (file)
@@ -453,7 +453,7 @@ inolog("hlen=%d", hlen);
        {
            char    abbrevmode[sizeof(ci->sslmode)];
 
-           olen = snprintf(&connect_string[hlen], nlen, ";"
+           (void) snprintf(&connect_string[hlen], nlen, ";"
                ABBR_SSLMODE "=%s", abbrev_sslmode(ci->sslmode, abbrevmode));
        }
        hlen = strlen(connect_string);
index 978f848ca87d7d42c549abeb088aafefb7fe13f0..723cc2862902271f649ed9c4ea32bb2e0a690523 100644 (file)
@@ -288,7 +288,6 @@ LRESULT CALLBACK manage_dsnProc(HWND hdlg,
               LPARAM lParam);
 #endif   /* WIN32 */
 
-void       updateGlobals(void);
 int        writeDriverCommoninfo(const char *fileName, const char *sectionName,
        const GLOBAL_VALUES *);
 void       writeDSNinfo(const ConnInfo *ci);
@@ -300,7 +299,6 @@ BOOL        copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *valu
 int    getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen);
 int    getLogDir(char *dir, int dirmax);
 int    setLogDir(const char *dir);
-int     changeDriverNameOfaDSN(const char *dsn, const char *driver_name, DWORD *errcode);
 UInt4  getExtraOptions(const ConnInfo *);
 BOOL   setExtraOptions(ConnInfo *, const char *str, const char *format);
 char   *extract_extra_attribute_setting(const pgNAME setting, const char *attr);
index 1b52b507b2a89503db3d20fada2bc92aa71f6845..444796112ec4181c081fcb2c98369c979125d21b 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -1070,7 +1070,7 @@ next_param_row:
            /* Check for data at execution parameters */
            if (apdopts->parameters[i].data_at_exec)
            {
-               mylog("The %dth parameter of %d-row is data at exec(%d)\n", i, current_row, *pcVal);
+               mylog("The %dth parameter of %d-row is data at exec(%d)\n", i, current_row, pcVal ? (*pcVal) : -1);
                if (stmt->data_at_exec < 0)
                    stmt->data_at_exec = 1;
                else
@@ -1479,7 +1479,7 @@ PGAPI_PutData(HSTMT hstmt,
    ParameterInfoClass *current_param;
    ParameterImplClass *current_iparam;
    PutDataClass    *current_pdata;
-   char       *buffer, *putbuf, *allocbuf = NULL;
+   char       *putbuf, *allocbuf = NULL;
    Int2        ctype;
    SQLLEN      putlen;
    BOOL        lenset = FALSE, handling_lo = FALSE;
@@ -1654,11 +1654,13 @@ PGAPI_PutData(HSTMT hstmt,
        }
        else
        {
-           buffer = current_pdata->EXEC_buffer;
            old_pos = *current_pdata->EXEC_used;
            if (putlen > 0)
            {
-               SQLLEN  used = *current_pdata->EXEC_used + putlen, allocsize;
+               SQLLEN  used = *current_pdata->EXEC_used + putlen;
+               SQLLEN allocsize;
+               char *buffer;
+
                for (allocsize = (1 << 4); allocsize <= used; allocsize <<= 1) ;
                mylog("        cbValue = %d, old_pos = %d, *used = %d\n", putlen, old_pos, used);
 
diff --git a/info.c b/info.c
index 951ee495a864cb94e46a693e069cfaa8914cc616..171bdd77450b2a0cdb272f0cdd1e1c26a448bb73 100644 (file)
--- a/info.c
+++ b/info.c
@@ -914,6 +914,7 @@ mylog("CONVERT_FUNCTIONS=" FORMAT_ULEN "\n", value);
        case SQL_INDEX_KEYWORDS:
            len = 4;
            value = SQL_IK_NONE;
+           break;
        case SQL_INFO_SCHEMA_VIEWS:
            len = 4;
            value = 0;
index 00521155d06478c7407b1e31ee50f8da45ff6e1a..49d8a6171b245a6b5bb5dcd57b34baf9d0a3b30c 100644 (file)
--- a/results.c
+++ b/results.c
@@ -2651,7 +2651,6 @@ static void UndoRollback(StatementClass *stmt, QResultClass *res, BOOL partial)
        rollbps = rollbp = res->rb_count;
        for (i = 0, doubtp = 0; i < res->rb_count; i++)
        {
-           index = rollback[i].index;
            keys.blocknum = rollback[i].blocknum;
            keys.offset = rollback[i].offset;
            texist = tupleExists(stmt, &keys);
@@ -3872,7 +3871,6 @@ irow_insert(RETCODE ret, StatementClass *stmt, StatementClass *istmt,
 
            if (0 != oid)
                poid = &oid;
-           qret = SQL_NO_DATA_FOUND;
 
            if (NULL != tres->backend_tuples &&
                1 == QR_get_num_cached_tuples(tres))