Tizenãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ãã§ãã¯ã«é¢ããé·ãèšäºã®åŸã誀æ€ç¥ã®å²åãšãšã©ãŒå¯åºŠïŒPVS-Studioãã³ãŒã1000è¡ããšã«æ€åºãããšã©ãŒã®æ°ïŒã«ã€ããŠå€ãã®è³ªåãåããŸããã ããã¯åæå¯Ÿè±¡ã®ãããžã§ã¯ãã«å€§ããäŸåããŠãããã¢ãã©ã€ã¶ãŒã®èšå®ãæ¬åœã®çãã®ããã«ã¯èŠããªããšããç§ã®èãã§ãã ç§ã¯ç¹å®ã®æ°åãä»ããŠãTizenã®äžéšã§ãããããžã§ã¯ãã®1ã€ããã培åºçã«ç ç©¶ããããšã«ããŸããã Carsten Haitzlerããã®èšäºã®è°è«ã«ç©æ¥µçã«åå ããã®ã§ã圌ãé¢äžããŠããEFLã³ã¢ã©ã€ãã©ãªã®å®éšãè¡ãã®ã¯é¢çœããšæããŸããã ãã®èšäºããCarstenãã¢ãã©ã€ã¶ãŒã®ãã¡ã³ã«ãªãã®ã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸã:)ã
èæ¯
èªè
ã®äžäººãèŠéããå Žåãç§ã¯æè¿
Tizenéçºè
ã«å
¬éæžç°¡ãæžã
ãããããèšå¿µç¢çãªèšäºã
Tizenãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§27,000ã®ãšã©ãŒ ããæžã
ãããšãç¥ãããŸãã
ãã®åŸãããã€ãã®ãµã€ãã«é¢é£ãããã¥ãŒã¹èšäºãæ²èŒãããããã€ãã®è°è«ãå§ãŸããŸããã ãããã®ããã€ããæ¬¡ã«ç€ºããŸãã
Carsten Haitzlerã«æè¬ããããšæããŸã
ãCarstenHaitzlerã¯ç§ã®åºçç©ã«æ³šæãæããè°è«ã«ç©æ¥µçã«åå ããŠãããŸããã
ããŸããŸãªãããã¯ãåãäžããããŸãããããã®ãã¡ã®ããã€ãã«ã€ããŠã¯ãèšäºã
TizenïŒsummarizing ãã§è©³çްãªã³ã¡ã³ããè¿°ã¹ãŸããã
ãã ããæ¬¡ã®2ã€ã®æ°žé ã®è³ªåããããŸãã
- 誀æ€ç¥ã®å²åã¯ã©ã®ãããã§ããïŒ
- PVS-Studioã¯1000è¡ã®ã³ãŒãã§ããã€ã®ãšã©ãŒãæ€åºããŸããïŒ
éçåææ¹æ³è«ãäœã§ããããããçè§£ããŠããããã°ã©ããŒã¯ããã®ãããªäžè¬åããã質åãæå³ããªããªãããšã«åæããŸãã ããã¯ãã¹ãŠç§ãã¡ãåãçµãã§ãããããžã§ã¯ãã«äŸåããŸãã ãã®ãããªè³ªåãããããšã¯ããããªãã®ç
é¢ã®æ£è
ã®å¹³åäœæž©ã¯ã©ã®ãããã§ããïŒããšãã質åã«å»åž«ã«å°ããããšãšåãã§ãã
ãããã£ãŠãç¹å®ã®ãããžã§ã¯ãã®äŸã«ã€ããŠåçããŸãã EFL Core Librariesãéžã³ãŸããã ãŸãããã®ãããžã§ã¯ãã¯Tizenã®äžéšã§ãã 第äºã«ãCarsten Haitzlerããã®éçºã«åå ããŠããŸãã圌ãç§ã®çµæãèŠãã®ã¯é¢çœããšæããŸãã
ããªãã¯ãŸã åçºããã§ãã¯ããããšã¯ã§ããŸããããç§ã«ã¯ããããåããããŸããã§ããã ããããªããšãèšäºã¯éåžžã«é·ããªããšæããŸãã
Enlightenment Foundation Libraries ïŒEFLïŒã¯ããŠã£ã³ããŠãããŒãžã£ããã³Waylandãããã³ã«ã§ããEnlightenmentã®éçºã«ç±æ¥ããã°ã©ãã£ãã¯ã©ã€ãã©ãªã®ã³ã¬ã¯ã·ã§ã³ã§ãã
EFLã³ã¢ã©ã€ãã©ãªã確èªãããšãããªããžããª
https://git.enlightenment.org/ããååŸããæ°ããã³ãŒãã䜿çšããŸããã
ãŸãã調æ»å¯Ÿè±¡ã®ãããžã§ã¯ãã¯ãCoverityéçã¢ãã©ã€ã¶ãŒã䜿çšããŠãã§ãã¯ãããããšã«æ³šæããŠãã ããã ãã®ãããã¯ã«é¢ãã
ã³ã¡ã³ãã¯æ¬¡ã®ãšããã§ãã
ãã§ãã¯ãçå£ã«åãæ¢ããŠãããšèšããŸãã Coverityã¯Enlightenmentã¢ããã¹ããªãŒã ã®ãã°ç0ãå ±åããŸãïŒCoverityãææãããã¹ãŠã®åé¡ãä¿®æ£ããããããèŠãŠããåœãšããŠåŽäžããŸããïŒãåé¡ãèŠã€ããã®ã¯ã³ãŒãããŒã¹ã倧ããã»ã©ç°¡åã§ãã ãããã¯ã»ãšãã©ããã»ã©å€§ããªåœ±é¿ãäžãããã®ã§ã¯ãããŸããã ç§ãã¡ããªãªãŒã¹ãããã³ã«ãã°çãäžããããªãªãŒã¹ã®æ°é±éåã«ãåé¡ãä¿®æ£ãããããšãç¹°ãè¿ãåŸåããããŸããããŠãPVS-Studioã¢ãã©ã€ã¶ãŒãã©ã®ããã«ããèªäœãå®èšŒããããèŠãŠã¿ãŸãããã
ç¹åŸŽ
èšå®åŸã®PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãEFLã³ã¢ã©ã€ãã©ãªãããžã§ã¯ãã®ãã§ãã¯æã«çŽ
10ã15ïŒ
ã®èª€æ€ç¥ãçæããŸãã
EFLã³ã¢ã©ã€ãã©ãªã§çŸåšæ€åºãããŠãããšã©ãŒã®å¯åºŠã¯
ãã³ãŒã1000è¡ããã0.71ãè¶
ããŠã
ãŸã ã
èšç®ã¯ã©ãã ã£ã
åææã®EFLã³ã¢ã©ã€ãã©ãªãããžã§ã¯ãã«ã¯ãCããã³C ++ã§çŽ1,616,000è¡ã®ã³ãŒããå«ãŸããŠããŸãã ãããã®ãã¡ã17.7ïŒ
ãã³ã¡ã³ãã§ãã ãããã£ãŠãã³ã¡ã³ãã®ãªãã³ãŒãã®è¡æ°ã¯1,330,000ã§ãã
æåã®å®è¡åŸãæ¬¡ã®æ°ã®æ±çšã¡ãã»ãŒãžïŒGAïŒã衚瀺ãããŸããã
- é«ãç¢ºå®æ§ïŒ605
- å¹³åä¿¡é Œã¬ãã«ïŒ3924
- äœã¬ãã«ã®ä¿¡é ŒïŒ1186
ãã¡ãããããã¯æªãçµæã§ãã ãã®ãããæœè±¡çãªæž¬å®çµæãæžããããªãã®ã§ãã ã¢ãã©ã€ã¶ãŒãæ§æããå¿
èŠããããŸãããä»åã¯æéããããããšã«ããŸããã
ã»ãšãã©ãã¹ãŠã®ãããžã§ã¯ãã¯Cã§èšè¿°ãããŠããããã®çµæããã¯ããåºã䜿çšãããŠããŸãã 誀æ€ç¥ã®å€§åãåŒãèµ·ããã®ã¯ãã¯ãã§ãã ã¬ããŒãããã°ãã衚瀺ããã®ã«çŽ40åãããããã¡ã€ã«
efl_settings.txtãã³ã³ãã€ã«ã
ãŸãã ã
ãã¡ã€ã«ã«ã¯å¿
èŠãªèšå®ãå«ãŸããŠããŸãã ãããžã§ã¯ãããã§ãã¯ãããšãã«ãããã䜿çšããã«ã¯ãã¢ãã©ã€ã¶ãŒæ§æãã¡ã€ã«ïŒããšãã°ãPVS-Studio.cfgïŒã§æå®ããå¿
èŠããããŸãã
rules-config=/path/to/efl_settings.txt
ã¢ãã©ã€ã¶ãŒã¯æ¬¡ã®ããã«èµ·åã§ããŸãã
pvs-studio-analyzer analyze ... --cfg /path/to/PVS-Studio.cfg ...
ãããã
pvs-studio ... --cfg /patn/to/PVS-Studio.cfg ...
䜿çšããçµ±åæ¹æ³ã«ãã£ãŠç°ãªããŸãã
èšå®ã䜿çšããŠãç¹å®ã®ãã¯ããŸãã¯åŒã®ååãå«ãã³ãŒãè¡ã«å¯ŸããŠèŠåãåºããªãããã¢ãã©ã€ã¶ãŒã«æç€ºããŸããã ãŸããããã€ãã®èšºæãå®å
šã«ç¡å¹ã«ããŸããã ããšãã°ã
V505ããªãã«ã
ãŸãã ã ã«ãŒãã§
alloca颿°ã䜿çšããã®ã¯è¯ããããŸããããããã¯æãããªééãã§ã¯ãããŸããã èŠåã誀æ€ç¥ã§ãããã©ããã«ã€ããŠã¯ããŸãè°è«ããããããŸãããäœããç¡å¹ã«ããæ¹ãç°¡åã ãšæããŸããã
ã¯ããæåã®2ã€ã®ã¬ãã«ã®ã¢ã©ãŒãã®ã¿ãèŠãŠèšå®ããŠããããšã«æ³šæããŠãã ããã å°æ¥çã«ã¯ãããã®ã¿ãæ€èšããŸãã ä¿¡é ŒåºŠãäœããšããèŠåãèæ
®ããããšã¯ãå§ãããŸããã å°ãªããšããã¢ãã©ã€ã¶ãŒã®äœ¿çšãéå§ããŠããããããã®èŠåãåŠçããããšã¯äžåçã§ãã æåã®2ã€ã®ã¬ãã«ãçè§£ããŠåããŠã3çªç®ã®ã¬ãã«ãèŠãŠãèªåã®æèŠã§åœ¹ç«ã€èŠåã®çš®é¡ãéžæã§ããŸãã
åèµ·åã«ãããæ¬¡ã®çµæãåŸãããŸããã
- é«ãç¢ºå®æ§ïŒ189
- å¹³åä¿¡é Œã¬ãã«ïŒ1186
- äœã¬ãã«ã®ä¿¡é ŒïŒ1186
çªå·1186ã¯2åç¹°ãè¿ãããŸãããããã¯ã¿ã€ããã¹ã§ã¯ãããŸããã 確ãã«ãæ°åã¯ãšãŠãã©ã³ãã ã«äžèŽããŸããã
ãã®ãããã»ããã¢ããã«40åãè²»ãããåŸã誀æ€ç¥ã®æ°ã倧å¹
ã«æžãããŸããã ãã¡ãããç§ã«ã¯å€ãã®çµéšãããããã®ããã»ã¹ã«ã¯ãµãŒãããŒãã£ã®éçºè
ããããå€ãã®æéãããããŸããããèšå®ããã®ã«ã²ã©ãè€éãªãã®ã¯ãããŸããã
åèšã§ã189 + 1186 = 1375ã®ã¡ãã»ãŒãžïŒé«+äžïŒãåä¿¡ããããã§äœæ¥ãéå§ããŸããã
ãããã®ã¡ãã»ãŒãžãåæããåŸãã¢ãã©ã€ã¶ãŒã¯ãšã©ãŒãå«ã950åã®ã³ãŒããæ€åºãããšèããŠããŸãã ã€ãŸããä¿®æ£ãå¿
èŠãª950åã®ã³ãŒããèŠã€ãããŸããã ãããã®ãšã©ãŒã«ã€ããŠã¯ã次ã®ç« ã§è©³ãã説æããŸãã
ããã§ãæ€åºããããšã©ãŒã®å¯åºŠãèšç®ããŸãã
950 * 1000/1330000 =ã³ãŒã1000è¡ãããçŽ0.71ãšã©ãŒã
次ã«ã誀æ€ç¥ã®å²åãèšç®ããŠã¿ãŸãããã
ïŒïŒ1375-950ïŒ/ 1375ïŒ* 100ïŒ
= 30ïŒ
忢ã忢ãåæ¢ïŒ ãããå®éã«ã¯ãèšäºã®åé ã§ã誀æ€ç¥ã®çŽ10ã15ïŒ
ãšèšãããŠããŸããã ãããŠãããã¯30ïŒ
ã§ãã
ãããã説æããŸãã ããã§ã1375ä»¶ã®ã¡ãã»ãŒãžã®ã¬ããŒããèŠãŠã950ã¯ãšã©ãŒã瀺ããŠãããšããçµè«ã«éããŸããã æ®ã425ã¡ãã»ãŒãžã
ãããã®æ®ãã®425ã¡ãã»ãŒãžã®ãã¹ãŠã誀æ€ç¥ã§ã¯ãããŸããã ãšã©ãŒãæ€åºããããã©ããã ãã§ã¯ããããªãå€ãã®ã¡ãã»ãŒãžã以äžã«ç€ºããŸãã
èŠéããã¡ãã»ãŒãžã®äŸãèããŠã¿ãŸãããã
.... uint64_t callback_mask; .... static void _check_event_catcher_add(void *data, const Efl_Event *event) { .... Evas_Callback_Type type = EVAS_CALLBACK_LAST; .... else if ((type = _legacy_evas_callback_type(array[i].desc)) != EVAS_CALLBACK_LAST) { obj->callback_mask |= (1 << type); } .... }
PVS-StudioèŠåïŒ
V629 ã1 << typeãåŒã®æ€æ»ãæ€èšããŠãã ããã 32ãããå€ã®ãããã·ãããšãããã«ç¶ã64ãããã¿ã€ããžã®æ¡åŒµã evas_callbacks.c 709
è¡ã詳ããèŠãŠã¿ãŸãããã
obj->callback_mask |= (1 << type);
callback_mask倿°ã®ç®çã®ãããã«1ãæžã蟌ãããã«äœ¿çšãããŸãã
callback_mask倿°ã¯64ãããã§ããããšã«æ³šæããŠãã ããã
åŒ
ïŒ1 << typeïŒã¯
intåã§ããããã倿°
callback_maskã®äžéšã®ãããã®ã¿ã倿Žã§ã
ãŸã ã ããã[32-63]ã¯å€æŽã§ããŸããã
ãšã©ãŒããããã©ãããçè§£ããã«ã¯ã
_legacy_evas_callback_type颿°ãè¿ãããšãã§ããå€ã®ç¯å²ãææ¡ããå¿
èŠããããŸãã 31ãã倧ããå€ãè¿ãããšã¯ã§ããŸããïŒ ç§ã¯ãã®ã¡ãã»ãŒãžãç¥ãããã¹ãããããŸãã
ãçè§£ãã ããã ãã®ã³ãŒããèŠãã®ã¯ãããåããŠã§ãäœãããã®ãåãããŸããã ããã«ã
äœçŸãã®ã¢ãã©ã€ã¶ãŒã¡ãã»ãŒãžãç§ãåŸ
ã£ãŠããŸãã ç§ã¯ãã®ãããªåã±ãŒã¹ã«æ
éã«å¯ŸåŠãå§ããããšãã§ããŸããã
Carsten Haitzlerã«ããã³ã¡ã³ãã äžèš-å®éã«ã¯ãæ°ããã€ãã³ãã¿ã€ããå€ãã€ãã³ãã¿ã€ãã«ãããã³ã°ããããšãããã©ãããæ±ºå®ããããã«ããããèšå®ããæé©åã®çµæã§ãããã°ã§ãïŒæ°ãããªããžã§ã¯ãã·ã¹ãã ã®åšãã®å
éšã®å·šå€§ãªãã£ã³ã¯ããªãã¡ã¯ã¿ãªã³ã°ããŠãããããäºææ§ãç¶æããããã«ãããè¡ããŸãããä»ã®ãªãã¡ã¯ã¿ãªã³ã°ãšåæ§ã«...äœããèµ·ãããŸãã ã¯ã-ãããã·ãããã©ãããããã¹ã¯å
ã®åãããããã©ããã¢ã©ãŠã³ãã®ããã«2ã€ã®ã€ãã³ãã§å䜿çšããããããifã®æå
šäœã®è¿œå äœæ¥ãè¡ããŸãã ãã®ãããããã¯ãã°ã«ã€ãªããããšã¯ãªãããããããã¿ã€ãAãã ãã§ãªããã¿ã€ãA OR Bã®ã€ãã³ãã³ãŒã«ããã¯ããããããšãæå³ããå Žåããããã«å°ãªããã€ã¯ãæé©åãè¡ãããŸã...次ã®ã³ãŒãã¯å®éã«å®å
šãªãã§ãã¯ãè¡ããŸã/ãããã³ã°ã ããã¯ç¢ºãã«ã©ããããããšãæå³ãããã®ã§ã¯ãªãã£ãã®ã§ãããã¯ãã£ããã§ããããäœ¿çšæ¹æ³ã¯å®éã«ã¯ããªãç¡å®³ã§ããããšãæå³ããŸããæ®ãã®425åã®ã¡ãã»ãŒãžã®äžã«ã¯ããšã©ãŒã瀺ããã®ããããŸãã èŠéããã°ããã§ãã
PVS-Studioã®éåžžã®äœ¿çšã«é¢ããŠã¯ãåŒãç¶ãæ§æã§ããŸãã ç§ãèšã£ãããã«ãç§ã¯ãã§ã«ã»ããã¢ããã«40åããè²»ãããŠããŸããã ããããããã¯ç§ãã§ããããšããã¹ãŠãã£ããšããæå³ã§ã¯ãããŸããã ç¹å®ã®ãœãããŠã§ã¢æ§æã®èšºæãç¡å¹ã«ããããšã§ã誀æ€ç¥ã®æ°ãæžããããšãã§ããŸãã
æ®ãã®ã¡ãã»ãŒãžãšè¿œå ã®èšå®ãããã«æ
éã«æ€èšãããšã誀æ€ç¥ã®10ã15ïŒ
ããæ®ããŸããã è¯ãçµæã
èŠã€ãã£ããã°
次ã«ãèŠã€ãããšã©ãŒã«ã€ããŠèããŠã¿ãŸãããã 950ããã¹ãŠèª¬æããããšã¯ã§ããŸããããããã£ãŠãåã¿ã€ãã®èŠåã®ãã¢ãè§£æããããšã«éå®ããŸãã æ®ãã®èŠåã¯ãåå¥ã®ãã¡ã€ã«ãšããŠãªã¹ãããŸãã
ãŸããèªè
èªèº«ãã¬ããŒããã¡ã€ã«ãéãããšã«ããããã¹ãŠã®èŠåã«ç²Ÿéããããšãã§ããŸãã ãã¡ã€ã«ã«ã¯é«ããã³äžã®ä¿¡é Œã¬ãã«ã®äžè¬çãªèŠåã®ã¿ãæ®ããããšã«æ³šæããŠãã ããã
ãã®ã¬ããŒããWindowsã§èŠãŠãPVS-Studio StandaloneãŠãŒãã£ãªãã£ã䜿çšããŠéããŸããã
Linuxã§ã¯ãã¬ããŒããæ¬¡ã®ããããã®åœ¢åŒã«å€æããPlog ConverterãŠãŒãã£ãªãã£ã䜿çšã§ããŸãã
- xml-è§£æçµæã®è¿œå åŠçã®ããã®äŸ¿å©ãªãã©ãŒããããSonarQubeã®ãã©ã°ã€ã³ã§ãµããŒããããŠããŸãã
- csvã¯ã衚圢åŒã®ããŒã¿ã衚瀺ããããã®ããã¹ã圢åŒã§ãã
- errorfile -gccããã³clangã®åºå圢åŒã
- tasklistã¯ãQtCreatorã§éãããšãã§ãããšã©ãŒåœ¢åŒã§ãã
ããã«ãã¬ããŒãã衚瀺ããã«ã¯ãQtCreatorãVim / gVimãGNU EmacsãLibreOffice Calcã䜿çšã§ããŸãã ããã«ã€ããŠã¯ãããã¥ã¡ã³ãã»ã¯ã·ã§ã³ã
Linuxã§PVS-Studioãå®è¡ããæ¹æ³ ãã§è©³ãã説æããŠããŸãïŒãã¢ãã©ã€ã¶ãŒã¬ããŒãã®è¡šç€ºãšãã£ã«ã¿ãŒåŠçããåç
§ïŒã
V501ïŒ1ãšã©ãŒïŒ
Diagnostics
V501ã¯1ã€ã®ãšã©ãŒã®ã¿ãæããã«ããŸããããããã¯çŸãããã®ã§ãã ãšã©ãŒã¯æ¯èŒæ©èœã«ãããæè¿ã®èšäºã
æªã¯æ¯èŒæ©èœã«çãã ãã®ããŒããåæ
ããŠããŸã ã
static int _ephysics_body_evas_stacking_sort_cb(const void *d1, const void *d2) { const EPhysics_Body_Evas_Stacking *stacking1, *stacking2; stacking1 = (const EPhysics_Body_Evas_Stacking *)d1; stacking2 = (const EPhysics_Body_Evas_Stacking *)d2; if (!stacking1) return 1; if (!stacking2) return -1; if (stacking1->stacking < stacking2->stacking) return -1; if (stacking2->stacking > stacking2->stacking) return 1; return 0; }
PVS-StudioèŠåïŒV501ã>ãæŒç®åã®å·ŠåŽãšå³åŽã«ã¯ãåäžã®éšååŒãstacking2-> stackingãããããŸãã ephysics_body.cpp 450
ã¿ã€ããã¹ã æåŸã®æ¯èŒã¯æ¬¡ã®ããã«ãªããŸãã
if (stacking1->stacking > stacking2->stacking) return 1;
V512ïŒ8ãšã©ãŒïŒ
ãŸãã
Eina_Arrayæ§é äœã®å®çŸ©ãèŠãŠãã ããã
typedef struct _Eina_Array Eina_Array; struct _Eina_Array { int version; void **data; unsigned int total; unsigned int count; unsigned int step; Eina_Magic __magic; };
å¿
èŠã§ã¯ãªãããšãæ
éã«æ€èšããŠãã ããã ããçš®ã®ãã£ãŒã«ããæã€åãªãæ§é ã
次ã«ã
Eina_Accessor_Arrayæ§é äœã®å®çŸ©ãèŠãŠãã ããã
typedef struct _Eina_Accessor_Array Eina_Accessor_Array; struct _Eina_Accessor_Array { Eina_Accessor accessor; const Eina_Array *array; Eina_Magic __magic; };
Eina_Accessor_Arrayæ§é äœã
Eina_Arrayæ§é äœãžã®ãã€ã³ã¿ãŒãä¿æããŠããããšã«æ³šæããŠ
ãã ãã ã ãã以å€ã®å Žåããããã®æ§é ã¯çžäºæ¥ç¶ãããŠãããããµã€ãºãç°ãªããŸãã
ã¢ãã©ã€ã¶ãŒãç¹å®ããã³ãŒãã§ãç§ãçè§£ã§ããªãã³ãŒãïŒ
static Eina_Accessor * eina_array_accessor_clone(const Eina_Array *array) { Eina_Accessor_Array *ac; EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL); EINA_MAGIC_CHECK_ARRAY(array); ac = calloc(1, sizeof (Eina_Accessor_Array)); if (!ac) return NULL; memcpy(ac, array, sizeof(Eina_Accessor_Array)); return &ac->accessor; }
PVS-StudioèŠåïŒ
V512 ãmemcpyã颿°ãåŒã³åºããšããé
åããããã¡ãŒãç¯å²å€ã«ãªããŸãã eina_array.c 186
äžèŠãªè©³çްããã¹ãŠåé€ããŠãç°¡åã«ããŸãã
.... eina_array_accessor_clone(const Eina_Array *array) { Eina_Accessor_Array *ac = calloc(1, sizeof (Eina_Accessor_Array)); memcpy(ac, array, sizeof(Eina_Accessor_Array)); }
Eina_Accessor_Arrayåã®ãªããžã§ã¯ãã«ã¡ã¢ãªãå²ãåœãŠãããŸãã ãã®åŸãå¥åŠãªããšãèµ·ãããŸãã
ã¿ã€ã
Eina_Arrayã®ãªããžã§ã¯ãã¯ãå²ãåœãŠãããã¡ã¢ãªãããã¡ã«ã³ããŒãããŸãã
èæ
®ããã颿°ãäœããã¹ããã¯ããããŸããããäœãééã£ãŠããŸãã
ãŸããã³ããŒãããšãããœãŒã¹
ã¯ç¯å²å€ã«ãªããŸã ïŒæ§é
Eina_Array ïŒã
第äºã«ãäžè¬çã«ãã®ãããªã³ããŒã¯æå³ããªããŸããã æ§é ã«ã¯ããŸã£ããç°ãªãã¿ã€ãã®ãã£ãŒã«ãã®ã»ããããããŸãã
Carsten Haitzlerã«ããã³ã¡ã³ãã 颿°ã®å
å®¹ãæ£ãã-ãã©ã¡ãŒã¿ãŒã®å
¥åãééã£ãŠããŸãã 颿°ã¯æ£ããåãæã€func ptrã«å²ãåœãŠãããæ±çšã®ã芪ã¯ã©ã¹ãã§ãããããå²ãåœãŠã¯æ±çšã¢ã¯ã»ãµåã«ãã£ã¹ãããããããã³ã³ãã€ã©ã¯æå¥ãèšãããããã¯æ©èœããããã«èŠãããããå®éã«ã¯åé¡ã§ã¯ãããŸããã§ãããæ¬¡ã®ãšã©ãŒãèæ
®ããŠãã ããã
static Eina_Bool _convert_etc2_rgb8_to_argb8888(....) { const uint8_t *in = src; uint32_t *out = dst; int out_step, x, y, k; unsigned int bgra[16]; .... for (k = 0; k < 4; k++) memcpy(out + x + k * out_step, bgra + k * 16, 16); .... }
PVS-StudioèŠåïŒV512ãmemcpyã颿°ãåŒã³åºããšããããã¡ãŒãbgra + k * 16ãããªãŒããŒãããŒããŸãã draw_convert.c 318
ããã§ã¯ãã¹ãŠãç°¡åã§ãã éåžžåºå£ã®æµ·å€ãããã¡ãŒã
bgraé
åã¯ã
unsigned intåã®16åã®èŠçŽ ã§æ§æãããŠããŸãã
倿°
kã¯ããµã€ã¯ã«ã®0ã3ã®å€ãåããŸãã
åŒã«æ³šæããŠãã ããïŒ
bgra + k * 16 ã
倿°
kã®å€ã0ãã倧ããå Žåãé
åã®å€åŽãæããã€ã³ã¿ãŒãèšç®ãããŸãã
ãã ããäžéšã®V512ã¡ãã»ãŒãžã¯ãå®éã®ãšã©ãŒãå«ãŸãªãã³ãŒãã瀺ããŠããŸãã ãã ãããã®ãããªã¢ãã©ã€ã¶ãŒã®å¿çã¯åœãšã¯èŠãªããŸããã ã³ãŒãã¯æªãã®ã§ãç§ã®æèŠã§ã¯ã倿Žããå¿
èŠããããŸãã ãã®å Žåãæ€èšããŠãã ããã
#define MATRIX_XX(m) (m)->xx typedef struct _Eina_Matrix4 Eina_Matrix4; struct _Eina_Matrix4 { double xx; double xy; double xz; double xw; double yx; double yy; double yz; double yw; double zx; double zy; double zz; double zw; double wx; double wy; double wz; double ww; }; EAPI void eina_matrix4_array_set(Eina_Matrix4 *m, const double *v) { memcpy(&MATRIX_XX(m), v, sizeof(double) * 16); }
PVS-StudioèŠåïŒV512ãmemcpyã颿°ãåŒã³åºããšããããã¡ãŒãïŒïŒmïŒ-> xxãããªãŒããŒãããŒããŸãã eina_matrix.c 1003
é
åãæ§é äœã«ã³ããŒããã ãã§æžã¿ãŸãã ãããã代ããã«ãæåã®
xxã¡ã³ããŒã®ã¢ãã¬ã¹ãååŸãããŸãã ãããããå°æ¥ãä»ã®ãã£ãŒã«ããæ§é ã®æåã«çŸãããšçè§£ãããŠããŸãã ãããŠãããã°ã©ã ã®åäœãå£ããªãããã«ããã®ãããªææ³ã䜿çšãããŸãã
Carsten Haitzlerã«ããã³ã¡ã³ãã äžèšããã³é¢é£ããmemcpyã®-ãã°ã§ã¯ãããŸããïŒæ§é äœã§ä¿èšŒãããmemã¬ã€ã¢ãŠããå©çšããŸããç§ã¯åœŒã奜ãã§ã¯ãããŸããã æ¬¡ã®ãããªãã®ãæžãããšããå§ãããŸãã
struct _Eina_Matrix4 { union { struct { double xx; double xy; double xz; double xw; double yx; double yy; double yz; double yw; double zx; double zy; double zz; double zw; double wx; double wy; double wz; double ww; }; double RawArray[16]; }; }; EAPI void void eina_matrix4_array_set(Eina_Matrix4 *m, const double *v) { memcpy(m->RawArray, v, sizeof(double) * 16); }
ããã¯å°ãé·ããªããŸãããã€ããªãã®ãŒçã«ã¯çå®ã§ãã ãã ããã³ãŒããç·šéããããªãå Žåã¯ã次ã®ããããã®æ¹æ³ã§èŠåãæå¶ããããšãã§ããŸãã
æåã®æ¹æ³ã ã³ãŒãã«ã³ã¡ã³ãã远å ããŸãã
memcpy(&MATRIX_XX(m), v, sizeof(double) * 16);
2çªç®ã®æ¹æ³ã èšå®ãã¡ã€ã«ã«æ¬¡ã®è¡ã远å ããŸãã
第äžã®æ¹æ³ã
ããŒã¯ã¢ããããŒã¿ããŒã¹ã䜿çšããŸã ã
ãã®ä»ã®ãšã©ãŒïŒ
- V512ãmemcpyã颿°ãåŒã³åºããšããããã¡ãŒãïŒïŒmïŒ-> xxãããªãŒããŒãããŒããŸãã eina_matrix.c 1098
- V512ãmemcpyã颿°ãåŒã³åºããšããããã¡ãŒãïŒïŒmïŒ-> xxãããªãŒããŒãããŒããŸãã eina_matrix.c 1265
- V512ãmemcpyã颿°ãåŒã³åºããšããïŒpd-> projection.xxããããã¡ãŒãç¯å²å€ã«ãªããŸãã evas_canvas3d_camera.c 120
- V512ãmemcpyã颿°ãåŒã³åºããšããïŒpd-> projection.xxããããã¡ãŒãç¯å²å€ã«ãªããŸãã evas_canvas3d_light.c 270
- V512ãmemcpyã颿°ãåŒã³åºããšããããã¡ãŒãbgra + k * 16ãããªãŒããŒãããŒããŸãã draw_convert.c 350
V517ïŒ3ãšã©ãŒïŒ
static Eina_Bool evas_image_load_file_head_bmp(void *loader_data, Evas_Image_Property *prop, int *error) { .... if (header.comp == 0)
PVS-Studio
èŠå ïŒ
V517 ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ433ã439ãevas_image_load_bmp.c 433
2åã倿°
header.compã¯å®æ°
3ãšæ¯èŒãããŸãã
ãã®ä»ã®ãšã©ãŒïŒ
- V517ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ1248ã1408ãevas_image_load_bmp.c 1248
- V517ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªïŒ426ã432ãparser.c 426
V519ïŒ1ãšã©ãŒïŒ
EOLIAN static Efl_Object * _efl_net_ssl_context_efl_object_finalize(....) { Efl_Net_Ssl_Ctx_Config cfg; .... cfg.load_defaults = pd->load_defaults;
PVS-StudioèŠåïŒ
V519 ãcfg.load_defaultsã倿°ã«ã¯é£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ304ã309ãefl_net_ssl_context.c 309
å²ãåœãŠãç¹°ãè¿ãããŸãã 1ã€ã®å²ãåœãŠãäžèŠã§ããããä»ã®äœããã³ããŒããã®ãå¿ããŠããŸããã
Carsten Haitzlerã«ããã³ã¡ã³ãã ãã°ã§ã¯ãããŸããã è¡ã®ç±å¿ãªã³ããŒïŒããŒã¹ãã ãã§ããå¥ã®åçŽãªã±ãŒã¹ïŒ
EAPI Eina_Bool edje_edit_size_class_add(Evas_Object *obj, const char *name) { Eina_List *l; Edje_Size_Class *sc, *s; .... s->maxh = -1; s->maxh = -1; .... }
PVS-StudioèŠåïŒV519 's-> maxh'倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ8132ã8133ãedje_edit.c 8133
ãã¡ããããã¹ãŠã®ã±ãŒã¹ãããã»ã©æçœã§ã¯ãããŸããã ãã ãã以äžã®èŠåã¯ãšã©ãŒã瀺ããŠããå¯èœæ§ãé«ããšèããŠããŸãã
- V519ãpdata-> seat-> object.inã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ1519ã1521ãevas_events.c 1521
- V519ãpdata-> seat-> object.inã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ2597ã2599ãevas_events.c 2599
- V519 'b-> buffer [r]'倿°ã«ã¯ãå€ãé£ç¶ããŠ2åå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ348ã353ãevas_image_load_pmaps.c 353
- V519ãattr_amountã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªïŒ13891ã13959ãedje_edit.c 13959
- V519ãasync_loader_runningã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªïŒ152ã165ãevas_gl_preload.c 165
- V519ãtextlenã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ããã§ãã¯ïŒ86ã87ãelm_code_widget_undo.c 87
- V519ãcontentã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ313ã315ãelm_dayselector.c 315
- V519ãwd-> resize_objã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ3099ã3105ãelm_entry.c 3105
- V519ãwd-> resize_objã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ3125ã3131ãelm_entry.c 3131
- V519ãidata-> valuesã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ128ã129ãelm_view_list.c 129
- V519ãwd-> resize_objã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ2602ã2608ãefl_ui_text.c 2608
- V519ãwd-> resize_objã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ2628ã2634ãefl_ui_text.c 2634
- V519ãfinfoã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ706ã743ãevas_image_load_gif.c 743
- V519ãcurrent_program_lookupsã倿°ã«ã¯ãé£ç¶ããŠ2åå€ãå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ15819ã15820ãedje_cc_handlers.c 15820
ãæ³šæ Carsten Haitzlerã¯ãã®èšäºã«ã³ã¡ã³ãããŠãèšèŒãããŠããV519èŠåã¯èª€æ€ç¥ã§ãããšæžããŠããŸãã ç§ã¯ãã®ã¢ãããŒãã«åæããŸããã ã³ãŒãã¯æ£ããåäœããå¯èœæ§ããããŸããããšã«ããæ³šæãšç·šéã«å€ããŸãã èªè
ãèªåã®èгç¹ããã倿°ã®èª€æ€åºãžã®å²ãåœãŠã®ç¹°ãè¿ããã©ãããè©äŸ¡ã§ããããã«ãèšäºã«ãªã¹ããæ®ãããšã«ããŸããã ããããCarstenã¯ãããã¯ééãã§ã¯ãªããšèšãã®ã§ãèšç®ã§ã¯èæ
®ããŸãããV522ïŒ563ãšã©ãŒïŒ
EFLãããžã§ã¯ãã«ã¯ããã§ãã¯ã®ååšã«é¢ããåé¡ããããŸããã¡ã¢ãªãå²ãåœãŠãããŠãããã©ããã§ãã äžè¬ã«ããããžã§ã¯ãã«ã¯ãã®ãããªãã§ãã¯ããããŸãã äŸïŒ
if (!(el = malloc(sizeof(Evas_Stringshare_El) + slen + 1))) return NULL;
ããã«ããããã¯å¿
èŠã®ãªãå Žæã§ããããŸãïŒèŠå
V668ã«ã€ããŠã¯ä»¥äžãåç
§ïŒã
ããããéåžžã«å€ãã®å Žæã§æ€èšŒã¯è¡ãããŠããŸããã ããšãã°ãã¢ãã©ã€ã¶ãŒã®ã¡ãã»ãŒãžãããã€ãèããŠã¿ãŸãããã
Carsten Haitzlerã«ããã³ã¡ã³ãã ããã¯ãå°ãªããšãLinuxãåžžã«äž»ãªçŠç¹ã§ãããé·ãéå¯äžã®ã¿ãŒã²ããã§ãã£ããããmalloc / calloc / reallocããã®æ»ãå€ã¯ç¹ã«å°éã§ã¯ä¿¡é Œã§ããªããšããäžè¬çãªåãå
¥ãã§ãã Linuxã¯ããã©ã«ãã§ã¡ã¢ãªããªãŒããŒã³ãããããŸãã ã€ãŸããæ°ããã¡ã¢ãªãååŸããŸãããã«ãŒãã«ã¯å®éã®ç©çã¡ã¢ãªããŒãžããŸã å²ãåœãŠãŠããŸããã ä»®æ³ç©ºéã®ã¿ã è§ŠãããŸã§ã¯ã ã«ãŒãã«ããã®ãªã¯ãšã¹ããåŠçã§ããªãå Žåãããã°ã©ã ã¯æå¹ãªãã€ã³ã¿ãŒã®ããã«èŠããã¡ã¢ãªã«ã¢ã¯ã»ã¹ããããšããŠã¯ã©ãã·ã¥ããŸãã ãããã£ãŠãå°ãªããšãLinuxã§å°ããallocã®æ»ãå€ããã§ãã¯ããããšã®ãã¹ãŠã®äŸ¡å€ã¯äœãã§ãã æã«ã¯ãããè¡ããŸã...æã«ã¯è¡ããŸããã ãã ããéåžžã«å€§éã®ã¡ã¢ãªããªãéããæ»ãå€ã¯äžè¬çã«ä¿¡é Œã§ããŸãããããšãã°ãallocã¯ãµãŒãã¹ãããŸãããããšãã°ãallocãä»®æ³ã¢ãã¬ã¹ç©ºéã«ãŸã£ããåãŸããªãå ŽåããããŸãïŒ32ãããã®å ŽåããããŸãïŒã ã¯ãããªãŒããŒã³ãããã¯èª¿æŽã§ããŸãããã»ãšãã©ã®äººã決ããŠæ¯æããããªãããããã¯èª°ã調æŽã§ããããšããç¥ããªããšããã³ã¹ããããããŸãã 第äºã«ãã¡ã¢ãªã®å°ããªãã£ã³ã¯ã§fi allocã倱æããŸããããšãã°ããªã³ã¯ãªã¹ãããŒã...çŸå®çã«NULLãè¿ãããå Žå...ã¯ã©ãã·ã¥ã¯ã§ããããšãšã»ãŒåçã§ã ã¡ã¢ãªãéåžžã«å°ãªããããã¯ã©ãã·ã¥ããå¯èœæ§ããããŸããglibãg_mallocã§è¡ãããã«ãabortïŒïŒãåŒã³åºããŸãã20ã40ãã€ããå²ãåœãŠãããšãã§ããªãå Žå...äœæ¥ã¡ã¢ãªãæ®ã£ãŠããªããããã·ã¹ãã ãåããããã§ãã ç§ã¯ããã§å°ããªçµã¿èŸŒã¿ã·ã¹ãã ã«ã€ããŠè©±ããŠããã®ã§ã¯ãªããä»®æ³ã¡ã¢ãªãšæ°ã¡ã¬ãã€ãã®ã¡ã¢ãªãåãã倧ããªãã·ã³ãªã©ã«ã€ããŠè©±ããŠããŸãã ãããç§ãã¡ã®ç®æšã§ããã PVS-Studioãããã奜ãŸãªãçç±ãããããŸãã å³å¯ã«ã¯å®éã«ã¯æ£ããã®ã§ãããå®éã«ã¯ããã®ãããªãã®ã®åŠçã«è²»ããããã³ãŒãã¯ãç¶æ³ã®çŸå®ãèãããšãã³ãŒãã®ç¡é§ã§ãã ããã«ã€ããŠã¯åŸã§è©³ãã説æããŸãã static Eina_Debug_Session * _session_create(int fd) { Eina_Debug_Session *session = calloc(1, sizeof(*session)); session->dispatch_cb = eina_debug_dispatch; session->fd = fd;
Carsten Haitzlerã«ããã³ã¡ã³ãã ããã¯2ãæåã«å°çããæ°ããã³ãŒãã§ããŸã æ§ç¯ããã³ãã¹ããããŠããããã©ã€ã ã¿ã€ã ã®æºåãã§ããŠããŸããã ã©ã€ããããã°ã€ã³ãã©ã¹ãã©ã¯ãã£ã®äžéšã§ãããEFLã䜿çšããã¢ããªã¯ããããã¬ããŒã¢ã³ïŒå®è¡ãããŠããå ŽåïŒã«ãã£ãŠå¶åŸ¡ãããå¶åŸ¡ãããŸãïŒã¡ã¢ãªå
ã®ãã¹ãŠã®ãªããžã§ã¯ããšãå®è¡äžã«ã€ã³ããã¹ãã¯ã·ã§ã³ã§ãªããžã§ã¯ãããªãŒãšãã®ç¶æ
ãæ€æ»ããŸãïŒãå®è¡ãåéããŸãã¿ã€ã ã©ã€ã³ãã°ïŒã©ã®ã¹ã¬ããã§ã©ã®é¢æ°åŒã³åºãããªãŒã«ã©ã®ãããã®æéãè²»ããããŠããã-ã©ã®ã¹ã¬ãããã©ã®ã¹ãããã§ms以äžã®ã¹ãããã«CPUæéã䜿çšããŠãããã颿°åŒã³åºããã¢ãã¡ãŒã·ã§ã³ã·ã¹ãã ã®ç¶æ
ãããã³ãŠã§ã€ã¯ã¢ããæã«çžé¢ã€ãã³ããçºçãããŠã§ã€ã¯ã¢ãããããªã¬ãŒããããã€ã¹ã®ã¿ã€ã ã¹ã¿ã³ããªã©...ãã®ã·ããªãªãèãããš...ã¡ã¢ãªã®æåã®ããŒãžã«ã¢ã¯ã»ã¹ããã¯ã©ãã·ã¥ã®ãããã°äžã«å°ããªã»ãã·ã§ã³æ§é äœãåŒã³åºãããšãã§ããªãå Žåã¯ãäœãšåããããè¯ãã§ã...äžèšã®ã¡ã¢ãªããã³ã¢ããŒããªã©ã¢ã³ãã¬ã€ã»ã«ã«ããã«ããã³ã¡ã³ãã ããŸãæç¢ºã§ã¯ãããŸããããããã«æ°ãããã¹ããããŠããªãã³ãŒãããããŸãã éçã¢ãã©ã€ã¶ãŒã¯ãäž»ã«æ°ããã³ãŒãã®ãšã©ãŒãæ¢ãããã«èšèšãããŠããŸããPVS-StudioèŠåïŒ
V522æœåšçãªãã«ãã€ã³ã¿ãŒãã»ãã·ã§ã³ãã®éåç
§ãååšããå¯èœæ§ããããŸãã eina_debug.c 440
calloc颿°ã䜿çšããŠã¡ã¢ãªãå²ãåœãŠãããã«äœ¿çšããŸããã
å¥ã®äŸïŒ
static Reference * _entry_reference_add(Entry *entry, Client *client, unsigned int client_entry_id) { Reference *ref;
PVS-StudioèŠåïŒV522æœåšçãªãã«ãã€ã³ã¿ãŒ 'ref'ã®éåç
§ãããå¯èœæ§ããããŸãã evas_cserve2_cache.c 1404
563åã§ãã èšäºã§ã¯åŒçšã§ããŸããã
EFL_V522.txtãã¡ã€ã«ãžã®ãªã³ã¯ãæäŸããŸãã
V547ïŒ39ãšã©ãŒïŒ
static void _ecore_con_url_dialer_error(void *data, const Efl_Event *event) { Ecore_Con_Url *url_con = data; Eina_Error *perr = event->info; int status; status = efl_net_dialer_http_response_status_get(url_con->dialer); if ((status < 500) && (status > 599)) { DBG("HTTP error %d reset to 1", status); status = 1; } WRN("HTTP dialer error url='%s': %s", efl_net_dialer_address_dial_get(url_con->dialer), eina_error_msg_get(*perr)); _ecore_con_event_url_complete_add(url_con, status); }
PVS-Studio
èŠå ïŒ
V547åŒ 'ïŒã¹ããŒã¿ã¹<500ïŒ&&ïŒã¹ããŒã¿ã¹> 599ïŒ'ã¯åžžã«falseã§ãã ecore_con_url.c 351
ãã§ãã¯ã®æ£ããããŒãžã§ã³ã¯æ¬¡ã®ããã«ãªããŸãã
if ((status < 500) || (status > 599))
ãã®ãšã©ãŒãå«ãã³ãŒãã¹ããããã¯ãããã«2ã€ã®å Žæã«ã³ããŒãããŸããã
- V547åŒ 'ïŒã¹ããŒã¿ã¹<500ïŒ&&ïŒã¹ããŒã¿ã¹> 599ïŒ'ã¯åžžã«falseã§ãã ecore_con_url.c 658
- V547åŒ 'ïŒã¹ããŒã¿ã¹<500ïŒ&&ïŒã¹ããŒã¿ã¹> 599ïŒ'ã¯åžžã«falseã§ãã ecore_con_url.c 1340
次ã®ãšã©ãŒç¶æ³ïŒ
EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) { Eina_Rectangle *match; Eina_Rectangle_Alloc *new; .... match = (Eina_Rectangle *) (new + 1); if (match) era->pool->empty = _eina_rectangle_skyline_list_update( era->pool->empty, match); .... }
PVS-StudioèŠåïŒV547åŒãäžèŽãã¯åžžã«çã§ãã eina_rectangle.c 798
ãŠãããããã€ã³ã¿ãŒã«è¿œå ãããåŸã
NULLããã§ãã¯ããŠãæå³ããããŸããã
å ç®äžã«ãªãŒããŒãããŒãçºçããå Žåã«ã®ã¿ã
äžèŽãã€ã³ã¿ãŒããŒãã«ãªãããšããããŸãã ãã ãããã€ã³ã¿ãŒãªãŒããŒãããŒã¯æªå®çŸ©ã®åäœãšèŠãªãããããããã®ãªãã·ã§ã³ã¯èæ
®ããªãã§ãã ããã
ãããŠããäžã€ã®ã±ãŒã¹ã
EAPI const void * evas_object_smart_interface_get(const Evas_Object *eo_obj, const char *name) { Evas_Smart *s; .... s = evas_object_smart_smart_get(eo_obj); if (!s) return NULL; if (s) .... }
PVS-StudioèŠåïŒV547åŒ 's'ã¯åžžã«çã§ãã evas_object_smart.c 160
ãã€ã³ã¿ãŒã
NULLã®å Žåã颿°ã¯çµäºããŸãã å確èªã¯æå³ããããŸããã
ãã®ä»ã®ãšã©ãŒïŒ
EFL_V547.txtç§ã¯ããããçè§£ããããšã«èå³ããªãã£ãã®ã§ãç§ã¯éããæžãåºããªãã£ãV547èŠåããããŸãã ãããã®äžã«ã¯ãããã«ããã€ãã®ãšã©ãŒããããŸãã
V556ïŒ8ãšã©ãŒïŒ
1ã€ã®ã³ãŒãã§8ã€ã®ãšã©ãŒããã¹ãŠçºè¡ãããŸãã æåã«ã2ã€ã®ãªã¹ãã®çºè¡šãèŠãŠã¿ãŸãããã
typedef enum _Elm_Image_Orient_Type { ELM_IMAGE_ORIENT_NONE = 0, ELM_IMAGE_ORIENT_0 = 0, ELM_IMAGE_ROTATE_90 = 1, ELM_IMAGE_ORIENT_90 = 1, ELM_IMAGE_ROTATE_180 = 2, ELM_IMAGE_ORIENT_180 = 2, ELM_IMAGE_ROTATE_270 = 3, ELM_IMAGE_ORIENT_270 = 3, ELM_IMAGE_FLIP_HORIZONTAL = 4, ELM_IMAGE_FLIP_VERTICAL = 5, ELM_IMAGE_FLIP_TRANSPOSE = 6, ELM_IMAGE_FLIP_TRANSVERSE = 7 } Elm_Image_Orient; typedef enum { EVAS_IMAGE_ORIENT_NONE = 0, EVAS_IMAGE_ORIENT_0 = 0, EVAS_IMAGE_ORIENT_90 = 1, EVAS_IMAGE_ORIENT_180 = 2, EVAS_IMAGE_ORIENT_270 = 3, EVAS_IMAGE_FLIP_HORIZONTAL = 4, EVAS_IMAGE_FLIP_VERTICAL = 5, EVAS_IMAGE_FLIP_TRANSPOSE = 6, EVAS_IMAGE_FLIP_TRANSVERSE = 7 } Evas_Image_Orient;
ã芧ã®ãšããããããã®åæã®å®æ°ã®ååã¯äŒŒãŠããŸãã .
EAPI void elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient) { Efl_Orient dir; Efl_Flip flip; EFL_UI_IMAGE_DATA_GET(obj, sd); sd->image_orient = orient; switch (orient) { case EVAS_IMAGE_ORIENT_0: .... case EVAS_IMAGE_ORIENT_90: .... case EVAS_IMAGE_FLIP_HORIZONTAL: .... case EVAS_IMAGE_FLIP_VERTICAL: .... }
PVS-Studioã®èŠåïŒ
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2141
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2145
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2149
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2153
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2157
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2161
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2165
- V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B:⊠}. efl_ui_image.c 2169
, .
, , . :
- ELM_IMAGE_ORIENT_NONE = 0; EVAS_IMAGE_ORIENT_NONE = 0,
- ELM_IMAGE_ORIENT_0 = 0; EVAS_IMAGE_ORIENT_0 = 0
- ELM_IMAGE_ROTATE_90 = 1; EVAS_IMAGE_ORIENT_90 = 1
- .
, .
Comment by Carsten Haitzler. All of the above orient/rotate enum stuff is intentional. We had to cleanup duplication of enums and we ensured they had the same values so they were interchangeable â we moved from rotate to orient and kept the compatibility. It's part of our move over to the new object system and a lot of code auto-generation etc. that is still underway and beta. It's not an error but intended to do this as part of transitioning, so it's a false positive.. , false positives. , , - , .V558 (4 )
accessor_iterator<T>& operator++(int) { accessor_iterator<T> tmp(*this); ++*this; return tmp; }
PVS-Studio:
V558 Function returns the reference to temporary local object: tmp. eina_accessor.hh 519
,
& :
accessor_iterator<T> operator++(int)
:
- V558 Function returns the reference to temporary local object: tmp. eina_accessor.hh 535
- V558 Function returns the reference to temporary local object: tmp. eina_accessor.hh 678
- V558 Function returns the reference to temporary local object: tmp. eina_accessor.hh 694
V560 (32 )
static unsigned int read_compressed_channel(....) { .... signed char headbyte; .... if (headbyte >= 0) { .... } else if (headbyte >= -127 && headbyte <= -1)
PVS-Studio:
V560 A part of conditional expression is always true: headbyte <= â 1. evas_image_load_psd.c 221
headbyte >= 0,
<= -1 .
å¥ã®ã±ãŒã¹ãèããŠã¿ãŸãããã
static Eeze_Disk_Type _eeze_disk_type_find(Eeze_Disk *disk) { const char *test; .... test = udev_device_get_property_value(disk->device, "ID_BUS"); if (test) { if (!strcmp(test, "ata")) return EEZE_DISK_TYPE_INTERNAL; if (!strcmp(test, "usb")) return EEZE_DISK_TYPE_USB; return EEZE_DISK_TYPE_UNKNOWN; } if ((!test) && (!filesystem))
PVS-Studio: V560 A part of conditional expression is always true: (!test). eeze_disk.c 55
.
test , .
:
EFL_V560.txt .
V568 (3 )
EOLIAN static Eina_Error _efl_net_server_tcp_efl_net_server_fd_socket_activate(....) { .... struct sockaddr_storage *addr; socklen_t addrlen; .... addrlen = sizeof(addr); if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) != 0) .... }
PVS-Studio:
V568 It's odd that 'sizeof()' operator evaluates the size of a pointer to a class, but not the size of the 'addr' class object. efl_net_server_tcp.c 192
, , . :
addrlen = sizeof(*addr);
:
- V568 It's odd that 'sizeof()' operator evaluates the size of a pointer to a class, but not the size of the 'addr' class object. efl_net_server_udp.c 228
- V568 It's odd that 'sizeof()' operator evaluates the size of a pointer to a class, but not the size of the 'addr' class object. efl_net_server_unix.c 198
V571 (6 )
EAPI void eeze_disk_scan(Eeze_Disk *disk) { .... if (!disk->cache.vendor) if (!disk->cache.vendor) disk->cache.vendor = udev_device_get_sysattr_value(....); .... }
PVS-Studio:
V571 Recurring check. The 'if (!disk->cache.vendor)' condition was already verified in line 298. eeze_disk.c 299
.
:
- V571 Recurring check. The 'if (!disk->cache.model)' condition was already verified in line 302. eeze_disk.c 303
- V571 Recurring check. The 'if (priv->last_buffer)' condition was already verified in line 150. emotion_sink.c 152
- V571 Recurring check. The 'if (pd->editable)' condition was already verified in line 892. elm_code_widget.c 894
- V571 Recurring check. The 'if (mnh >= 0)' condition was already verified in line 279. els_box.c 281
- V571 Recurring check. The 'if (mnw >= 0)' condition was already verified in line 285. els_box.c 287
ãæ³šæ Carsten Haitzler . . , . , . , .V575 (126 )
, . .
static void free_buf(Eina_Evlog_Buf *b) { if (!b->buf) return; b->size = 0; b->top = 0; # ifdef HAVE_MMAP munmap(b->buf, b->size); # else free(b->buf); # endif b->buf = NULL; }
PVS-Studio:
V575 The 'munmap' function processes '0' elements. Inspect the second argument. eina_evlog.c 117
b->size 0,
munmap .
, :
static void free_buf(Eina_Evlog_Buf *b) { if (!b->buf) return; b->top = 0; # ifdef HAVE_MMAP munmap(b->buf, b->size); # else free(b->buf); # endif b->buf = NULL; b->size = 0; }
.
EAPI Eina_Bool eina_simple_xml_parse(....) { .... else if ((itr + sizeof("<!>") - 1 < itr_end) && (!memcmp(itr + 2, "", sizeof("") - 1))) .... }
PVS-Studio: V575 The 'memcmp' function processes '0' elements. Inspect the third argument. eina_simple_xml_parser.c 355
, 0 .
.
static void _edje_key_down_cb(....) { .... char *compres = NULL, *string = (char *)ev->string; .... if (compres) { string = compres; free_string = EINA_TRUE; } else free(compres); .... }
PVS-Studio: V575 The null pointer is passed into 'free' function. æåã®åŒæ°ã調ã¹ãŸãã edje_entry.c 2306
compress , .
else free(compres);
.
Comment by Carsten Haitzler. Not a bug but indeed some extra if paranoia like code that isn't needed. Micro optimizations again?. . , . , , . , , .:
- V575 The null pointer is passed into 'free' function. æåã®åŒæ°ã調ã¹ãŸãã efl_ui_internal_text_interactive.c 1022
- V575 The null pointer is passed into 'free' function. æåã®åŒæ°ã調ã¹ãŸãã edje_cc_handlers.c 15962
V575 . - , , V522.
static void _fill_all_outs(char **outs, const char *val) { size_t vlen = strlen(val); for (size_t i = 0; i < (sizeof(_dexts) / sizeof(char *)); ++i) { if (outs[i]) continue; size_t dlen = strlen(_dexts[i]); char *str = malloc(vlen + dlen + 1); memcpy(str, val, vlen); memcpy(str + vlen, _dexts[i], dlen); str[vlen + dlen] = '\0'; outs[i] = str; } }
PVS-Studio: V575 The potential null pointer is passed into 'memcpy' function. æåã®åŒæ°ã調ã¹ãŸãã main.c 112
, , .
:
EFL_V575.txt .
V587 (2 )
void _ecore_x_event_handle_focus_in(XEvent *xevent) { .... e->time = _ecore_x_event_last_time; _ecore_x_event_last_time = e->time; .... }
PVS-Studio:
V587 An odd sequence of assignments of this kind: A = B; B = A;. Check lines: 1006, 1007. ecore_x_events.c 1007
Comment by Carsten Haitzler. Not bugs as such â looks like just overzealous storing of last timestamp. This is adding a timestamp to an event when no original timestamp exists so we can keep a consistent structure for events with timestamps, but it is code clutter and a micro optimization.. , . , Carsten , . .: V587 An odd sequence of assignments of this kind: A = B; B = A;. Check lines: 1050, 1051. ecore_x_events.c 1051
V590 (3 )
static int command(void) { .... while (*lptr == ' ' && *lptr != '\0') lptr++; .... }
PVS-Studio:
V590 Consider inspecting the '* lptr == ' ' && * lptr != '\0'' expression. The expression is excessive or contains a misprint. embryo_cc_sc2.c 944
. :
while (*lptr == ' ')
:
- V590 Consider inspecting the 'sym->ident == 9 || sym->ident != 10' expression. The expression is excessive or contains a misprint. embryo_cc_sc3.c 1782
- V590 Consider inspecting the '* p == '\n' || * p != '\"'' expression. The expression is excessive or contains a misprint. cpplib.c 4012
V591 (1 )
_self_type& operator=(_self_type const& other) { _base_type::operator=(other); }
PVS-Studio:
V591 Non-void function should return a value. eina_accessor.hh 330
V595 (4 )
static void eng_image_size_get(void *engine EINA_UNUSED, void *image, int *w, int *h) { Evas_GL_Image *im; if (!image) { *w = 0;
PVS-Studioã®èŠåïŒ
- V595 The 'w' pointer was utilized before it was verified against nullptr. Check lines: 575, 585. evas_engine.c 575
- V595 The 'h' pointer was utilized before it was verified against nullptr. Check lines: 576, 586. evas_engine.c 576
if (w) if (h) ,
w h NULL . , .
eng_image_size_get :
eng_image_size_get(NULL, NULL, NULL, NULL);
.
, , , :
- V595 The 'cur->node' pointer was utilized before it was verified against nullptr. Check lines: 9889, 9894. evas_object_textblock.c 9889
- V595 The 'subtype' pointer was utilized before it was verified against nullptr. Check lines: 2200, 2203. eet_data.c 2200
V597 (6 )
EAPI Eina_Binbuf * emile_binbuf_decipher(Emile_Cipher_Algorithm algo, const Eina_Binbuf *data, const char *key, unsigned int length) { .... Eina_Binbuf *result = NULL; unsigned int *over; EVP_CIPHER_CTX *ctx = NULL; unsigned char ik[MAX_KEY_LEN]; unsigned char iv[MAX_IV_LEN]; .... on_error: memset(iv, 0, sizeof (iv)); memset(ik, 0, sizeof (ik)); if (ctx) EVP_CIPHER_CTX_free(ctx); eina_binbuf_free(result); return NULL; }
PVS-Studioã®èŠåïŒ
- V597 The compiler could delete the 'memset' function call, which is used to flush 'iv' buffer. ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿
èŠããããŸãã emile_cipher_openssl.c 293
- V597 The compiler could delete the 'memset' function call, which is used to flush 'ik' buffer. ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿
èŠããããŸãã emile_cipher_openssl.c 294
,
memset . . - ,
V597 .
Comment by Carsten Haitzler. Above 2 â totally familiar with the issue. The big problem is memset_s is not portable or easily available, thus why we don't use it yet. You have to do special checks for it to see if it exists as it does not exist everywhere. Just as a simple example add AC_CHECK_FUNCS([memset_s]) to your configure.ac and memset_s is not found you have to jump through some more hoops like define __STDC_WANT_LIB_EXT1__ 1 before including system headers⊠and it's still not declared. On my pretty up to date Arch system memset_s is not defined by any system headers, same on debian testing⊠warning: implicit declaration of function 'memset_s'; did you mean memset'? [-Wimplicit-function-declaration], and then compile failure⊠no matter what I do. A grep -r of all my system includes shows no memset_s declared⊠so I think advising people to use memset_s is only a viable advice if its widely available and usable. Be aware of this.:
- V597 The compiler could delete the 'memset' function call, which is used to flush 'key_material' buffer. ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿
èŠããããŸãã emile_cipher_openssl.c 144
- V597 The compiler could delete the 'memset' function call, which is used to flush 'iv' buffer. ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿
èŠããããŸãã emile_cipher_openssl.c 193
- V597 The compiler could delete the 'memset' function call, which is used to flush 'ik' buffer. ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿
èŠããããŸãã emile_cipher_openssl.c 194
- V597 The compiler could delete the 'memset' function call, which is used to flush 'key_material' buffer. ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿
èŠããããŸãã emile_cipher_openssl.c 249
V609 (1 )
eina_value_util_type_size .
static inline size_t eina_value_util_type_size(const Eina_Value_Type *type) { if (type == EINA_VALUE_TYPE_INT) return sizeof(int32_t); if (type == EINA_VALUE_TYPE_UCHAR) return sizeof(unsigned char); if ((type == EINA_VALUE_TYPE_STRING) || (type == EINA_VALUE_TYPE_STRINGSHARE)) return sizeof(char*); if (type == EINA_VALUE_TYPE_TIMESTAMP) return sizeof(time_t); if (type == EINA_VALUE_TYPE_ARRAY) return sizeof(Eina_Value_Array); if (type == EINA_VALUE_TYPE_DOUBLE) return sizeof(double); if (type == EINA_VALUE_TYPE_STRUCT) return sizeof(Eina_Value_Struct); return 0; }
, 0. , :
static inline unsigned int eina_value_util_type_offset(const Eina_Value_Type *type, unsigned int base) { unsigned size, padding; size = eina_value_util_type_size(type); if (!(base % size)) return base; padding = ( (base > size) ? (base - size) : (size - base)); return base + padding; }
PVS-Studio:
V609 Mod by zero. Denominator range [0..24]. eina_inline_value_util.x 60
. ,
eina_value_util_type_size 0. .
Comment by Carsten Haitzler. The 0 return would only happen if you have provided totally invalid input, like again strdup(NULL)⊠So I call this a false positive as you cant have an eina_value generic value that is not valid without bad stuff happening â validate you passes a proper value in first. eina_value is performance sensitive btw so every check here costs something. it's like adding if() checks to the add opcode.V610 (1 )
void fetch_linear_gradient(....) { .... if (t + inc*length < (float)(INT_MAX >> (FIXPT_BITS + 1)) && t+inc*length > (float)(INT_MIN >> (FIXPT_BITS + 1))) .... }
PVS-Studio:
V610 Unspecified behavior. ã·ããæŒç®åã>>ãã確èªããŠãã ããã The left operand '(- 0x7fffffff â 1)' is negative. ector_software_gradient.c 412
V614 (1 )
extern struct tm *gmtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__)); static void _set_headers(Evas_Object *obj) { static char part[] = "ch_0.text"; int i; struct tm *t; time_t temp; ELM_CALENDAR_DATA_GET(obj, sd); elm_layout_freeze(obj); sd->filling = EINA_TRUE; t = gmtime(&temp);
PVS-Studio:
V614 Uninitialized variable 'temp' used. Consider checking the first actual argument of the 'gmtime' function. elm_calendar.c 720
V621 (1 )
static void _opcodes_unregister_all(Eina_Debug_Session *session) { Eina_List *l; int i; _opcode_reply_info *info = NULL; if (!session) return; session->cbs_length = 0; for (i = 0; i < session->cbs_length; i++) eina_list_free(session->cbs[i]); .... }
PVS-Studio:
V621 Consider inspecting the 'for' operator. It's possible that the loop will be executed incorrectly or won't be executed at all. eina_debug.c 405
V630 (2 )
btVector3 . , .
class btVector3 { public: .... btScalar m_floats[4]; inline btVector3() { } .... };
Simulation_Msg :
typedef struct _Simulation_Msg Simulation_Msg; struct _Simulation_Msg { EPhysics_Body *body_0; EPhysics_Body *body_1; btVector3 pos_a; btVector3 pos_b; Eina_Bool tick:1; };
,
btVector3 . , :
_ephysics_world_tick_dispatch(EPhysics_World *world) { Simulation_Msg *msg; if (!world->ticked) return; world->ticked = EINA_FALSE; world->pending_ticks++; msg = (Simulation_Msg *) calloc(1, sizeof(Simulation_Msg)); msg->tick = EINA_TRUE; ecore_thread_feedback(world->cur_th, msg); }
PVS-Studio:
V630 The 'calloc' function is used to allocate memory for an array of objects which are classes containing constructors. ephysics_world.cpp 299
, non-POD ,
calloc .
, . .
: V630 The 'calloc' function is used to allocate memory for an array of objects which are classes containing constructors. ephysics_world.cpp 471
Comment by Carsten Haitzler. Because the other end of the pipe is C code that is passing around a raw ptr as the result from thread A to thread B, it's a mixed c and c++ environment. In the end we'd be sending raw ptr's around no matter what...V654 (2 )
int evas_mem_free(int mem_required EINA_UNUSED) { return 0; } int evas_mem_degrade(int mem_required EINA_UNUSED) { return 0; } void * evas_mem_calloc(int size) { void *ptr; ptr = calloc(1, size); if (ptr) return ptr; MERR_BAD(); while ((!ptr) && (evas_mem_free(size))) ptr = calloc(1, size); if (ptr) return ptr; while ((!ptr) && (evas_mem_degrade(size))) ptr = calloc(1, size); if (ptr) return ptr; MERR_FATAL(); return NULL; }
PVS-Studioã®èŠåïŒ
- V654 The condition '(!ptr) && (evas_mem_free(size))' of loop is always false. main.c 44
- V654 The condition '(!ptr) && (evas_mem_degrade(size))' of loop is always false. main.c 46
- .
Comment by Carsten Haitzler. Old old code because caching was implemented, so it was basically a lot of NOP's waiting to be filled in. since evas speculatively cached data (megabytes of it) the idea was that if allocs fail â free up some cache and try again⊠if that fails then actually try nuke some non-cached data that could be reloaded/rebuilt but with more cost⊠and only fail after that. But because of overcommit this didn't end up practical as allocs would succeed then just fall over often enough if you did hit a really low memory situation, so I gave up. it's not a bug. it's a piece of history :)..
EAPI void evas_common_font_query_size(....) { .... size_t cluster = 0; size_t cur_cluster = 0; .... do { cur_cluster = cluster + 1; glyph--; if (cur_w > ret_w) { ret_w = cur_w; } } while ((glyph > first_glyph) && (cur_cluster == cluster)); .... }
PVS-Studio:
V654 The condition of loop is always false. evas_font_query.c 376
:
cur_cluster = cluster + 1;
,
(cur_cluster == cluster) false .
Comment by Carsten Haitzler. Above⊠it seems you built without harfbuzz support⊠we highly don't recommend that. it's not tested. Building without basically nukes almost all of the interesting unicode/intl support for text layout. You do have to explicitly â disable it⊠because with harfbuzz support we have opentype enabled and a different bit of code is executed due to ifdefs⊠if you actually check history of the code before adding opentype support it didn't loop over clusters at all or even glyphs⊠so really the ifdef just ensures the loop only loops one and avoids more ifdefs later in the loop conditions making the code easier to maintain â beware the ifdefs!V668 (21 )
, ,
malloc /
calloc .
new - .
:
static EPhysics_Body * _ephysics_body_rigid_body_add(....) { .... motion_state = new btDefaultMotionState(); if (!motion_state) { ERR("Couldn't create a motion state."); goto err_motion_state; } .... }
PVS-Studio:
V668 There is no sense in testing the 'motion_state' pointer against null, as the memory was allocated using the 'new' operator. ã¡ã¢ãªå²ãåœãŠãšã©ãŒã®å ŽåãäŸå€ãçæãããŸãã ephysics_body.cpp 837
,
std::bad_alloc .
Comment by Carsten Haitzler. Fair enough, but be aware some compiler DON'T throw exceptions⊠they return NULL on new⊠so not totally useless code depending on the compiler. I believe VSC6 didn't throw an exception â so before exceptions were a thing this actually was correct behavior, also I depends on the allocator func if it throws and exception or not, so all in all, very minor harmless code.. . . .:
EAPI EPhysics_Constraint * ephysics_constraint_linked_add(EPhysics_Body *body1, EPhysics_Body *body2) { .... constraint->bt_constraint = new btGeneric6DofConstraint( *ephysics_body_rigid_body_get(body1), *ephysics_body_rigid_body_get(body2), btTransform(), btTransform(), false); if (!constraint->bt_constraint) { ephysics_world_lock_release(constraint->world); free(constraint); return NULL; } .... }
PVS-Studio: V668 There is no sense in testing the 'constraint->bt_constraint' pointer against null, as the memory was allocated using the 'new' operator. ã¡ã¢ãªå²ãåœãŠãšã©ãŒã®å ŽåãäŸå€ãçæãããŸãã ephysics_constraints.cpp 382
, , ,
free .
Comment by Carsten Haitzler. Same as previous new + NULL check.. , Visual C++ 6.0. , new. , , . Tizen Visual C++ 6.0! . , . , . , . , memory-leak. , new , new(nothrow). . , , .:
EFL_V668.txt .
V674 (2 )
,
abs :
extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
,
int .
, .
#define ELM_GESTURE_MINIMUM_MOMENTUM 0.001 typedef int Evas_Coord; struct _Elm_Gesture_Momentum_Info { .... Evas_Coord mx; Evas_Coord my; .... }; static void _momentum_test(....) { .... if ((abs(st->info.mx) > ELM_GESTURE_MINIMUM_MOMENTUM) || (abs(st->info.my) > ELM_GESTURE_MINIMUM_MOMENTUM)) state_to_report = ELM_GESTURE_STATE_END; .... }
PVS-Studioã®èŠåïŒ
- V674 The '0.001' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'abs(st->info.mx) > 0.001' expression. elm_gesture_layer.c 2533
- V674 The '0.001' literal of the 'double' type is compared to a value of the 'int' type. Consider inspecting the 'abs(st->info.my) > 0.001' expression. elm_gesture_layer.c 2534
,
int 0.001. - .
V686 (3 )
static Image_Entry * _scaled_image_find(Image_Entry *im, ....) { size_t pathlen, keylen, size; char *hkey; Evas_Image_Load_Opts lo; Image_Entry *ret; if (((!im->file) || ((!im->file) && (!im->key))) || (!im->data1) || ((src_w == dst_w) && (src_h == dst_h)) || ((!im->flags.alpha) && (!smooth))) return NULL; .... }
PVS-Studio:
V686 A pattern was detected: (!im->file) || ((!im->file) && ...). The expression is excessive or contains a logical error. evas_cache2.c 825
, . .
if (A || (A && B) || C)
:
if (A || C)
, - - . . .
:
- V686 A pattern was detected: (!im->file) || ((!im->file) && ...). The expression is excessive or contains a logical error. evas_cache2.c 905
- V686 A pattern was detected: (nextc == '*') || ((nextc == '*') && ...). The expression is excessive or contains a logical error. cpplib.c 1022
V694 (2 )
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1) static void initialize_builtins(cpp_reader * pfile) { .... cpp_buffer *pbuffer = CPP_BUFFER(pfile); while (CPP_PREV_BUFFER(pbuffer)) pbuffer = CPP_PREV_BUFFER(pbuffer); .... }
PVS-Studio:
V694 The condition ((pbuffer) + 1) is only false if there is pointer overflow which is undefined behavior anyway. cpplib.c 2496
, .
cpp_buffer *pbuffer = ....; while (pbuffer + 1) ....
. , . . undefined behavior, . , :
while (true) pbuffer = CPP_PREV_BUFFER(pbuffer);
.
: V694 The condition ((ip) + 1) is only false if there is pointer overflow which is undefined behavior anyway. cpplib.c 2332
Comment by Carsten Haitzler. This old code indeed has issues. There should be checks against CPP_NULL_BUFFER(pfile) because if its a linked list this is a null heck, if its a static buffer array as a stack, it checks stack end position â interestingly in decades it's never been triggered that I know of.V701 (69 )
static void _efl_vg_gradient_efl_gfx_gradient_stop_set( ...., Efl_VG_Gradient_Data *pd, ....) { pd->colors = realloc(pd->colors, length * sizeof(Efl_Gfx_Gradient_Stop)); if (!pd->colors) { pd->colors_count = 0; return ; } memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop)); pd->colors_count = length; _efl_vg_changed(obj); }
PVS-Studio:
V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'pd->colors' is lost. Consider assigning realloc() to a temporary pointer. evas_vg_gradient.c 14
:
pd->colors = realloc(pd->colors, ....);
pd->colors . , . ,
pd->colors NULL .
. , . , , . :
EOLIAN void _evas_canvas_key_lock_add( Eo *eo_e, Evas_Public_Data *e, const char *keyname) { if (!keyname) return; if (e->locks.lock.count >= 64) return; evas_key_lock_del(eo_e, keyname); e->locks.lock.count++; e->locks.lock.list = realloc(e->locks.lock.list, e->locks.lock.count * sizeof(char *)); e->locks.lock.list[e->locks.lock.count - 1] = strdup(keyname); eina_hash_free_buckets(e->locks.masks); }
PVS-Studio: V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'e->locks.lock.list' is lost. Consider assigning realloc() to a temporary pointer. evas_key.c 142
:
EFL_701.txt .
V728 (4 )
static Eina_Bool _evas_textblock_node_text_adjust_offsets_to_start(....) { Evas_Object_Textblock_Node_Format *last_node, *itr; .... if (!itr || (itr && (itr->text_node != n))) .... }
PVS-Studio:
V728 An excessive check can be simplified. ã||ã operator is surrounded by opposite expressions '!itr' and 'itr'. evas_object_textblock.c 9505
, . :
if (!itr || (itr->text_node != n))
:
- V728 An excessive check can be simplified. ã||ã operator is surrounded by opposite expressions '!p' and 'p'. elm_theme.c 447
- V728 An excessive check can be simplified. ã||ã operator is surrounded by opposite expressions '!ss' and 'ss'. config.c 3932
- V728 An excessive check can be simplified. ã||ã operator is surrounded by opposite expressions '!icon_version' and 'icon_version'. efreet_icon_cache_create.c 917
V769 (11 )
V522, . .
EAPI Eina_Bool edje_edit_sound_sample_add( Evas_Object *obj, const char *name, const char *snd_src) { .... ed->file->sound_dir->samples = realloc(ed->file->sound_dir->samples, sizeof(Edje_Sound_Sample) * ed->file->sound_dir->samples_count); sound_sample = ed->file->sound_dir->samples + ed->file->sound_dir->samples_count - 1; sound_sample->name = (char *)eina_stringshare_add(name); .... }
PVS-Studio:
V769 The 'ed->file->sound_dir->samples' pointer in the expression could be nullptr. In such case, resulting value of arithmetic operations on this pointer will be senseless and it should not be used. edje_edit.c 1271
. , . , , . , , . .
, , . . (NULL + N) , - .
:
- V769 The 'new_txt' pointer in the 'new_txt + outlen' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã eina_str.c 539
- V769 The 'new_txt' pointer in the 'new_txt + outlen' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã eina_str.c 611
- V769 The 'tmp' pointer in the 'tmp ++' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã evas_object_textblock.c 11131
- V769 The 'dst' pointer in the 'dst += sizeof (int)' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã evas_font_compress.c 218
- V769 The 'content' pointer in the 'content + position' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã elm_code_line.c 78
- V769 The 'newtext' pointer in the 'newtext + length1' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã elm_code_line.c 102
- V769 The 'tmp' pointer in the 'tmp + dirlen' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã elm_code_file.c 101
- V769 The 'ptr' pointer in the 'ptr += strlen(first) + newline_len' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã elm_code_widget_text.c 72
- V769 The 'content' pointer in the 'content + 319' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã test_store.c 198
- V769 The 'pos' pointer in the 'pos += sizeof (msg)' expression could be nullptr. ãã®ãããªå Žåãçµæã®å€ã¯ç¡æå³ã«ãªãã䜿çšããªãã§ãã ããã evas_cserve2_cache.c 2534
V779 (19 )
V779 , , . äŸïŒ
EAPI Eina_Bool ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, int *w, int *h) { LOGFN(__FILE__, __LINE__, __FUNCTION__); #ifdef ECORE_XINERAMA if (_xin_info) { int i; for (i = 0; i < _xin_scr_num; i++) { if (_xin_info[i].screen_number == screen) { if (x) *x = _xin_info[i].x_org; if (y) *y = _xin_info[i].y_org; if (w) *w = _xin_info[i].width; if (h) *h = _xin_info[i].height; return EINA_TRUE; } } } #endif if (x) *x = 0; if (y) *y = 0; if (w) *w = DisplayWidth(_ecore_x_disp, 0); if (h) *h = DisplayHeight(_ecore_x_disp, 0); return EINA_FALSE; screen = 0;
PVS-StudioèŠåïŒV779å°éäžèœã³ãŒããæ€åºãããŸããã ãšã©ãŒãååšããå¯èœæ§ããããŸãã ecore_x_xinerama.c 92
,
screen . - , , , .
EINA_UNUSED .
:
extern void _exit (int __status) __attribute__ ((__noreturn__)); static void _timeout(int val) { _exit(-1); if (val) return; }
PVS-StudioèŠåïŒV779å°éäžèœã³ãŒããæ€åºãããŸããã ãšã©ãŒãååšããå¯èœæ§ããããŸãã timeout.c 30
_exit . . , :
static void _timeout(int val) { if (val) return; _exit(-1); }
Comment by Carsten Haitzler. Not a bug. it's also an unused param thing from before the macros. The timeout has the process self exit in case it takes too long (assuming the decoder lib is stuck if a timeout happens).. . , , . . , .:
EFL_V779.txt .
V1001 (6 )
static Elocation_Address *address = NULL; EAPI Eina_Bool elocation_address_get(Elocation_Address *address_shadow) { if (!address) return EINA_FALSE; if (address == address_shadow) return EINA_TRUE; address_shadow = address; return EINA_TRUE; }
PVS-Studio:
V1001 The 'address_shadow' variable is assigned but is not used until the end of the function. elocation.c 1122
. , :
*address_shadow = *address;
:
- V1001 The 'screen' variable is assigned but is not used until the end of the function. ecore_x_xinerama.c 92
- V1001 The 'ret' variable is assigned but is not used until the end of the function. edje_edit.c 12774
- V1001 The 'ret' variable is assigned but is not used until the end of the function. edje_edit.c 15884
- V1001 The 'position_shadow' variable is assigned but is not used until the end of the function. elocation.c 1133
- V1001 The 'status_shadow' variable is assigned but is not used until the end of the function. elocation.c 1144
Carsten Haitzler
PVS-Studio Coverity. ( , ). , , (). , Coverity, . , PVS-Studio Coverity , Coverity , , . , , -, PVS-Studio Coverity, â .
ãããã«
,
, .
, . , EFL Coverity. , PVS-Studio . , PVS-Studio , :). , , PVS-Studio, Coverity, PVS-Studio .
PVS-Studio :
.
ãã®èšäºãè±èªåã®èŽè¡ãšå
±æãããå Žåã¯ã翻蚳ãžã®ãªã³ã¯ã䜿çšããŠãã ããïŒAndrey Karpovã
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives