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 309663 - gcc 4.01 compiler treats pointer target warnings as errors
gcc 4.01 compiler treats pointer target warnings as errors
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
git master
Other Linux
: Normal normal
: ---
Assigned To: Marco Barisione
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2005-07-07 02:21 UTC by Rod Butcher
Modified: 2014-02-15 12:52 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
-Wno-pointer-sign flag passed to gcc 4. (839 bytes, patch)
2005-07-07 19:37 UTC, Marco Barisione
none Details | Review
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign (9.51 KB, patch)
2005-08-21 15:03 UTC, Marco Barisione
accepted-commit_now Details | Review
Make gtksourceprintjob.c compile without passing -Wno-pointer-sign (2.54 KB, patch)
2005-08-21 15:16 UTC, Marco Barisione
accepted-commit_now Details | Review
Make tests/test-widget.c compile without passing -Wno-pointer-sign (675 bytes, patch)
2005-08-24 18:49 UTC, Marco Barisione
none Details | Review
Make tests/test-widget.c compile without passing -Wno-pointer-sign (675 bytes, patch)
2005-08-24 18:49 UTC, Marco Barisione
none Details | Review
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign (8.66 KB, patch)
2006-01-04 15:45 UTC, Marco Barisione
none Details | Review
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign (10.12 KB, patch)
2006-01-06 16:36 UTC, Marco Barisione
accepted-commit_now Details | Review

Description Rod Butcher 2005-07-07 02:21:59 UTC
Distribution/Version:  Mandriva Linux release 2006.0

