After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 659870 - gvalue: Fix signedness of g_value_get_char()
gvalue: Fix signedness of g_value_get_char()
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 666833 688444 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-09-22 20:12 UTC by Colin Walters
Modified: 2017-11-17 12:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gvalue: Fix signedness of g_value_get_char() (2.55 KB, patch)
2011-09-22 20:12 UTC, Colin Walters
none Details | Review
gvalue: Add explicitly signed g_value_get_schar() and g_value_set_schar() (10.17 KB, patch)
2011-09-22 21:04 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2011-09-22 20:12:46 UTC
The documentation for G_TYPE_CHAR says:

"The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed
 integer."

However the return value for this function was just "char" which
has an unspecified signedness, which happens to work on signed char
platforms like x86, but will fail on e.g. ppc or ARM.

Fix this by explicitly specifying gint8 and guint8 for all 4 of these
functions.
Comment 1 Colin Walters 2011-09-22 20:12:48 UTC
Created attachment 197290 [details] [review]
gvalue: Fix signedness of g_value_get_char()
Comment 2 Colin Walters 2011-09-22 20:14:21 UTC
One major problem with this is it's technically an ABI break on unsigned char platforms.  We either:

1) Accept it
2) Add a new g_value_get_char2 which only exists on unsigned-char platforms.  This would be horribly ugly =(
Comment 3 Colin Walters 2011-09-22 21:04:24 UTC
Created attachment 197294 [details] [review]
gvalue: Add explicitly signed g_value_get_schar() and g_value_set_schar()

Let's go the other way and not break ABI.
Comment 4 Matthias Clasen 2011-09-22 22:49:19 UTC
Review of attachment 197294 [details] [review]:

Other than that, looks right to me.

::: gobject/gvaluetypes.h
@@ +182,3 @@
 gchar		      g_value_get_char		(const GValue *value);
+void		      g_value_set_schar		(GValue	      *value,
+						 gint8	       v_char);

Need to add deprecation guards in the header.
Comment 5 Matthias Clasen 2011-09-22 22:49:47 UTC
Review of attachment 197294 [details] [review]:

Actually, we've already branched, so feel free to commit to master
Comment 6 Colin Walters 2011-09-23 00:07:59 UTC
Attachment 197294 [details] pushed as f42fe6c - gvalue: Add explicitly signed g_value_get_schar() and g_value_set_schar()
Comment 7 Dan Winship 2012-11-16 14:20:01 UTC
*** Bug 688444 has been marked as a duplicate of this bug. ***
Comment 8 Philip Withnall 2017-11-17 12:10:59 UTC
*** Bug 666833 has been marked as a duplicate of this bug. ***