GNOME Bugzilla – Bug 743936
glib: handle unsigned modifier for long long in internal printf
Last modified: 2017-11-16 11:00:24 UTC
When internal printf is used, ie HAVE_GOOD_PRINTF not defined, and when HAVE_LONG_LONG_FORMAT is not defined, print_long_long function is used to display both unsigned and signed long long type. However, this function doesn't handle 'u' modifier, so it display an unsigned long long as a signed one which is not the expected behavior. For instance a test program like: int main(...) { guint64 tmp = G_MAXUINT64; g_print ("G_MAXUINT64=%" G_GUINT64_FORMAT "\n", tmp); return 0; } displays G_MAXUINT64=-1
Created attachment 296026 [details] [review] glib: handle unsigned modifier for long long in internal printf Proposal patch to handle 'u' modifier
Does this affect upstream gnulib too? Hmm...it looks like glib's copy of vasnprintf was last synchronized in 2003. The gnulib code is pretty radically different today. Honestly, I think the best thing is for you to get a copy of glibc and avoid using glib's included printf code...it's obviously undermaintained.
Review of attachment 296026 [details] [review]: Change looks fine to me.
https://git.gnome.org/browse/glib/commit/?id=5b74681f5b4dd3f5fc93b82a4f706c2337d76a8d
(In reply to comment #2) > Does this affect upstream gnulib too? Hmm...it looks like glib's copy of > vasnprintf was last synchronized in 2003. The gnulib code is pretty radically > different today. I try to check in upstream, but as you said, code is different, so I don't really know if it's affect or not upstream because I think code to handle long long was added in glibc. > > Honestly, I think the best thing is for you to get a copy of glibc and avoid > using glib's included printf code...it's obviously undermaintained. After some other investigations, I succeeded to make glib use system printf instead of included one by forcing some autoconf variables: ac_cv_func_vsnprintf_c99, ac_cv_func_printf_unix98 and glib_cv_long_long_format and it seems to work too :) So I may have a problem with features detection, but first, I will try to figure out what my libc really supports or not. If interested, or just for records, I use eglibc-2.15
I'd use OpenEmbedded as a reference point here: https://github.com/openembedded/openembedded-core/blob/master/meta/recipes-core/glib-2.0/glib.inc#L36
Comment on attachment 296026 [details] [review] glib: handle unsigned modifier for long long in internal printf (Was pushed as 5b74681f5b4dd3f5fc93b82a4f706c2337d76a8d.)
*** Bug 693347 has been marked as a duplicate of this bug. ***