[grisbi-devel] Grisbi compiler warnings and bugs

Ludovic Rousseau ludovic.rousseau at gmail.com
Wed Oct 26 19:54:39 CEST 2016


Le 21 octobre 2016 à 08:36, Rémi Cardona <remi at gentoo.org> a écrit :

> Le 06/10/2016 à 20:44, Ludovic Rousseau a écrit :
> > Bonsoir,
> >
> > Je commence à corriger les warnings. Juste avec clang et le niveau de
> > warnings de base j'ai déjà plusieurs warnings inquiétants.
> >
> > Par exemple j'en ai corrigé 1 qui est aussi un bug :
> > https://github.com/grisbi/grisbi/commit/f28fd44812a9112c670568849ae491
> a73f5e7d4e
> >
> > Mon idée est de corriger tous les warnings et ensuite de configurer
> > Travis-CI avec -Werror pour qu'un nouveau warning fasse échouer la
> > compilation automatique.
>
> C'est une super idée! Depuis le début, je compilais grisbi avec pas mal
> d'options mais le passage à gtk3 a généré tellement de nouveaux warnings
> que j'ai laissé tomber (honte sur moi). Idem pour static-analyzer de
> clang, il m'a permis de corriger énormément de problèmes alors que le
> projet était tout jeune. J'imagine qu'il a encore du s'améliorer depuis
> et qu'il trouve moult nouveaux problèmes :)
>
> Concernant les warnings, je suggère de s'inspirer de ce qui est fait
> dans la galaxie Xorg:
>
> * une macro XORG_TESTSET_CFLAG[1] qui teste qu'une option de compilateur
> marche (du moins, ne fait pas planter la compilation d'un fichier vide)
> * une macro XORG_COMPILER_FLAGS[2] qui définit une belle liste de
> warnings à activer[3], et de warnings systématiquement transformés en
> erreurs[4]
> * une macro XORG_STRICT_OPTION[5] qui ajoute l'option
> --enable-strict-compilation au ./configure pour facilement activer -Werror
>
> Cette dernière option n'est pas activée par défaut afin de ne pas casser
> inutilement la compilation de vieilles versions de paquets Xorg avec de
> nouveaux compilateurs. Lorsqu'une personne travaille sur le code de
> Xorg, il/elle n'a donc qu'à activer cette option pour avoir le niveau
> maximum de sévérité.
>
> Le code des macros m4 de Xorg est assez compliqué, voire velu, mais il
> s'explique par le nombre d'OS et d'architectures (donc de compilateurs)
> supportés, ainsi que par le nombre de paquets l'utilisant (20+
> bibliothèques, 10+ pilotes, 30+ outils, le serveur X, etc).
>
> J'ai pris Xorg parce que je connais plutôt bien ce projet, mais si
> d'autres choses existent ailleurs (je pense à autoconf-archive
> notamment[6][7]), allons-y!
>

Super. Je ne connaissais pas cet aspect de Xorg.

Avec clang 8.0.0 la macro XORG_COMPILER_FLAGS m'a trouvé :
BASE_CFLAGS =  -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
-Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement
-Wunused -Wuninitialized -Wshadow -Wmissing-noreturn
-Wmissing-format-attribute -Wredundant-decls -Werror=implicit
-Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces
-Werror=sequence-point -Werror=return-type -Werror=trigraphs
-Werror=array-bounds -Werror=write-strings -Werror=address
-Werror=int-to-pointer-cast -Werror=pointer-to-int-cast

Il semble que toutes les options testées par XORG_COMPILER_FLAGS (sauf
-Wlogical-op) soient présentes :
[...]
checking whether __clang__ is declared... yes
checking whether __INTEL_COMPILER is declared... no
checking whether __SUNPRO_C is declared... no
checking if gcc supports -Werror=unknown-warning-option... yes
checking if gcc supports -Werror=unused-command-line-argument... yes
checking if gcc supports -Wall... yes
checking if gcc supports -Wpointer-arith... yes
checking if gcc supports -Wmissing-declarations... yes
checking if gcc supports -Wformat=2... yes
checking if gcc supports -Wstrict-prototypes... yes
checking if gcc supports -Wmissing-prototypes... yes
checking if gcc supports -Wnested-externs... yes
checking if gcc supports -Wbad-function-cast... yes
checking if gcc supports -Wold-style-definition... yes
checking if gcc supports -Wdeclaration-after-statement... yes
checking if gcc supports -Wunused... yes
checking if gcc supports -Wuninitialized... yes
checking if gcc supports -Wshadow... yes
checking if gcc supports -Wmissing-noreturn... yes
checking if gcc supports -Wmissing-format-attribute... yes
checking if gcc supports -Wredundant-decls... yes
checking if gcc supports -Wlogical-op... no
checking if gcc supports -Werror=implicit... yes
checking if gcc supports -Werror=nonnull... yes
checking if gcc supports -Werror=init-self... yes
checking if gcc supports -Werror=main... yes
checking if gcc supports -Werror=missing-braces... yes
checking if gcc supports -Werror=sequence-point... yes
checking if gcc supports -Werror=return-type... yes
checking if gcc supports -Werror=trigraphs... yes
checking if gcc supports -Werror=array-bounds... yes
checking if gcc supports -Werror=write-strings... yes
checking if gcc supports -Werror=address... yes
checking if gcc supports -Werror=int-to-pointer-cast... yes
checking if gcc supports -Werror=pointer-to-int-cast... yes
checking if gcc supports -pedantic... yes
checking if gcc supports -Werror... yes
checking if gcc supports -Werror=attributes... yes
[...]

Je crois qu'il va falloir activer une options une par une. J'ai un peu trop
de warnings si j'utilise tout d'un coup :-)

à+


> Rémi
>
> [1]
> https://cgit.freedesktop.org/xorg/util/macros/tree/xorg-macros.m4.in#n1540
> [2]
> https://cgit.freedesktop.org/xorg/util/macros/tree/xorg-macros.m4.in#n1633
> [3]
> https://cgit.freedesktop.org/xorg/util/macros/tree/xorg-macros.m4.in#n1669
> [4]
> https://cgit.freedesktop.org/xorg/util/macros/tree/xorg-macros.m4.in#n1702
> [5]
> https://cgit.freedesktop.org/xorg/util/macros/tree/xorg-macros.m4.in#n1765
> [6] https://cgit.freedesktop.org/systemd/systemd/tree/configure.ac#n148
> [7]
> http://www.gnu.org/software/autoconf-archive/ax_append_
> compile_flags.html#ax_append_compile_flags
> _______________________________________________
> devel mailing list
> devel at listes.grisbi.org
> http://listes.grisbi.org/mailman/listinfo/devel
>



-- 
 Dr. Ludovic Rousseau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listes.grisbi.org/pipermail/devel/attachments/20161026/0c45e186/attachment.html>


More information about the devel mailing list