YeLinux 5.18 yakarongwa kufambisa kodhi kune imwe yazvino vhezheni yeC kuitira kugadzirisa matambudziko akasiyana. 

Chii chinonzi Linux uye ndechei?

Munguva yemaitiro e developer hurukuro yeLinux kernel nezve uyel dingindira reimwe seti ye zvigamba zvekugadzirisa kusasimba yeSpecter mune kodhi yekushanda nemazita akabatanidzwa, zvakava pachena kune vakawanda vagadziri kuti dambudziko inogona kugadziriswa nyore nyore kana yakabvumidzwa mu kernel code C que inopindirana neshanduro itsva yechiyero. 

Uye ndezvekuti parizvino kodhi yakawedzerwa kuLinux Kernel inofanirwa kuenderana neiyo ANSI C (C89) yakatarwa, iyo yakaumbwa muna 1989.

Ndokusaka dambudziko rine chekuita neSpecter mukodhi yaive nekuti sndakaramba ndichishandisa iterator inotsanangurwa zvakasiyana mushure mechiuno.

Kunyangwe iyo inowanzo kukurumidza hunhu, iyo kernel chirongwa chinotsamira pane akati wandei ekare maturusi. Nepo vatsoropodzi vachida kutarisa nezvemashandisirwo eemail zvakanyanya nenharaunda, chingangove chakakosha anachronism kushandiswa kweiyo 1989 vhezheni yemutauro weC C yekernel code, chiyero chakakodhawa chirongwa chekernel chisati chatanga makore makumi matatu apfuura. Zvinotaridza sekuti tsika yakagara kwenguva refu inogona kusvika pakupera nekukurumidza kernel 30, inotarisirwa muna Chivabvu gore rino.

Izvo zvinotaurwa kuti macro inoshandiswa kudzokorora pamusoro pezvinhu zverunyorwa rwakabatana, uye sezvo loop iterator ichipfuudzwa kune iyi macro, inotsanangurwa kunze kweiyo loop pachayo uye inoramba iripo mushure mechiuno. Kushandisa chiyero cheC99 kwaizobvumira vanogadzira kutsanangura zvinoshanduka zve loop mu () block, izvo zvaizogadzirisa dambudziko pasina kugadzira maworkaround.

Nehurombo, kune nzvimbo dzakawanda mu kernel pane iyo rondedzero
iterator inoshandiswa mushure mechiuno chinoputika pane shanduko yakadaro. Sezvineiwo
pane script use_after_iter.cocci rinogona kushandiswa kuona zvakadaro
code nzvimbo. Ndaifanira kugadzirisa script zvishoma sezvo ichideredza nhema
positives mune yekutanga kushandiswa kesi, asi izvo zvinoenderana nechigamba ichi.

Yakakura yakakurisa yenzvimbo dzakashumwa dzekodhi dzinoshandisa iyo rondedzero iterator mushure
kutenderera kana paine kubuda kwekutanga (break/goto) uye nekudaro havasi
zvinoenderana.

Kune rumwe rutivi, Linus Torvalds akabvumirana nepfungwa iyi kukwanisa kuita tsigiro yezvitsva zvakatemwa uyezve kurudzira kufamba pa kernel 5.18 kushandisa iyo C11 standard, yakaburitswa muna 2011.

Mushure meizvozvo, panguva yekutanga yekusimbisa, kukwira kuGCC uye Clang mune nyowani modhi yakapfuura pasina kutsauka. Kunze kwekunge matambudziko asingatarisirwe amuka nekuda kwekuyedzwa kwakawanda, iyo 5.18 kernel kuvaka zvinyorwa zvinoshandura iyo '-std=gnu89' sarudzo kuita '-std=gnu11 -Wno-shift-negative-value'.

Linus Torvalds aisada chigamba ichi zvakanyanya uye haana kuona kuti chakabatana sei nekusagadzikana kwekufungidzira. Nekudaro, mushure mekunge Koschel awedzera kutsanangura mamiriro ezvinhu, Torvalds akabvuma kuti "iyi ingori tsikidzi, yakajeka uye yakapusa" uye akati inofanirwa kugadziriswa zvisinei neakakura akateedzana. Asi akabva anyura mune chaiyo kwainobva dambudziko: kuti iterator yakapfuudza kune rondedzero inotenderera macros inofanirwa kuziviswa muchikamu chiri kunze kwechiuno pachayo:

Chikonzero chikuru chekukanganisa kusingafungidzirwe kungaitika ndechekuti nhoroondo isu takanga tisina C99-style "declare variables in loops." Saka list_for_each_entry() - uye nevamwe vese - zvakanyanya kugara uchisefa yekupedzisira HEAD yekupinda kubva muchiuno, nekuda kwekuti isu hatina kukwanisa kuzivisa iterator kusiyanisa muchiuno pachayo.

Izvo zvakakoshawo kutaura izvo mukana wekushandisa chiyero cheC17 chakatariswa, asi munyaya iyi zvingave zvakakosha kuwedzera zvishoma zvakatsigirwa shanduro yeGCC, sezvo kuiswa kwekutsigirwa kweC11 kunopindirana nezvinodiwa zvezvino zveGCC version (5.1).

Finalmente kana iwe uchifarira kuziva zvakawanda nezvazvo, unogona kutarisa ruzivo mu inotevera chinongedzo.


Izvo zviri muchinyorwa zvinoomerera pamisimboti yedu ye tsika dzekunyora. Kuti utaure chikanganiso tinya pano.

Iva wekutanga kutaura

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa.

*

*

  1. Inotarisira data: AB Internet Networks 2008 SL
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako