On 11 August 2013 23:31, Nick Treleaven git-noreply@geany.org wrote:
Branch: refs/heads/master Author: Nick Treleaven nick.treleaven@btinternet.com Committer: Nick Treleaven nick.treleaven@btinternet.com Date: Sun, 11 Aug 2013 13:31:30 UTC Commit: 0c7cf8df103232a5ccee7da4e46d611b35eae033
https://github.com/geany/geany/commit/0c7cf8df103232a5ccee7da4e46d611b35eae0...
Log Message:
Fix gcc warning 'cast to pointer from integer of different size'
Modified Paths:
tagmanager/src/tm_workspace.c
Modified: tagmanager/src/tm_workspace.c 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -207,7 +207,7 @@ static guint tm_file_inode_hash(gconstpointer key) #ifdef TM_DEBUG g_message ("Hash for '%s' is '%d'\n", filename, file_stat.st_ino); #endif
return g_direct_hash (GUINT_TO_POINTER (file_stat.st_ino));
return g_direct_hash (GUINT_TO_POINTER
((guint)file_stat.st_ino));
Hi Nick,
On 64 bit Linux ino_t is 64 bits, but guint is 32 bits so this has the potential to truncate inode numbers, you should cast to gulong.
Note from the Glib docs on GUINT_TO_POINTER "#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))"
Cheers Lex
} else { return 0; }
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure). _______________________________________________ Commits mailing list Commits@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/commits
On 12/08/2013 01:03, Lex Trotman wrote:
On 11 August 2013 23:31, Nick Treleaven git-noreply@geany.org wrote:
return g_direct_hash (GUINT_TO_POINTER (file_stat.st_ino));
return g_direct_hash (GUINT_TO_POINTER
((guint)file_stat.st_ino));
Hi Nick,
On 64 bit Linux ino_t is 64 bits, but guint is 32 bits so this has the potential to truncate inode numbers, you should cast to gulong.
Thanks, fixed.
Note from the Glib docs on GUINT_TO_POINTER "#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))"
On my Windows system that macro doesn't cast to gulong, otherwise there wouldn't be a gcc warning. Matt pointed out it may be a GLib bug.
Nick Treleaven nick.treleaven@btinternet.com schrieb:
On 12/08/2013 01:03, Lex Trotman wrote:
On 11 August 2013 23:31, Nick Treleaven git-noreply@geany.org
wrote:
return g_direct_hash (GUINT_TO_POINTER
(file_stat.st_ino));
return g_direct_hash (GUINT_TO_POINTER
((guint)file_stat.st_ino));
Hi Nick,
On 64 bit Linux ino_t is 64 bits, but guint is 32 bits so this has
the
potential to truncate inode numbers, you should cast to gulong.
Thanks, fixed.
Note from the Glib docs on GUINT_TO_POINTER "#define
GUINT_TO_POINTER(u)
((gpointer) (gulong) (u))"
On my Windows system that macro doesn't cast to gulong, otherwise there
wouldn't be a gcc warning. Matt pointed out it may be a GLib bug.
What does it cast to? Long is only 32bit on windows anyway.
Best regards
On 13-08-12 07:43 AM, Thomas Martitz wrote:
Nick Treleaven nick.treleaven@btinternet.com schrieb:
On 12/08/2013 01:03, Lex Trotman wrote:
On 11 August 2013 23:31, Nick Treleaven git-noreply@geany.org
wrote:
return g_direct_hash (GUINT_TO_POINTER
(file_stat.st_ino));
return g_direct_hash (GUINT_TO_POINTER
((guint)file_stat.st_ino));
Hi Nick,
On 64 bit Linux ino_t is 64 bits, but guint is 32 bits so this has
the
potential to truncate inode numbers, you should cast to gulong.
Thanks, fixed.
Note from the Glib docs on GUINT_TO_POINTER "#define
GUINT_TO_POINTER(u)
((gpointer) (gulong) (u))"
On my Windows system that macro doesn't cast to gulong, otherwise there
wouldn't be a gcc warning. Matt pointed out it may be a GLib bug.
What does it cast to? Long is only 32bit on windows anyway.
One would think the point of a cross-platform toolkit typedef-ing every type in the standard would be normalize it across platforms, otherwise it's just plain stupid to stick "g" in front of even such basic types and typedef their well-known standard names and "g"-#define their limit macros to the exact same thing already available on every single platform in every single standard library (afaik).</end-g-rant>
But yeah, I'm pretty sure that *is* why it doesn't have the additional (gulong) cast as claimed and discussed in the documentation, but what's curious to me is 1) why is the extra new cast needed above just casting to pointer as before (especially casting to wider type), and 2) what changed that made this warning popup out of nowhere in code I don't think has been touched in quite some time?
Cheers, Matthew Brush
On 13/08/2013 01:27, Matthew Brush wrote:
Note from the Glib docs on GUINT_TO_POINTER "#define
GUINT_TO_POINTER(u)
((gpointer) (gulong) (u))"
On my Windows system that macro doesn't cast to gulong, otherwise there
wouldn't be a gcc warning. Matt pointed out it may be a GLib bug.
What does it cast to? Long is only 32bit on windows anyway.
...
But yeah, I'm pretty sure that *is* why it doesn't have the additional (gulong) cast as claimed and discussed in the documentation, but what's curious to me is 1) why is the extra new cast needed above just casting to pointer as before (especially casting to wider type), and 2) what changed that made this warning popup out of nowhere in code I don't think has been touched in quite some time?
It's only needed on Windows. Before I ignored the warning.