Noyau linux et respect des conventions

Bonjour,
Ça m’embête un peu que le passage à une nouvelle version du noyau linux ne s’accompagne jamais par la rectification d’erreurs bénines ou manquements à la syntaxe du langage C.
La différence entre une version 2.6.x.x et 2.6.x.y consiste donc en l’ajout de nouveau module, mais pas en révision de la syntaxe de ce qui a déjà été écrit, qui fonctionne certe, mais qui provoque des erreurs non fatales de compilation.

Voici les premières lignes de logs de ma dernière compilation d’un 2.6.21 debian, les erreurs tournent principalement autour de trois choses:

  • non initialisation préalable d’une variable utilisée dans le corps d’une fonction.
  • test de comparaison toujours vrai ou toujours faux que le gcc relève.
  • bloc de test if vide (que certains langages se refusent à interpréter).

arch/i386/kernel/setup.c:80: warning: missing initializer arch/i386/kernel/setup.c:80: warning: (near initialization for ‘new_cpu_data.x86_capability’) arch/i386/kernel/setup.c:82: warning: missing initializer arch/i386/kernel/setup.c:82: warning: (near initialization for ‘boot_cpu_data.x86_capability’) arch/i386/kernel/reboot.c:150: warning: initialization discards qualifiers from pointer target type arch/i386/kernel/init_task.c:17: warning: missing initializer arch/i386/kernel/init_task.c:17: warning: (near initialization for ‘init_mm.context’) arch/i386/kernel/init_task.c:37: warning: missing initializer arch/i386/kernel/init_task.c:37: warning: (near initialization for ‘init_task.rcu’)

Ou encore :

fs/lockd/svc.c:490: warning: comparison of unsigned expression < 0 is always false fs/ncpfs/dir.c:327: warning: empty body in an else-statement fs/ncpfs/ioctl.c:397: warning: empty body in an else-statement fs/ncpfs/ioctl.c:399: warning: empty body in an else-statement fs/ncpfs/ioctl.c:447: warning: empty body in an else-statement fs/ncpfs/ioctl.c:449: warning: empty body in an else-statement fs/ncpfs/ncplib_kernel.c:299: warning: empty body in an if-statement
Le tout représente 1455 lignes de warning (mais pas 1455 fichiers *.c incriminés).
Mais je ne connais pas le C. Y aurait il quelqu’un connaissant la syntaxe C et à même de rectifier tout cela dans les sources pour mettre ici et à disposition un package linux-source-x.y.z voir un patch à appliquer aux sources debian pour qu’on dispose de sources bien écrites ?

ps: pour le confort compilatoire :smiley:
En plus je me dis que ces petits manquements ne sont pas toujours étrangers aux bizarreries de comportement d’un driver donné, non ?

Ce serais rigolo à faire. Si c’est vraiment les erreurs dont tu parle.
1 500 lignes à corriger c’est pas énorme. Les défaut d’initialisations peuvent peut être causer des petits problèmes mais tout le reste est directement optimisé par gcc.

Alors moi je connais un peu le C, la compil’ d’un noyau moins. Pour voir tout ces logs il faut passer par la méthode classique ou Debian?

Edit :

Ça peut être grave ce genre de problèmes. Mais il faudrais réellement revoir la partie du noyau correspondante pour voir si c’est robuste ou non.

Non, sans compter que une erreur se logue sur 2 lignes, le fichier où l’erreur se produit, et l’erreur et son contexte. Donc à la louche on divise par deux. Mais il s’agit d’un noyau optimisé, le minimum en dur et 400 modules pas plus. Sur un gros noyau à compiler, ça fait sûrement beaucoup de lignes d’erreur.

[quote=“Yoko”]Les défaut d’initialisations peuvent peut être causer des petits problèmes mais tout le reste est directement optimisé par gcc.[/quote]Tu veux dire que c’est corrigé à la compilation du module par gcc ?

[quote=“Yoko”]Pour voir tout ces logs il faut passer par la méthode classique ou Debian?[/quote]Pour voir tous ces logs tu veux dire : pour les loguer dans un fichier ?
C’est trés simple, mais il faut faire le make menuconfig séparément avant : # script -c 'make-kpkg --initrd buildpackage' /vers_ton_fichier/compile.logs

[quote=“Yoko”]fs/lockd/svc.c:490: warning: comparison of unsigned expression < 0 is always false
Ça peut être grave ce genre de problèmes. Mais il faudrais réellement revoir la partie du noyau correspondante pour voir si c’est robuste ou non.[/quote]Et bien, c’est simple, tu instales linux-source-detonchoix, tu te rend dedans, et tu édites le fichier fs/lockd/svc.c avec si possible un éditeur qui te numérote les lignes, pour pointer la ligne 490 et alentours.

Oui ça serait bien à faire, on apprendrait du même coup à créer un patch pour le noyau et à l’appliquer.(Ça me fait penser que j’ai un truc en cours avec fran.b [désolé] sur comment créer un .deb, mais j’ai hyper urgent à faire en ce moment, mais j’y reviendrais …).

EDIT: oui, reste à faire un grep warning compile.logs > compile-warnings

Oui non je sais coder que ce soit avec vi ou un autre éditeur de texte t’inquiète pas c’était juste que je craignait que la méthode debian cache les log.

Je vais essayer de faire ça pour mon noyau c’est à dire le 2.6.18-4-amd64. Je verrais plus tard si je m’amuse à compiler le 2.6.21.

Je voulais me taper la compilation du 2.6.20 mais j’ai eu quelques empêchements, je vais donc le faire sur le 2.6.21 et je compléterais mon tuto pour toutes suggestions d’ajout dans celui-ci n’hésitez pas à me contacter en privé. L’initiative d’usinagaz n’est pas mauvaise du tout et j’espère que ça pourra se compléter, c’est vrai que je trouve souvent pas mal de warnings qui me dérangent mais n’empêche pas forcément un fonctionnement correcte.

Je vais voir combien de warnings je vais avoir pour ma recompile et ensuite j’essaierais d’optimiser le contenu de mon noyau afin d’avoir le minimum requis.

ok super …
Sur certains modules (j’oubliais), il y a des dizaines et des dizaines de lignes d’erreurs, ex:

