Author: turnstep
Date: Sat Feb 16 15:31:58 2008
New Revision: 10747

Modified:
   DBD-Pg/trunk/Makefile.PL
   DBD-Pg/trunk/README.dev
   DBD-Pg/trunk/dbdimp.c
   DBD-Pg/trunk/dbdimp.h

Log:
Tweaks inspired by splint.


Modified: DBD-Pg/trunk/Makefile.PL
==============================================================================
--- DBD-Pg/trunk/Makefile.PL    (original)
+++ DBD-Pg/trunk/Makefile.PL    Sat Feb 16 15:31:58 2008
@@ -200,6 +200,8 @@
 
 SPLINTFLAGS =            \
   -message-stream-stdout \
+  -linelen 90            \
+  -boolops               \
   -tmpdir $(SPLINT_TMP)  \
   +posixstrictlib        \
   +ignoresigns           \

Modified: DBD-Pg/trunk/README.dev
==============================================================================
--- DBD-Pg/trunk/README.dev     (original)
+++ DBD-Pg/trunk/README.dev     Sat Feb 16 15:31:58 2008
@@ -323,7 +323,8 @@
 
 1) Getting it to work in the first place. As the Makefile.PL section says, you 
need at least 
 version 3.1.2. You also need to include all the relevant files, which 
Makefile.PL should do 
-for you.
+for you. Note that 'make splint' expects the TMP environment variable to be 
set to a writeable 
+directory.
 
 2) Limiting the amount of results. splint is extremely verbose, so one must 
usually limit 
 what sort of things are returned. Again, the Makefile.PL has a partial list.

Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c       (original)
+++ DBD-Pg/trunk/dbdimp.c       Sat Feb 16 15:31:58 2008
@@ -91,8 +91,6 @@
 static int pg_db_start_txn (SV *dbh, imp_dbh_t *imp_dbh);
 static int handle_old_async(SV * handle, imp_dbh_t * imp_dbh, int asyncflag);
 
-DBISTATE_DECLARE;
-
 /* ================================================================== */
 void dbd_init (dbistate_t *dbistate)
 {
@@ -740,7 +738,9 @@
                if (strEQ("pg_errorlevel", key)) {
                        /* Introduced in 7.4 servers */
                        if (imp_dbh->pg_protocol >= 3) {
-                               newval = SvIV(valuesv);
+                               if (SvOK(valuesv)) {
+                                       newval = (unsigned)SvIV(valuesv);
+                               }
                                /* Default to "1" if an invalid value is passed 
in */
                                imp_dbh->pg_errorlevel = 0==newval ? 0 : 
2==newval ? 2 : 1;
                                (void)PQsetErrorVerbosity(imp_dbh->conn, 
imp_dbh->pg_errorlevel); /* pre-7.4 does nothing */
@@ -781,7 +781,9 @@
                if (strEQ("pg_server_prepare", key)) {
                        /* No point changing this if the server does not 
support it */
                        if (imp_dbh->pg_protocol >= 3) {
-                               newval = SvIV(valuesv);
+                               if (SvOK(valuesv)) {
+                                       newval = (unsigned)SvIV(valuesv);
+                               }
                                /* Default to "2" if an invalid value is passed 
in */
                                imp_dbh->server_prepare = 0==newval ? 0 : 
1==newval ? 1 : 2;
                        }
@@ -1194,7 +1196,7 @@
 
        status = PQconsumeInput(imp_dbh->conn);
        if (0 == status) { 
-               pg_error(dbh, PQstatus(imp_dbh->conn), 
PQerrorMessage(imp_dbh->conn));
+               pg_error(dbh, PGRES_FATAL_ERROR, PQerrorMessage(imp_dbh->conn));
                return &sv_undef;
        }
 
@@ -1298,10 +1300,10 @@
                imp_sth->firstword[newsize] = '\0';
 
                /* Note whether this is preparable DML */
-               if (0==strcasecmp(imp_sth->firstword, "SELECT") ||
-                       0==strcasecmp(imp_sth->firstword, "INSERT") ||
-                       0==strcasecmp(imp_sth->firstword, "UPDATE") ||
-                       0==strcasecmp(imp_sth->firstword, "DELETE")
+               if (0 == strcasecmp(imp_sth->firstword, "SELECT") ||
+                       0 == strcasecmp(imp_sth->firstword, "INSERT") ||
+                       0 == strcasecmp(imp_sth->firstword, "UPDATE") ||
+                       0 == strcasecmp(imp_sth->firstword, "DELETE")
                        ) {
                        imp_sth->is_dml = DBDPG_TRUE;
                }
@@ -1685,6 +1687,7 @@
                                if (0==strncmp(thisph->fooname, 
statement-sectionsize, sectionsize)) {
                                        newseg->placeholder = xint;
                                        newseg->ph = thisph;
+                                       Safefree(thisph);
                                        break;
                                }
                        }
@@ -2317,7 +2320,7 @@
 } /* end of pg_stringify_array */
 
 /* ================================================================== */
-SV * pg_destringify_array(imp_dbh_t *imp_dbh, unsigned char * input, 
sql_type_info_t * coltype) {
+static SV * pg_destringify_array(imp_dbh_t *imp_dbh, unsigned char * input, 
sql_type_info_t * coltype) {
 
        AV*    av;              /* The main array we are returning a reference 
to */
        AV*    currentav;       /* The current array level */
@@ -2375,7 +2378,7 @@
                else if ('}' == *input) {
                }
                else if ('"' == *input) {
-                       in_quote = 1;
+                       in_quote = (bool)1;
                }
                else {
                        string[section_size++] = *input;
@@ -4062,7 +4065,7 @@
          return -2;
        }
 
-       return ! PQisBusy(imp_dbh->conn);
+       return PQisBusy(imp_dbh->conn) ? 0 : 1;
 
 } /* end of dbdpg_ready */
 

Modified: DBD-Pg/trunk/dbdimp.h
==============================================================================
--- DBD-Pg/trunk/dbdimp.h       (original)
+++ DBD-Pg/trunk/dbdimp.h       Sat Feb 16 15:31:58 2008
@@ -140,7 +140,7 @@
 int dbdpg_cancel (SV *h, imp_dbh_t *imp_dbh);
 int dbdpg_cancel_sth (SV *sth, imp_sth_t *imp_sth);
 SV * pg_stringify_array(SV * input, const char * array_delim, int 
server_version);
-SV * pg_destringify_array(imp_dbh_t *imp_dbh, unsigned char * input, 
sql_type_info_t * coltype);
+static SV * pg_destringify_array(imp_dbh_t *imp_dbh, unsigned char * input, 
sql_type_info_t * coltype);
 
 /* end of dbdimp.h */
 

Reply via email to