[patch] Fix compiler warnings on 64 bit processor.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] Fix compiler warnings on 64 bit processor.

Karl Hegbloom
Here's a ChangeLog entry and diff against today's CVS that suppresses
the compiler warnings wrt casting from gpointer to int when a pointer is
64 bits and an int is only 32.  See the Glib manual, under type
conversion macros for documentation of the macros used in this patch.

--
Karl Hegbloom <[hidden email]>

2005-11-01  Karl Hegbloom  <[hidden email]>

        * src/backend/postgres/upgrade.c (get_iguid_cb): Use glib macros
          for type conversions to suppress compiler warnings on amd64.
          (put_iguid_in_tables): ditto

        * src/backend/postgres/price.c (commodity_mark_cb): Use glib
          macros for type conversions to suppress compiler warnings on
          amd64.

        * src/backend/postgres/base-autogen.c (pgendAccountCompareVersion):
          Use glib macros for type conversions to suppress compiler
          warnings on amd64.
          (pgendTransactionCompareVersion): ditto
          (pgendPriceCompareVersion): ditto
          (pgendAccountGetDeletedVersion): ditto
          (pgendBookGetDeletedVersion): ditto
          (pgendTransactionGetDeletedVersion): ditto
          (pgendPriceGetDeletedVersion): ditto

        * src/backend/postgres/kvp-sql.c (ival_cb): Use glib macros for
          type conversions to suppress compiler warnings on amd64.

        * src/backend/postgres/putil.h (COMP_INT64): Cast fun to long long
          int to suppress compiler warning on amd64.


Index: src/backend/postgres/kvp-sql.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/kvp-sql.c,v
retrieving revision 1.13.2.5
diff -u -r1.13.2.5 kvp-sql.c
--- src/backend/postgres/kvp-sql.c 13 Oct 2005 12:28:06 -0000 1.13.2.5
+++ src/backend/postgres/kvp-sql.c 1 Nov 2005 20:43:34 -0000
@@ -121,7 +121,7 @@
 ival_cb (PGBackend *be, PGresult *result, int j, gpointer data)
 {
   int ival = atoi (DB_GET_VAL ("ipath", 0));
-  return (gpointer) ival;
+  return GINT_TO_POINTER(ival);
 }
 
 
@@ -143,7 +143,7 @@
    p = stpcpy (p, "';");
 
    SEND_QUERY (be,be->buff, 0);
-   ival = (int) pgendGetResults (be, ival_cb, (gpointer) 0);
+   ival = GPOINTER_TO_INT(pgendGetResults (be, ival_cb, (gpointer) 0));
    if (ival) return ival;
 
    /* Else, this guid has never been stored before.
Index: src/backend/postgres/price.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/price.c,v
retrieving revision 1.17.4.8
diff -u -r1.17.4.8 price.c
--- src/backend/postgres/price.c 20 Oct 2005 14:48:11 -0000 1.17.4.8
+++ src/backend/postgres/price.c 1 Nov 2005 20:43:34 -0000
@@ -197,7 +197,7 @@
 static gboolean
 commodity_mark_cb (gnc_commodity *cm, gpointer user_data)
 {
-   gint32 v = ((gint32) user_data) & 0xffff;
+   gint32 v = ((gint32) GPOINTER_TO_INT(user_data)) & 0xffff;
    gnc_commodity_set_mark (cm, (gint16) v);
    return TRUE;
 }
Index: src/backend/postgres/putil.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/putil.h,v
retrieving revision 1.10.4.6
diff -u -r1.10.4.6 putil.h
--- src/backend/postgres/putil.h 20 Oct 2005 14:48:11 -0000 1.10.4.6
+++ src/backend/postgres/putil.h 1 Nov 2005 20:43:34 -0000
@@ -318,7 +318,7 @@
 #define COMP_INT64(sqlname,fun,ndiffs) { \
    if (strtoll (DB_GET_VAL(sqlname,0), NULL, 0) != fun) { \
       PINFO("mis-match: %s sql='%s', eng='%lld'", sqlname, \
-         DB_GET_VAL (sqlname,0), fun); \
+ DB_GET_VAL (sqlname,0), (long long int) fun); \
       ndiffs++; \
    } \
 }
Index: src/backend/postgres/upgrade.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/upgrade.c,v
retrieving revision 1.12.4.3
diff -u -r1.12.4.3 upgrade.c
--- src/backend/postgres/upgrade.c 1 Oct 2005 22:42:52 -0000 1.12.4.3
+++ src/backend/postgres/upgrade.c 1 Nov 2005 20:43:35 -0000
@@ -126,7 +126,7 @@
 get_iguid_cb (PGBackend *be, PGresult *result, int j, gpointer data)
 {
    int fin = atoi(DB_GET_VAL ("iguid", j));
-   return (gpointer) fin;
+   return GINT_TO_POINTER(fin);
 }
 
 
@@ -150,7 +150,7 @@
 
    p = "SELECT iguid FROM gncGUIDCache ORDER BY iguid DESC LIMIT 1;";
    SEND_QUERY (be,p, );
-   iguid = (guint32) pgendGetResults (be, get_iguid_cb, 0);
+   iguid = (guint32) GPOINTER_TO_UINT(pgendGetResults (be, get_iguid_cb, 0));
    iguid ++;
 
    sprintf(buff, "CREATE SEQUENCE gnc_iguid_seq START %d;", iguid);

_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix compiler warnings on 64 bit processor.

David Hampton-2
On Tue, 2005-11-01 at 12:47 -0800, Karl Hegbloom wrote:
> Here's a ChangeLog entry and diff against today's CVS that suppresses
> the compiler warnings wrt casting from gpointer to int when a pointer is
> 64 bits and an int is only 32.  See the Glib manual, under type
> conversion macros for documentation of the macros used in this patch.

Applied.

David


_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix compiler warnings on 64 bit processor.

Karl Hegbloom
In reply to this post by Karl Hegbloom
In reading the message that came back from the list, I'm seeing some
things I missed and also that maybe not all of the things I changed are
in the diff for some reason.  Please discard that, unless you've already
applied it, and I'll resubmit.  If you already applied it, don't sweat
it, obviously it is a minor change and I can re-sync and fix the rest.

Thank you for switching to Subversion.  I like it better than CVS mainly
due to the speed improvements due to it not needing a network connection
for everything.  It's much nicer on a laptop.

--
Karl Hegbloom <[hidden email]>

_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Fix compiler warnings on 64 bit processor.

David Hampton-2
On Wed, 2005-11-02 at 10:37 -0800, Karl Hegbloom wrote:
> In reading the message that came back from the list, I'm seeing some
> things I missed and also that maybe not all of the things I changed are
> in the diff for some reason.  Please discard that, unless you've already
> applied it,

I applied the entire patch.  I trimmed the comments a bit, but all the
source changes were applied.

David


_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel