-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


Unreal Engine

, 27 2017 . 10:49 +
PVS-Studio & Unreal Engine

Unreal Engine . , . PVS-Studio. , . , .

, PVS-Studio. Unreal Engine Blog: "Static Analysis as Part of the Development Process in Unreal Engine".

,


. . .

(code review) . . , . , , . . , .

, , . (Steve McConnell, Code Complete).

:
  1. . . . , , .
  2. , / . , , malloc - , stdlib.h. " 64- ". : . , , . , , , - .

, . . . . , . , , . , / , .

, . . , , : , , , -, .

, , .

, , . , , , , ( ):

 1.           (      .  " ").

1. ( . ).

, , .

. . , . .

, 1000 . :

 2.      .  : "Program Quality and Programmer Productivity" (Jones, 1977), "Estimating Software Costs" (Jones, 1998).

2. . : Program Quality and Programmer Productivity (Jones, 1977), Estimating Software Costs (Jones, 1998).

, .



1. . . . .

, , . , , , 8 . : , .

, , , . , .

, , . :
  1. . .
  2. . .
  3. . List of tools for static code analysis.
  4. Al Bessey, Ken Block, Ben Chelf, Andy Chou, Bryan Fulton, Seth Hallem, Charles Henri-Gros, Asya Kamsky, Scott McPeak, Dawson Engler. A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World.
  5. . .
  6. PVS-Studio.

, , Unreal Engine.

Unreal Engine


Unreal Engine!

, . . .

, . - , . . , , " ".

Unreal Engine . - , - . . , , PVS-Studio.

Epic Games , PVS-Studio. , , : , Epic Games, . , Epic Games. , . , , .

, PVS-Studio ? , , :
  • GCC ()
  • Clang (, , )
  • Valgrind ()
  • GDB ()
  • FreeBSD (, )
  • .

PVS-Studio . Epic Games , Unreal Engine . - .


Unreal Engine , , , , . , pull request GitHub. pull request Unreal Engine GitHub. GitHub EpicGames, unrealengine.com. Epic Games GitHub. .

PVS-Studio , . , . :
uint8* Data = (uint8*)PointerVal;

if (Data != nullptr || DataLen == 0)
{
  NUTDebug::LogHexDump(Data, DataLen);
}
else if (Data == nullptr)
{
  Ar.Logf(TEXT("Invalid Data parameter."));
}
else // if (DataLen == 0)
{
  Ar.Logf(TEXT("Invalid DataLen parameter."));
}

PVS-Studio: V547 Expression 'Data == nullptr' is always true. unittestmanager.cpp 1924

(Data != nullptr || DataLen == 0) , , Data nullptr. , (Data == nullptr) .

:
if (Data != nullptr && DataLen > 0)

V547 2010 . , . DataLen, , . , , .

PVS-Studio, . , , .. .

, , C++. C++11, C++14 . , . V714, range-based . Unreal Engine V714 :
for (TSharedPtr SlateWidget : SlateWidgets)
{
  SlateWidget = nullptr; 
}

PVS-Studio: V714 Variable is not passed into foreach loop by a reference, but its value is changed inside of the loop. vreditorradialfloatingui.cpp 170

nullptr SlateWidgets. , SlateWidget , . . , :
for (TSharedPtr &SlateWidget : SlateWidgets)
{
  SlateWidget = nullptr; 
}

, , , . , V767 2015 , Unreal Engine. PVS-Studio 6.07 (8 2016). :
for(int i = 0; i < SelectedObjects.Num(); ++i)
{
  UObject* Obj = SelectedObjects[0].Get();
  EdObj = Cast(Obj);
  if(EdObj)
  {
    break;
  }
}

PVS-Studio: V767 Suspicious access to element of 'SelectedObjects' array by a constant index inside a loop. skeletonnotifydetails.cpp 38

, UEditorSkeletonNotifyObj. - i 0.

:
UObject* Obj = SelectedObjects[i].Get();

V763, , V767, PVS-Studio 6.07. , , , RunTest:
bool FCreateBPTemplateProjectAutomationTests::RunTest(
  const FString& Parameters)
{
  TSharedPtr NewProjectWizard;
  NewProjectWizard = SNew(SNewProjectWizard);

  TMap> >& Templates =
    NewProjectWizard->FindTemplateProjects();
  int32 OutMatchedProjectsDesk = 0;
  int32 OutCreatedProjectsDesk = 0;
  GameProjectAutomationUtils::CreateProjectSet(Templates, 
    EHardwareClass::Desktop, 
    EGraphicsPreset::Maximum, 
    EContentSourceCategory::BlueprintFeature,
    false,
    OutMatchedProjectsDesk,
    OutCreatedProjectsDesk);

  int32 OutMatchedProjectsMob = 0;
  int32 OutCreatedProjectsMob = 0;
  GameProjectAutomationUtils::CreateProjectSet(Templates, 
    EHardwareClass::Mobile,
    EGraphicsPreset::Maximum,
    EContentSourceCategory::BlueprintFeature,
    false,
    OutMatchedProjectsMob,
    OutCreatedProjectsMob);

  return ( OutMatchedProjectsDesk == OutCreatedProjectsDesk ) &&
         ( OutMatchedProjectsMob  == OutCreatedProjectsMob  );
}

:
  • CreateProjectSet OutMatchedProjectsDesk OutCreatedProjectsDesk.
  • CreateProjectSet OutMatchedProjectsMob OutCreatedProjectsMob.

, :
return ( OutMatchedProjectsDesk == OutCreatedProjectsDesk ) &&
       ( OutMatchedProjectsMob  == OutCreatedProjectsMob  );

, . , , CreateProjectSet , , .

CreateProjectSet:
static void CreateProjectSet(.... int32 OutCreatedProjects,
                                  int32 OutMatchedProjects)
{
  ....
  OutCreatedProjects = 0;
  OutMatchedProjects = 0;
  ....
  OutMatchedProjects++;
  ....
  OutCreatedProjects++;
  ....
}

PVS-Studio :
  • V763 Parameter 'OutCreatedProjects' is always rewritten in function body before being used. gameprojectautomationtests.cpp 88
  • V763 Parameter 'OutMatchedProjects' is always rewritten in function body before being used. gameprojectautomationtests.cpp 89

, , OutCreatedProjects OutMatchedProjects , 0.

: . :
static void CreateProjectSet(.... int32 &OutCreatedProjects,
                                  int32 &OutMatchedProjects)

, - . . , break:
{
  case EWidgetBlendMode::Opaque:
    ActualBackgroundColor.A = 1.0f;
  case EWidgetBlendMode::Masked:
    ActualBackgroundColor.A = 0.0f;
}

:
checkf(GPixelFormats[PixelFormat].BlockSizeX 
    == GPixelFormats[PixelFormat].BlockSizeY 
    == GPixelFormats[PixelFormat].BlockSizeZ 
    == 1, 
  TEXT("Tried to use compressed format?"));

- C++ , , V709.

, PVS-Studio. , ?

, . .
{
  case EWidgetBlendMode::Opaque:
    ActualBackgroundColor.A = 1.0f;
  case EWidgetBlendMode::Masked:
    ActualBackgroundColor.A = 0.0f;
}

. , , .

: - ?


PVS-Studio , , , . , PVS-Studio. .

, , , , , .

, , , , .

, . , , , . , , , .

, . , , , .

. " ' '" (en). :

( , , )?

, 90% .

, . 100 50 50 . . , , , , .

, . . / . , .

, .

. .

. , , . , , . , //. : " ".

: . , :
  • ;
  • , ;
  • ( , );
  • ;
  • ;
  • , ;
  • , TDD;
  • .

. - , - . - , . .


Unreal Engine , PVS-Studio, , .

PVS-Studio . PVS-Studio , , ..

.
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/331724/


: [1] []
 

:
: 

: ( )

:

  URL