cc1: warnings being treated as errors
gtksourcelanguage.c: In function '_gtk_source_language_new_from_file':
gtksourcelanguage.c:88: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness
gtksourcelanguage.c:88: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:88: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness
gtksourcelanguage.c:88: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:88: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:88: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c: In function 'process_language_node':
gtksourcelanguage.c:278: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:278: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:281: warning: pointer targets in passing argument 1 of
'xmlStrdup' differ in signedness
gtksourcelanguage.c:281: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:284: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:287: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:287: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:297: warning: pointer targets in passing argument 1 of
'xmlStrdup' differ in signedness
gtksourcelanguage.c:302: warning: pointer targets in passing argument 2 of
'dcgettext' differ in signedness
gtksourcelanguage.c:302: warning: pointer targets in passing argument 1 of
'xmlStrdup' differ in signedness
gtksourcelanguage.c:302: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:307: warning: pointer targets in passing argument 1 of
'escape_id' differ in signedness
gtksourcelanguage.c:310: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:313: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:313: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:325: warning: pointer targets in passing argument 2 of
'dcgettext' differ in signedness
gtksourcelanguage.c:325: warning: pointer targets in passing argument 1 of
'xmlStrdup' differ in signedness
gtksourcelanguage.c:325: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:329: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:329: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c:354: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:354: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c: In function 'get_mime_types_from_file':
gtksourcelanguage.c:494: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness
gtksourcelanguage.c:494: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:494: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness
gtksourcelanguage.c:494: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:494: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:494: warning: pointer targets in passing argument 1 of
'__builtin_strcmp' differ in signedness
gtksourcelanguage.c:500: warning: pointer targets in passing argument 2 of
'xmlTextReaderGetAttribute' differ in signedness
gtksourcelanguage.c:500: warning: pointer targets in assignment differ in signedness
gtksourcelanguage.c: In function 'parseLineComment':
gtksourcelanguage.c:644: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:644: warning: pointer targets in passing argument 2 of
'gtk_line_comment_tag_new' differ in signedness
gtksourcelanguage.c: In function 'parseBlockComment':
gtksourcelanguage.c:704: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:705: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:705: warning: pointer targets in passing argument 2 of
'gtk_syntax_tag_new' differ in signedness
gtksourcelanguage.c: In function 'parseString':
gtksourcelanguage.c:726: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:776: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:777: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:778: warning: pointer targets in passing argument 2 of
'gtk_string_tag_new' differ in signedness
gtksourcelanguage.c: In function 'parseKeywordList':
gtksourcelanguage.c:803: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:816: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:829: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:842: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:845: warning: pointer targets in passing argument 1 of
'g_strdup' differ in signedness
gtksourcelanguage.c:850: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:853: warning: pointer targets in passing argument 1 of
'g_strdup' differ in signedness
gtksourcelanguage.c:867: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:893: warning: pointer targets in passing argument 2 of
'gtk_keyword_list_tag_new' differ in signedness
gtksourcelanguage.c: In function 'parsePatternItem':
gtksourcelanguage.c:919: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:919: warning: pointer targets in passing argument 2 of
'gtk_pattern_tag_new' differ in signedness
gtksourcelanguage.c: In function 'parseSyntaxItem':
gtksourcelanguage.c:979: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:980: warning: pointer targets in passing argument 1 of
'strconvescape' differ in signedness
gtksourcelanguage.c:980: warning: pointer targets in passing argument 2 of
'gtk_syntax_tag_new' differ in signedness
gtksourcelanguage.c: In function 'parseTag':
gtksourcelanguage.c:1028: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:1031: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:1036: warning: pointer targets in passing argument 2 of
'dcgettext' differ in signedness
gtksourcelanguage.c:1036: warning: pointer targets in passing argument 1 of
'xmlStrdup' differ in signedness
gtksourcelanguage.c:1042: warning: pointer targets in passing argument 2 of
'xmlGetProp' differ in signedness
gtksourcelanguage.c:1050: warning: pointer targets in passing argument 1 of
'escape_id' differ in signedness
gtksourcelanguage.c:1056: warning: pointer targets in passing argument 1 of
'xmlStrdup' differ in signedness
gtksourcelanguage.c:1097: warning: pointer targets in passing argument 1 of
'g_strdup' differ in signedness
gtksourcelanguage.c: In function 'language_file_parse':
gtksourcelanguage.c:1174: warning: pointer targets in passing argument 1 of
'g_utf8_get_char_validated' differ in signedness
make[4]: *** [gtksourcelanguage.lo] Error 1
Comment 1 Marco Barisione 2005-07-07 19:37:42 UTC
Created attachment 48794 [details] [review]
-Wno-pointer-sign flag passed to gcc 4.
Comment 2 Paolo Maggi 2005-07-13 09:18:56 UTC
It is not clear to me why we should add -Wno-pointer-sign instead of fixing the
warnings in the code.
It may be it is not possible to fix them and it seems a lot of programs are
adding this option to their CFLAGS. 
Have you tried to ask on #gnome-hackers? Is this the real solution?

As you can note I am a bit nervous about papering over these warnings without
addressing them.
Comment 3 Paolo Maggi 2005-08-04 07:28:47 UTC
Marco: can you reply to the questions in comment #2?
Comment 4 Marco Barisione 2005-08-21 13:47:53 UTC
The warning is generated because xmlChar is a typedef for unsigned char and the 
code mixes gchars and xmlChars.
I have added the flag because lots of projects are doing so and because I wanted 
a rapid solution to make gtksourceview compile again on my computer.
Comment 5 Marco Barisione 2005-08-21 15:03:31 UTC
Created attachment 51063 [details] [review]
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign

To avoid the warnings without using -Wno-pointer-sign the code needs a lot of
ugly casts the make the code less readable. The casts cannot be avoided as we
need to mix xmlChars with gchars (for instance to pass the values read from the
xml file to gtk).
Comment 6 Marco Barisione 2005-08-21 15:16:19 UTC
Created attachment 51064 [details] [review]
Make gtksourceprintjob.c compile without passing -Wno-pointer-sign

I cannot understand why gnomeprint uses guchar intead of gchar.
And why are GNOME_PRINT_KEY_PAGE_MARGIN_* macros defines to be gchars even if
they should be passed to functions accepting guchars?
Comment 7 Paolo Maggi 2005-08-23 15:38:43 UTC
Comment on attachment 51064 [details] [review]
Make gtksourceprintjob.c compile without passing -Wno-pointer-sign

