Ticket #1150 (new defect)

Opened 5 years ago

Last modified 5 years ago

Cast from long long int to int in archive

Reported by: bricks Owned by: bricks
Priority: normal Milestone: OpenSync 0.40
Component: OpenSync: Build Environment Version: 0.38
Severity: normal Keywords:
Cc:

Description

osync_archive_load_changes and osync_archive_load_ignored_conflicts contain invalid casts from long long int to int in lines 432, 434, 517 and 518. Gcc complains about cast to pointer from integer of different size

Change History

comment:1 Changed 5 years ago by dgollub

  • Owner changed from dgollub to bricks
  • Component changed from OpenSync to OpenSync: Build Environment

comment:2 Changed 5 years ago by bricks

Our code in these lines isn't portable and usable on 64Bit systems. In these code segments calls like GINT_TO_POINTER((int)mappingid) can be found. mappingid is of a type long long int. This won't work on 64Bit as the glib doc says:

#define GINT_TO_POINTER(i)	((gpointer) (glong) (i))

Stuffs an integer into a pointer type.

Remember, YOU MAY NOT STORE POINTERS IN INTEGERS. THIS IS NOT PORTABLE IN ANY WAY SHAPE OR FORM.
These macros ONLY allow storing integers in pointers, and only preserve 32 bits of the integer;
values outside the range of a 32-bit integer will be mangled.

How can we solve this issue?

Note: See TracTickets for help on using tickets.