[PATCH] Silence GCC warnings, fix build - Mailing list pgsql-odbc

From Pavel Raiskup
Subject [PATCH] Silence GCC warnings, fix build
Date
Msg-id 1386349717-2942-1-git-send-email-praiskup@redhat.com
Whole thread Raw
Responses Re: [PATCH] Silence GCC warnings, fix build  (Pavel Raiskup <praiskup@redhat.com>)
List pgsql-odbc
* Makefile.am: Add mylog.h into dependand sources.
* convert.c (mylog): Retype sprintf() parameters.
* specific.c (getCommonDefaults): Don't check array for NULL.
* psqlodbc.c (copy_globals): Initialize the 'to' structure
completely.
---
 Makefile.am    |  2 +-
 convert.c      | 31 ++++++++++++++++++++-----------
 dlg_specific.c |  2 +-
 psqlodbc.c     |  2 +-
 4 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dfd36ab..f9820a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,7 +32,7 @@ psqlodbca_la_SOURCES = \
     descriptor.h dlg_specific.h environ.h \
     lobj.h md5.h misc.h multibyte.h pgapifunc.h pgtypes.h \
     psqlodbc.h qresult.h resource.h socket.h statement.h tuple.h \
-    version.h loadlib.h pgenlist.h
+    version.h loadlib.h pgenlist.h mylog.h

 psqlodbcw_la_SOURCES = $(psqlodbca_la_SOURCES) \
     odbcapi30w.c odbcapiw.c win_unicode.c
diff --git a/convert.c b/convert.c
index f647f9c..a7136ce 100644
--- a/convert.c
+++ b/convert.c
@@ -4376,27 +4376,36 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used);
                 break;
         case SQL_C_INTERVAL_YEAR:
             ivsign = ivstruct->interval_sign ? "-" : "";
-            sprintf(param_string, "%s%d years", ivsign, ivstruct->intval.year_month.year);
+            sprintf(param_string, "%s%lu years", ivsign,
+                    (unsigned long)ivstruct->intval.year_month.year);
             break;
         case SQL_C_INTERVAL_MONTH:
         case SQL_C_INTERVAL_YEAR_TO_MONTH:
             ivsign = ivstruct->interval_sign ? "-" : "";
-            sprintf(param_string, "%s%d years %s%d mons", ivsign, ivstruct->intval.year_month.year, ivsign,
ivstruct->intval.year_month.month);
+            sprintf(param_string, "%s%lu years %s%lu mons", ivsign,
+                    (unsigned long)ivstruct->intval.year_month.year, ivsign,
+                    (unsigned long)(ivstruct->intval.year_month.month));
             break;
         case SQL_C_INTERVAL_DAY:
             ivsign = ivstruct->interval_sign ? "-" : "";
-            sprintf(param_string, "%s%d days", ivsign, ivstruct->intval.day_second.day);
+            sprintf(param_string, "%s%lu days", ivsign,
+                    (unsigned long)ivstruct->intval.day_second.day);
             break;
         case SQL_C_INTERVAL_HOUR:
         case SQL_C_INTERVAL_DAY_TO_HOUR:
             ivsign = ivstruct->interval_sign ? "-" : "";
-            sprintf(param_string, "%s%d days %s%02d:00:00", ivsign, ivstruct->intval.day_second.day, ivsign,
ivstruct->intval.day_second.hour);
+            sprintf(param_string, "%s%lu days %s%02lu:00:00", ivsign,
+                    (unsigned long)ivstruct->intval.day_second.day, ivsign,
+                    (unsigned long)ivstruct->intval.day_second.hour);
             break;
         case SQL_C_INTERVAL_MINUTE:
         case SQL_C_INTERVAL_HOUR_TO_MINUTE:
         case SQL_C_INTERVAL_DAY_TO_MINUTE:
             ivsign = ivstruct->interval_sign ? "-" : "";
-            sprintf(param_string, "%s%d days %s%02d:%02d:00", ivsign, ivstruct->intval.day_second.day, ivsign,
ivstruct->intval.day_second.hour,ivstruct->intval.day_second.minute); 
+            sprintf(param_string, "%s%lu days %s%02lu:%02lu:00",
+                    ivsign, (unsigned long)ivstruct->intval.day_second.day,
+                    ivsign, (unsigned long)ivstruct->intval.day_second.hour,
+                    (unsigned long)ivstruct->intval.day_second.minute);
             break;

         case SQL_C_INTERVAL_SECOND:
@@ -4404,11 +4413,11 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used);
         case SQL_C_INTERVAL_HOUR_TO_SECOND:
         case SQL_C_INTERVAL_MINUTE_TO_SECOND:
             ivsign = ivstruct->interval_sign ? "-" : "";
-            sprintf(param_string, "%s%d days %s%02d:%02d:%02d",
-                ivsign, ivstruct->intval.day_second.day,
-                ivsign, ivstruct->intval.day_second.hour,
-                ivstruct->intval.day_second.minute,
-                ivstruct->intval.day_second.second);
+            sprintf(param_string, "%s%lu days %s%02lu:%02lu:%02lu",
+                ivsign, (unsigned long)ivstruct->intval.day_second.day,
+                ivsign, (unsigned long)ivstruct->intval.day_second.hour,
+                (unsigned long)ivstruct->intval.day_second.minute,
+                (unsigned long)ivstruct->intval.day_second.second);
             if (ivstruct->intval.day_second.fraction > 0)
             {
                 int fraction = ivstruct->intval.day_second.fraction, prec = apara->precision;
@@ -4428,7 +4437,7 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used);
             SQLGUID *g = (SQLGUID *) buffer;
             snprintf (param_string, sizeof(param_string),
                 "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
-                g->Data1,
+                (unsigned long)g->Data1,
                 g->Data2, g->Data3,
                 g->Data4[0], g->Data4[1], g->Data4[2], g->Data4[3],
                 g->Data4[4], g->Data4[5], g->Data4[6], g->Data4[7]);
diff --git a/dlg_specific.c b/dlg_specific.c
index 53edd6d..fc06fdf 100644
--- a/dlg_specific.c
+++ b/dlg_specific.c
@@ -1435,7 +1435,7 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
         SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
             conn_settings, sizeof(conn_settings), filename);
         if ('\0' != conn_settings[0])
-            STR_TO_NAME(comval->conn_settings, conn_settings);
+            STRX_TO_NAME(comval->conn_settings, (char *)conn_settings);

         /* Default state for future DSN's Readonly attribute */
         SQLGetPrivateProfileString(section, INI_READONLY, "",
diff --git a/psqlodbc.c b/psqlodbc.c
index 09bd563..349d4e1 100644
--- a/psqlodbc.c
+++ b/psqlodbc.c
@@ -102,7 +102,7 @@ int    initialize_global_cs(void)

 void    copy_globals(GLOBAL_VALUES *to, const GLOBAL_VALUES *from)
 {
-    memset(to, 0, sizeof(to));
+    memset(to, 0, sizeof(*to));
     /***
     memcpy(to, from, sizeof(GLOBAL_VALUES));
     SET_NAME_DIRECTLY(to->drivername, NULL);
--
1.8.4.2



pgsql-odbc by date:

Previous
From: Pavel Raiskup
Date:
Subject: use inet_pton() instead of inet_addr() for ipv4/6
Next
From: Pavel Raiskup
Date:
Subject: Problems with linking against PostgreSQL 8.4