The patch looks good.
Please fix styles problem:

s/"guchar*"/"guchar *"
s/"gchar*"/"gchar *"

and commit.
Comment 8 Paolo Maggi 2005-08-23 15:47:29 UTC
Comment on attachment 51063 [details] [review]
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign

>-	lang->priv->translation_domain = xmlTextReaderGetAttribute (reader, "translation-domain");
>+	lang->priv->translation_domain = (gchar*) xmlTextReaderGetAttribute (
>+			reader, BAD_CAST "translation-domain");

How do we free "translation_domain"?
s/"gchar*"/"gchar *" (you have done the same error in other places too)

> 	if (lang->priv->translation_domain == NULL)
> 	{
>-		lang->priv->translation_domain = xmlStrdup (GETTEXT_PACKAGE);
>+		lang->priv->translation_domain = g_strdup (GETTEXT_PACKAGE);
> 	}

Same question as above.

Please, check that all the string allocated by libxml are freed with xmlFree
and all the strings allocated by glib
aree freed with g_free.

Feel free to commit when fixed.
Comment 9 Marco Barisione 2005-08-24 18:44:24 UTC
In new_hl_engine branch we have two different parsers that load the strings from 
the xml file and load them in the GtkSourceLanguage. GtkSourceLanguage is freed 
in gtksourcelanguage.c. This means that a variable in a GtkSourceLanguage can be 
created by libxml using a parser and by glib using the other parser.

IMHO there are two possible solutions:
 - use only strings allocated by glib in GtkSourceLanguage (and in the engines), 
this means that we need to copy all the strings returned by libxml with 
g_strdup()
 - use xmlMemSet, so libxml will use g_malloc and g_free and we can always use 
g_free(). This solution is not thread safe: if another thread is using libxml we 
change the memory management functions for that thread too
Comment 10 Marco Barisione 2005-08-24 18:49:10 UTC
Created attachment 51278 [details] [review]
Make tests/test-widget.c compile without passing -Wno-pointer-sign
Comment 11 Marco Barisione 2005-08-24 18:49:11 UTC
Created attachment 51279 [details] [review]
Make tests/test-widget.c compile without passing -Wno-pointer-sign
Comment 12 Jeroen Zwartepoorte 2005-10-18 13:19:47 UTC
I committed these to the code-folding branch. I fixes the s/gchar*/gchar *
formatting stuff as well. It'll probably be merged with HEAD when the
code-folding patches are reviewed.
Comment 13 Paolo Maggi 2006-01-02 10:08:22 UTC
Marco: are your patch up-to-date? Are they complete (i.e. fix all the warnings)? Could you provide a single big patch to review?
Comment 14 Paolo Maggi 2006-01-03 11:22:15 UTC
Comment on attachment 51279 [details] [review]
Make tests/test-widget.c compile without passing -Wno-pointer-sign

This patch is ok. Please, commit.
Comment 15 Marco Barisione 2006-01-04 15:45:28 UTC
Created attachment 56777 [details] [review]
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign
Comment 16 Marco Barisione 2006-01-06 16:36:27 UTC
Created attachment 56868 [details] [review]
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign
Comment 17 Paolo Maggi 2006-01-07 12:37:02 UTC
Comment on attachment 56868 [details] [review]
Make gtksourcelanguage.c compile without passing -Wno-pointer-sign

Only a few comments:
- add some comment in gsl-private.h to explain which fields have been allocated with libXml.
- add some comment to explain why you are not using strdup in 
  +		lang->priv->name = (gchar *)xmlStrdup (BAD_CAST dgettext (lang->priv->translation_domain, (gchar *)tmp));
and other similar lines;
- id_temp should be a gchar*
- mimetypes and version should be a xmlChar*

Please, make these simple changes and commit.
Feel free to close the bug if all the problems are fixed.