CC [M] sound/pci/ac97/ac97_codec.o sound/pci/ac97/ac97_codec.c:70: warning: missing initializer sound/pci/ac97/ac97_codec.c:70: warning: (near initialization for ‘snd_ac97_codec_id_vendors[0].flags’) sound/pci/ac97/ac97_codec.c:71: warning: missing initializer sound/pci/ac97/ac97_codec.c:71: warning: (near initialization for ‘snd_ac97_codec_id_vendors[1].flags’) sound/pci/ac97/ac97_codec.c:72: warning: missing initializer sound/pci/ac97/ac97_codec.c:72: warning: (near initialization for ‘snd_ac97_codec_id_vendors[2].flags’) sound/pci/ac97/ac97_codec.c:73: warning: missing initializer sound/pci/ac97/ac97_codec.c:73: warning: (near initialization for ‘snd_ac97_codec_id_vendors[3].flags’) sound/pci/ac97/ac97_codec.c:74: warning: missing initializer sound/pci/ac97/ac97_codec.c:74: warning: (near initialization for ‘snd_ac97_codec_id_vendors[4].flags’) sound/pci/ac97/ac97_codec.c:75: warning: missing initializer sound/pci/ac97/ac97_codec.c:75: warning: (near initialization for ‘snd_ac97_codec_id_vendors[5].flags’) sound/pci/ac97/ac97_codec.c:76: warning: missing initializer sound/pci/ac97/ac97_codec.c:76: warning: (near initialization for ‘snd_ac97_codec_id_vendors[6].flags’) sound/pci/ac97/ac97_codec.c:77: warning: missing initializer sound/pci/ac97/ac97_codec.c:77: warning: (near initialization for ‘snd_ac97_codec_id_vendors[7].flags’) sound/pci/ac97/ac97_codec.c:78: warning: missing initializer sound/pci/ac97/ac97_codec.c:78: warning: (near initialization for ‘snd_ac97_codec_id_vendors[8].flags’) sound/pci/ac97/ac97_codec.c:79: warning: missing initializer sound/pci/ac97/ac97_codec.c:79: warning: (near initialization for ‘snd_ac97_codec_id_vendors[9].flags’) sound/pci/ac97/ac97_codec.c:80: warning: missing initializer sound/pci/ac97/ac97_codec.c:80: warning: (near initialization for ‘snd_ac97_codec_id_vendors[10].flags’) sound/pci/ac97/ac97_codec.c:81: warning: missing initializer sound/pci/ac97/ac97_codec.c:81: warning: missing initializer sound/pci/ac97/ac97_codec.c:81: warning: (near initialization for ‘snd_ac97_codec_id_vendors[11].flags’) sound/pci/ac97/ac97_codec.c:82: warning: missing initializer sound/pci/ac97/ac97_codec.c:82: warning: (near initialization for ‘snd_ac97_codec_id_vendors[12].flags’) sound/pci/ac97/ac97_codec.c:83: warning: missing initializer sound/pci/ac97/ac97_codec.c:83: warning: (near initialization for ‘snd_ac97_codec_id_vendors[13].flags’) sound/pci/ac97/ac97_codec.c:84: warning: missing initializer sound/pci/ac97/ac97_codec.c:84: warning: (near initialization for ‘snd_ac97_codec_id_vendors[14].flags’) sound/pci/ac97/ac97_codec.c:85: warning: missing initializer sound/pci/ac97/ac97_codec.c:85: warning: (near initialization for ‘snd_ac97_codec_id_vendors[15].flags’) sound/pci/ac97/ac97_codec.c:86: warning: missing initializer sound/pci/ac97/ac97_codec.c:86: warning: (near initialization for ‘snd_ac97_codec_id_vendors[16].flags’) sound/pci/ac97/ac97_codec.c:87: warning: missing initializer sound/pci/ac97/ac97_codec.c:87: warning: (near initialization for ‘snd_ac97_codec_id_vendors[17].flags’) sound/pci/ac97/ac97_codec.c:88: warning: missing initializer sound/pci/ac97/ac97_codec.c:88: warning: (near initialization for ‘snd_ac97_codec_id_vendors[18].flags’) sound/pci/ac97/ac97_codec.c:89: warning: missing initializer sound/pci/ac97/ac97_codec.c:89: warning: (near initialization for ‘snd_ac97_codec_id_vendors[19].flags’) sound/pci/ac97/ac97_codec.c:90: warning: missing initializer sound/pci/ac97/ac97_codec.c:90: warning: (near initialization for ‘snd_ac97_codec_id_vendors[20].flags’) sound/pci/ac97/ac97_codec.c:91: warning: missing initializer sound/pci/ac97/ac97_codec.c:91: warning: (near initialization for ‘snd_ac97_codec_id_vendors[21].flags’) sound/pci/ac97/ac97_codec.c:92: warning: missing initializer sound/pci/ac97/ac97_codec.c:92: warning: (near initialization for ‘snd_ac97_codec_id_vendors[22].flags’) sound/pci/ac97/ac97_codec.c:93: warning: missing initializer sound/pci/ac97/ac97_codec.c:93: warning: (near initialization for ‘snd_ac97_codec_id_vendors[23].flags’) sound/pci/ac97/ac97_codec.c:97: warning: missing initializer sound/pci/ac97/ac97_codec.c:97: warning: (near initialization for ‘snd_ac97_codec_ids[0].flags’) sound/pci/ac97/ac97_codec.c:98: warning: missing initializer sound/pci/ac97/ac97_codec.c:98: warning: (near initialization for ‘snd_ac97_codec_ids[1].flags’) sound/pci/ac97/ac97_codec.c:99: warning: missing initializer sound/pci/ac97/ac97_codec.c:99: warning: (near initialization for ‘snd_ac97_codec_ids[2].flags’) sound/pci/ac97/ac97_codec.c:100: warning: missing initializer sound/pci/ac97/ac97_codec.c:100: warning: (near initialization for ‘snd_ac97_codec_ids[3].flags’) sound/pci/ac97/ac97_codec.c:101: warning: missing initializer sound/pci/ac97/ac97_codec.c:101: warning: (near initialization for ‘snd_ac97_codec_ids[4].flags’) sound/pci/ac97/ac97_codec.c:102: warning: missing initializer sound/pci/ac97/ac97_codec.c:102: warning: (near initialization for ‘snd_ac97_codec_ids[5].flags’) sound/pci/ac97/ac97_codec.c:103: warning: missing initializer sound/pci/ac97/ac97_codec.c:103: warning: (near initialization for ‘snd_ac97_codec_ids[6].flags’) sound/pci/ac97/ac97_codec.c:104: warning: missing initializer sound/pci/ac97/ac97_codec.c:104: warning: (near initialization for ‘snd_ac97_codec_ids[7].flags’) sound/pci/ac97/ac97_codec.c:105: warning: missing initializer sound/pci/ac97/ac97_codec.c:105: warning: (near initialization for ‘snd_ac97_codec_ids[8].flags’) sound/pci/ac97/ac97_codec.c:106: warning: missing initializer sound/pci/ac97/ac97_codec.c:106: warning: (near initialization for ‘snd_ac97_codec_ids[9].flags’) sound/pci/ac97/ac97_codec.c:107: warning: missing initializer sound/pci/ac97/ac97_codec.c:107: warning: (near initialization for ‘snd_ac97_codec_ids[10].flags’) sound/pci/ac97/ac97_codec.c:108: warning: missing initializer sound/pci/ac97/ac97_codec.c:108: warning: (near initialization for ‘snd_ac97_codec_ids[11].flags’) sound/pci/ac97/ac97_codec.c:109: warning: missing initializer sound/pci/ac97/ac97_codec.c:109: warning: (near initialization for ‘snd_ac97_codec_ids[12].flags’) sound/pci/ac97/ac97_codec.c:110: warning: missing initializer sound/pci/ac97/ac97_codec.c:110: warning: (near initialization for ‘snd_ac97_codec_ids[13].flags’) sound/pci/ac97/ac97_codec.c:111: warning: missing initializer sound/pci/ac97/ac97_codec.c:111: warning: (near initialization for ‘snd_ac97_codec_ids[14].flags’) sound/pci/ac97/ac97_codec.c:112: warning: missing initializer sound/pci/ac97/ac97_codec.c:112: warning: (near initialization for ‘snd_ac97_codec_ids[15].flags’) sound/pci/ac97/ac97_codec.c:113: warning: missing initializer sound/pci/ac97/ac97_codec.c:113: warning: (near initialization for ‘snd_ac97_codec_ids[16].flags’) sound/pci/ac97/ac97_codec.c:114: warning: missing initializer sound/pci/ac97/ac97_codec.c:114: warning: (near initialization for ‘snd_ac97_codec_ids[17].flags’) sound/pci/ac97/ac97_codec.c:115: warning: missing initializer sound/pci/ac97/ac97_codec.c:115: warning: (near initialization for ‘snd_ac97_codec_ids[18].flags’) sound/pci/ac97/ac97_codec.c:116: warning: missing initializer sound/pci/ac97/ac97_codec.c:116: warning: (near initialization for ‘snd_ac97_codec_ids[19].flags’) sound/pci/ac97/ac97_codec.c:117: warning: missing initializer sound/pci/ac97/ac97_codec.c:117: warning: (near initialization for ‘snd_ac97_codec_ids[20].flags’) sound/pci/ac97/ac97_codec.c:118: warning: missing initializer sound/pci/ac97/ac97_codec.c:118: warning: (near initialization for ‘snd_ac97_codec_ids[21].flags’) sound/pci/ac97/ac97_codec.c:119: warning: missing initializer sound/pci/ac97/ac97_codec.c:119: warning: (near initialization for ‘snd_ac97_codec_ids[22].flags’) sound/pci/ac97/ac97_codec.c:120: warning: missing initializer sound/pci/ac97/ac97_codec.c:120: warning: (near initialization for ‘snd_ac97_codec_ids[23].flags’) sound/pci/ac97/ac97_codec.c:121: warning: missing initializer sound/pci/ac97/ac97_codec.c:121: warning: (near initialization for ‘snd_ac97_codec_ids[24].flags’) sound/pci/ac97/ac97_codec.c:122: warning: missing initializer sound/pci/ac97/ac97_codec.c:122: warning: (near initialization for ‘snd_ac97_codec_ids[25].flags’) sound/pci/ac97/ac97_codec.c:123: warning: missing initializer sound/pci/ac97/ac97_codec.c:123: warning: (near initialization for ‘snd_ac97_codec_ids[26].flags’) sound/pci/ac97/ac97_codec.c:124: warning: missing initializer sound/pci/ac97/ac97_codec.c:124: warning: (near initialization for ‘snd_ac97_codec_ids[27].flags’) sound/pci/ac97/ac97_codec.c:125: warning: missing initializer sound/pci/ac97/ac97_codec.c:125: warning: (near initialization for ‘snd_ac97_codec_ids[28].flags’) sound/pci/ac97/ac97_codec.c:126: warning: missing initializer sound/pci/ac97/ac97_codec.c:126: warning: (near initialization for ‘snd_ac97_codec_ids[29].flags’) sound/pci/ac97/ac97_codec.c:127: warning: missing initializer sound/pci/ac97/ac97_codec.c:127: warning: (near initialization for ‘snd_ac97_codec_ids[30].flags’) sound/pci/ac97/ac97_codec.c:128: warning: missing initializer sound/pci/ac97/ac97_codec.c:128: warning: (near initialization for ‘snd_ac97_codec_ids[31].flags’) sound/pci/ac97/ac97_codec.c:129: warning: missing initializer sound/pci/ac97/ac97_codec.c:129: warning: missing initializer sound/pci/ac97/ac97_codec.c:129: warning: (near initialization for ‘snd_ac97_codec_ids[32].flags’) sound/pci/ac97/ac97_codec.c:130: warning: missing initializer sound/pci/ac97/ac97_codec.c:130: warning: (near initialization for ‘snd_ac97_codec_ids[33].flags’) sound/pci/ac97/ac97_codec.c:131: warning: missing initializer sound/pci/ac97/ac97_codec.c:131: warning: (near initialization for ‘snd_ac97_codec_ids[34].flags’) sound/pci/ac97/ac97_codec.c:132: warning: missing initializer sound/pci/ac97/ac97_codec.c:132: warning: (near initialization for ‘snd_ac97_codec_ids[35].flags’) sound/pci/ac97/ac97_codec.c:133: warning: missing initializer sound/pci/ac97/ac97_codec.c:133: warning: (near initialization for ‘snd_ac97_codec_ids[36].flags’) sound/pci/ac97/ac97_codec.c:134: warning: missing initializer sound/pci/ac97/ac97_codec.c:134: warning: (near initialization for ‘snd_ac97_codec_ids[37].flags’) sound/pci/ac97/ac97_codec.c:135: warning: missing initializer sound/pci/ac97/ac97_codec.c:135: warning: (near initialization for ‘snd_ac97_codec_ids[38].flags’) sound/pci/ac97/ac97_codec.c:136: warning: missing initializer sound/pci/ac97/ac97_codec.c:136: warning: (near initialization for ‘snd_ac97_codec_ids[39].flags’) sound/pci/ac97/ac97_codec.c:137: warning: missing initializer sound/pci/ac97/ac97_codec.c:137: warning: (near initialization for ‘snd_ac97_codec_ids[40].flags’) sound/pci/ac97/ac97_codec.c:138: warning: missing initializer sound/pci/ac97/ac97_codec.c:138: warning: (near initialization for ‘snd_ac97_codec_ids[41].flags’) sound/pci/ac97/ac97_codec.c:139: warning: missing initializer sound/pci/ac97/ac97_codec.c:139: warning: (near initialization for ‘snd_ac97_codec_ids[42].flags’) sound/pci/ac97/ac97_codec.c:140: warning: missing initializer sound/pci/ac97/ac97_codec.c:140: warning: (near initialization for ‘snd_ac97_codec_ids[43].flags’) sound/pci/ac97/ac97_codec.c:141: warning: missing initializer sound/pci/ac97/ac97_codec.c:141: warning: (near initialization for ‘snd_ac97_codec_ids[44].flags’) sound/pci/ac97/ac97_codec.c:142: warning: missing initializer sound/pci/ac97/ac97_codec.c:142: warning: (near initialization for ‘snd_ac97_codec_ids[45].flags’) sound/pci/ac97/ac97_codec.c:143: warning: missing initializer sound/pci/ac97/ac97_codec.c:143: warning: (near initialization for ‘snd_ac97_codec_ids[46].flags’) sound/pci/ac97/ac97_codec.c:144: warning: missing initializer sound/pci/ac97/ac97_codec.c:144: warning: (near initialization for ‘snd_ac97_codec_ids[47].flags’) sound/pci/ac97/ac97_codec.c:145: warning: missing initializer sound/pci/ac97/ac97_codec.c:145: warning: (near initialization for ‘snd_ac97_codec_ids[48].flags’) sound/pci/ac97/ac97_codec.c:146: warning: missing initializer sound/pci/ac97/ac97_codec.c:146: warning: (near initialization for ‘snd_ac97_codec_ids[49].flags’) sound/pci/ac97/ac97_codec.c:147: warning: missing initializer sound/pci/ac97/ac97_codec.c:147: warning: (near initialization for ‘snd_ac97_codec_ids[50].flags’) sound/pci/ac97/ac97_codec.c:148: warning: missing initializer sound/pci/ac97/ac97_codec.c:148: warning: (near initialization for ‘snd_ac97_codec_ids[51].flags’) sound/pci/ac97/ac97_codec.c:149: warning: missing initializer sound/pci/ac97/ac97_codec.c:149: warning: (near initialization for ‘snd_ac97_codec_ids[52].flags’) sound/pci/ac97/ac97_codec.c:150: warning: missing initializer sound/pci/ac97/ac97_codec.c:150: warning: (near initialization for ‘snd_ac97_codec_ids[53].flags’) sound/pci/ac97/ac97_codec.c:151: warning: missing initializer sound/pci/ac97/ac97_codec.c:151: warning: (near initialization for ‘snd_ac97_codec_ids[54].flags’) (...) etc (...)
Ça doit pas être la mer à boire de corriger tout ça je pense … et de patcher, voir d’envoyer la correction à la debian-team via un développeur debian que vous connaîtriez … avec tout le respect qu’on lui/leur doit :wink:

Je le compile en normal et j’enverrais le patchsur la liste de discution des Mentors.

Ca corrigeras pas tout les modules je vais “juste” voir pour la configuration par défaut. Je pense que s’occuper de la version 2.6.19 et 2.6.20 .

Première compilation terminée, je n’ai eu que 200 et quelques erreurs. Je compil’ en amd64 avec la config’ de base.

cool :wink:
200 fichiers.c différents, ou 200 lignes en vrac ?

200 lignes représentant chacune une erreur. Donc 200 erreurs.

C’est maintenant que ça va être long, il y en a des assez ardues.