GNOME Bugzilla – Bug 309663
gcc 4.01 compiler treats pointer target warnings as errors
Last modified: 2014-02-15 12:52:50 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
Created attachment 48794 [details] [review] -Wno-pointer-sign flag passed to gcc 4.
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.
Marco: can you reply to the questions in comment #2?
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.
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).
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 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 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.
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
Created attachment 51278 [details] [review] Make tests/test-widget.c compile without passing -Wno-pointer-sign
Created attachment 51279 [details] [review] Make tests/test-widget.c compile without passing -Wno-pointer-sign
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.
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 on attachment 51279 [details] [review] Make tests/test-widget.c compile without passing -Wno-pointer-sign This patch is ok. Please, commit.
Created attachment 56777 [details] [review] Make gtksourcelanguage.c compile without passing -Wno-pointer-sign
Created attachment 56868 [details] [review] Make gtksourcelanguage.c compile without passing -Wno-pointer-sign
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.