SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
PVS-Studio: analyzing ReactOS code
    Studio:           ReactOS's
Author: Andrey Karpov

Date: 01.09.2011


Abstract
Having checked ReactOS's code I managed to fulfill three of my wishes at once. Firstly, I had wanted for
a long time to write an article on a common project. It's not interesting to check the source code of
projects like Chromium: its quality is too high and a lot of resources are spent to maintain it, which are
unavailable to common projects. Secondly, it's a good example to demonstrate the necessity of static
analysis in a large project, especially when it is developed by a diverse and distributed team. Thirdly, I've
got a confirmation that PVS-Studio is becoming even better and more useful
                               Studio                                     useful.


PVS-Studio is becoming better and better




I will start with the last point regarding the advantages of PVS-Studio tool. ReactOS indirectly confirms
                                                                            .
that PVS-Studio is developing in a right direction. Here is the news about checking ReactOS with such
           Studio
heavyweight as Coverity - "Coverity Redux [1]. Of course, I understand that our tool capabilities are
                               Coverity Redux"                                     tool's
far more modest than those of Coverity. However, PVS Studio finds a whole lot of errors where Coverity
                                                      PVS-Studio
has found "a few new errors". Besides, you are not forced to send the code anywhere; you can just pick
                                ".
up and check any project. It means we're on the right track.


What is ReactOS?
ReactOS is a contemporary, free and open source operating system based on Windows XP/2003
                                     open-source
architecture. The system was written from scratch and has the purpose of replicating the Windows
                                                                                          Windows-NT
architecture created by Microsoft on all the layers from hardware to application layer. The size of the
source code in C, C++ and Assembler is about 220 MbMbytes.

References:

    •   ReactOS Site.
    •   Start Developing ReactOS
                         ReactOS.
    •   Wikipedia. ReactOS.
    •   ReactOS - Open-Source Windows Clone Software To Seriously Look Forward To
                        Source                                                 To.
Errors in ReactOS
Now let's speak about the whole lot of errors I have found in ReactOS's code. Of course, I won't describe
them all in the article. Here I have laid out a text file with descriptions of errors found during analysis.
The file contains diagnostic messages with file names and line numbers. I have also arranged the errors
in a form of short code inserts and commented upon them. That's why those of you who would like to
edit ReactOS should rely upon that file and not this article.

Or rather download PVS-Studio and check the project yourselves. You see, I'm not familiar with the
project, so I copied out only those errors that I've understood. And regarding many fragments, I don't
know if they contain errors or not. So my analysis is rather superficial. We will provide you a registration
key if you want to check the project.

Errors you may come across in ReactOS are very diverse. It's a zoo of errors, really. There are misprints
of one character.

BOOL WINAPI GetMenuItemInfoA(...)

{

    ...

    mii->cch = mii->cch;

    ...

}

This is how it should be actually written: "mii->cch = miiW->cch;". The letter 'W' was lost. As a result,
applications can't trust the GetMenuItemInfoA function.

Here you are another misprint of one character. This time it's incorrect comparison of two names.

static void _Stl_loc_combine_names(_Locale_impl* L,

    const char* name1, const char* name2,

    locale::category c)

{

    if ((c & locale::all) == 0 || strcmp(name1, name1) == 0)

    ...

}

Operators && and & are mixed up. It's a very common error. I come across it virtually in every project
where bits or file attributes are being handled.

static LRESULT APIENTRY ACEditSubclassProc()

{

    ...

    if ((This->options && ACO_AUTOSUGGEST) &&
((HWND)wParam != This->hwndListBox))

    ...

}

This is how the correct code must look: "(This->options & ACO_AUTOSUGGEST)". The sample below
contains a similar error which causes the whole condition to be false all the time.

void adns__querysend_tcp(adns_query qu, struct timeval now) {

    ...

        if (!(errno == EAGAIN || EWOULDBLOCK || errno == EINTR ||

            errno == ENOSPC || errno == ENOBUFS || errno == ENOMEM)) {

    ...

}

If you look closely, you may notice an insidious fragment: "|| EWOULDBLOCK ||".

By the way, in ReactOS I have found a lot of conditions which are always true or false. Some of them are
not dangerous because, for instance, they are located in the assert() macro. But, in my opinion, there
are some conditions which are crucial as well.

INT WSAAPI

connect(IN SOCKET s,

            IN CONST struct sockaddr *name,

            IN INT namelen)

{

    ...

    /* Check if error code was due to the host not being found */

    if ((Status == SOCKET_ERROR) &&

          (ErrorCode == WSAEHOSTUNREACH) &&

          (ErrorCode == WSAENETUNREACH))

    {

    ...

}

You agree that the implementation of functions like "connect" should be tested as thoroughly as
possible, don't you? But here we have a condition which is always false. It's not easy to notice the defect
quickly, so let me explain the error:

(ErrorCode == 10065) && (ErrorCode == 10051)
By the way, the part relating to sockets looks very raw. Perhaps it is explained by the fact that it's an
accepted practice to define SOCKET as a signed type in the Linux world, while in Windows it's unsigned:

typedef UINT_PTR SOCKET;

As a result, we have various errors in comparison operations:

void adns_finish(adns_state ads) {

    ...

    if (ads->tcpsocket >= 0) adns_socket_close(ads->tcpsocket);

    ...

}

The "ads->tcpsocket >= 0" expression is meaningless since it's always true.

There are simply odd fragments. Most likely, these are incomplete or forgotten code fragments.

if (ERROR_SUCCESS == hres)

{

    Names[count] = HeapAlloc(GetProcessHeap(), 0, strlenW(szValue) + 1);

    if (Names[count])

       strcmpW(Names[count], szValue);

}

Why would you call the "strcmpW", if you will not use the result in any way?

There are errors in operations' priorities.

VOID NTAPI

AtapiDmaInit(...)

{

    ...

    ULONG treg = 0x54 + (dev < 3) ? (dev << 1) : 7;

    ...

}

I will add parentheses to show how this expression really works:

ULONG treg = (0x54 + (dev < 3)) ? (dev << 1) : 7;

The next error can always be found in any large project. There are a couple of these errors in ReactOS
too. I mean the extra semicolon - ';'.
BOOLEAN

CTEScheduleEvent(PCTE_DELAYED_EVENT Event,

                          PVOID Context)

{

    ...

    if (!Event->Queued);

    {

        Event->Queued = TRUE;

        Event->Context = Context;

        ExQueueWorkItem(&Event->WorkItem, CriticalWorkQueue);

    }

    ...

}

I am also fond of errors related to the initialization of array items. I don't know why. They are touching.
Maybe it's just memories of my first experiments with arrays in Basic.

HPALETTE CardWindow::CreateCardPalette()

{

    ...

    //include button text colours

    cols[0] = RGB(0, 0, 0);

    cols[1] = RGB(255, 255, 255);



    //include the base background colour

    cols[1] = crBackgnd;



    //include the standard button colours...

    cols[3] = CardButton::GetHighlight(crBackgnd);

    cols[4] = CardButton::GetShadow(crBackgnd);

    ...

}
I may continue citing various interesting code fragments. Unfortunately, the article will become too long
then so I have to stop. Let me remind you that you can read about the errors found in ReactOS in this
file. I will only cite the following piece of code for dessert:

#define SWAP(a,b,c)             c = a;

                                a = b;

                                a = c

An example of how it was used:

BOOL FASTCALL

IntEngGradientFillTriangle(...)

{

    ...

    SWAP(v2,v3,t);

    ...

}

This is a masterpiece.


Static code analysis
I find ReactOS a very good example of a project where regular static analysis is a mandatory necessity.
The reason is not the developers' skill. It's because the project is very large and contains various
subsystems. It means that there are always a lot of people working on such a project. And in a large
team there are always people whose programming skill is relatively worse or better; some programmers
use one style and others use another style. But nobody is safe from errors. Look at the following code.

This is just what one person had written in ReactOS:

if ((res = setsockopt(....) == -1))

The code doesn't work as it was intended. The correct code is the following: if ((res = setsockopt(....)) ==
-1). If you adhere to practice of always writing a constant in the beginning, you will never make a wrong
assignment inside the "if" operator. We have a different sort of error here. But if you follow the rule
above when writing the code, then you won't make a mistake in the expression at hand as well: "if (-1 ==
res = setsockopt(....))".

But even if you follow that practice, you can easily make a mistake in an alternative way.

static DWORD CALLBACK

RegistrationProc(LPVOID Parameter)

{

    ...
if (0 == LoadStringW(hDllInstance, IDS_UNKNOWN_ERROR,

                                     UnknownError,

                                     sizeof(UnknownError) /

                                     sizeof(UnknownError[0] - 20)))

    ...

}

The 0 constant is written nicely here. But the closing parenthesis is in a wrong place. It's a simple
misprint.

What for do I cite all these examples? To show you that no one of us programmers is ideal. Neither
coding standards, nor programming technologies, nor self-discipline guarantee that you won't make
mistakes in source code.

In large projects you just cannot do without auxiliary technologies like dynamic and static analysis. I
want to emphasize the following idea:

I believe that static code analysis should be a mandatory component of the development cycle in the
case of ReactOS and other large projects.

Let me explain my statement. In such systems, you cannot get close to 100% code coverage when
testing the code with unit-tests or regression tests. Well, to be more precise, you can, of course, but
costs of creating and maintaining such tests will become unacceptably high.

The reason is that the number of system's possible states and execution paths of code branches is too
large. Some branches get control rarely but they do not get less important because of that. It is here
that you can notice the advantage of static analysis. It checks the whole source code regardless of how
often it gets control during the program's execution.

Here is an example of checking a code that rarely gets control:

static HRESULT STDMETHODCALLTYPE

CBindStatusCallback_OnProgress(...)

{

    ...

    if (This->szMimeType[0] != _T('0'))

      _tprintf(_T("Length: %I64u [%s]n"), This->Size,

                    This->szMimeType);

    else

      _tprintf(_T("Length: %ulln"), This->Size);

    ...
}

It's most likely that the code was written incorrectly in the beginning. Then somebody noticed that the
message was generated in a wrong way and fixed it by writing "%I64u". But he paid no attention to the
code nearby, while it still has an incorrect format "%ull". This brunch seems to be called very rare. Static
analysis won't miss that. It hadn't actually, since I can show you this example.

Another good example is a large number of memory cleanup errors that I've found in ReactOS. I
understand why there are so many of them. Nobody checks whether the memory is filled or not. Firstly,
it's difficult to realize that you might make a mistake in such simple places. Secondly, it's not so easy to
verify if some temporary buffer in a function has been cleared or not. Static analysis again comes to your
aid here. Let me give you only a couple of examples. Virtually I have counted at least 13 errors of filling
arrays with a constant value.

#define MEMSET_BZERO(p,l) memset((p), 0, (l))



char *SHA384_End(SHA384_CTX* context, char buffer[]) {

    ...

    MEMSET_BZERO(context, sizeof(context));

    ...

}

Only the first bytes of the array are cleared, since sizeof(context) returns the pointer's size instead of the
structure's size.

#define RtlFillMemory(Destination, Length, Fill) 

    memset(Destination, Fill, Length)



#define IOPM_FULL_SIZE                           8196



HalpRestoreIopm(VOID)

{

    ...

    RtlFillMemory(HalpSavedIoMap, 0xFF, IOPM_FULL_SIZE);

    ...

}

Arguments are mixed up when using the RtlFillMemory macro. This is how the call should look:

RtlFillMemory(HalpSavedIoMap, IOPM_FULL_SIZE, 0xFF);
To tabs and spaces again
I want to ask you beforehand not to start a flame on the topic in comments. I will simply tell you my
opinion. You may agree with it or not, but let's not discuss it.

There are two irreconcilable camps. One of them stands for using tabs in code because it allows you to
adjust code presentation according to your preferences. The others say that it doesn't work anyway and
there are no good reasons for using tabs. Tabs cause only harm and spoiled formatting. I refer to the
latter camp.

We may eternally repeat that everything will be okay if tabs are used in a right way. Unfortunately,
people who say that work on one project in isolation, without interacting with the outer world. In any
open-source or simply large project you cannot obtain a good code formatting if it is permitted to use
tabulation of any kind.

I won't get involved into abstract discussions. This time I will simply cite an obvious example from
ReactOS's code to my opponents.

ReactOS's coding standard has a good rule from the theoretical viewpoint [2]:

Generic note about TABs usage: Don't use TABs for formatting; use TABs for indenting only and use
only spaces for formatting.

Example:

NTSTATUS

SomeApi(IN Type Param1,

[spaces]IN Type Param2)

{

[TAB]ULONG MyVar;

[TAB]MyVar = 0;

[TAB]if ((MyVar == 3) &&

[TAB][sp](Param1 == TRUE))

[TAB]{

[TAB][TAB]CallSomeFunc();

...

TAB fans are satisfied. But I open up ReactOS's sources and observe spoiled formatting in many places.
Why is that?
The answer is obvious. Because it s hard to remember where you should press TAB and where you
                                    it's
should press several spaces when the project is not the only one you are deal with. That's why people
                                                                           dealing
constantly make mistakes. Since it comes to that, let's be practitioners, not theorists Why not forbid
                                                                              theorists.
usage of tabs at all? Then we all will write code with the same formatting and if a violator appears who
             s
starts using tabs, it will be easy to find and reprimand him.
                s,

It's not a step backward in code fo
   s                             formatting! It's just a step forward! It's the next level of awareness.
Theoretical beauty of indenting does not match practice. First of all, it's important to provide
                                                                          s
unequivocal code representation and easy development process in a large team. The Google company
understands that. Their formatting standard uses only spaces [3]. Those who stand for using tabs, please
think it over why it is spaces that a distributed team of highly skilled professionals working on Chromium
has chosen for formatting.

And once again, the theoretical beauty of configurable indenting does not match practice. However nice
the theory sounds, it's of no use if it doesn't work. And this is how things are in ReactOS.

So my recommendation to the ReactOS development team is to modify their standard and to refuse
usage of tabulation. Any tab should be considered a mistake and eliminated from the code.

By the way, this practice will allow you to detect awful things like the following one in ReactOS's code:

BOOLEAN

KdInitSystem(IN ULONG BootPhase,

                    IN PLOADER_PARAMETER_BLOCK LoaderBlock)

{

    ...

    /* Check if this is a comma, a space or a tab */

    if ((*DebugOptionEnd == ',') ||

          (*DebugOptionEnd == ' ') ||

          (*DebugOptionEnd == ' '))

    ...

}

The last comparison is comparison to a tab, not a space, as it may seem. The right code must be the
following: "(*DebugOptionEnd == 't')".

Note for TAB fans. Please, don't tell me again how to use tabs in a right way. And this is not my code.
Look, there is a concrete project like ReactOS. It has a badly formatted code. Now think how to save a
new programmer opening the project's code from making guesses about what TAB size should be set in
the editor's settings. Ideas like "they should have written it right from the beginning " are of no practical
value.


References
    1. Newsletter 79. Coverity Redux. http://www.viva64.com/go.php?url=727
    2. ReactOS. Coding Style. http://www.viva64.com/go.php?url=724
    3. Google C++ Style Guide. http://www.viva64.com/go.php?url=679

Mais conteúdo relacionado

Mais procurados

Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?PVS-Studio
 
Bugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioBugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioPVS-Studio
 
Documenting Bugs in Doxygen
Documenting Bugs in DoxygenDocumenting Bugs in Doxygen
Documenting Bugs in DoxygenPVS-Studio
 
Source code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedSource code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedPVS-Studio
 
CppCat Static Analyzer Review
CppCat Static Analyzer ReviewCppCat Static Analyzer Review
CppCat Static Analyzer ReviewAndrey Karpov
 
Checking OpenCV with PVS-Studio
Checking OpenCV with PVS-StudioChecking OpenCV with PVS-Studio
Checking OpenCV with PVS-StudioPVS-Studio
 
Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016PVS-Studio
 
PVS-Studio vs Clang
PVS-Studio vs ClangPVS-Studio vs Clang
PVS-Studio vs ClangPVS-Studio
 
The Little Unicorn That Could
The Little Unicorn That CouldThe Little Unicorn That Could
The Little Unicorn That CouldPVS-Studio
 
A fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBoxA fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBoxPVS-Studio
 
Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggyAndrey Karpov
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLitePVS-Studio
 
Errors that static code analysis does not find because it is not used
Errors that static code analysis does not find because it is not usedErrors that static code analysis does not find because it is not used
Errors that static code analysis does not find because it is not usedAndrey Karpov
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgePVS-Studio
 
Picking Mushrooms after Cppcheck
Picking Mushrooms after CppcheckPicking Mushrooms after Cppcheck
Picking Mushrooms after CppcheckAndrey Karpov
 
How to find 56 potential vulnerabilities in FreeBSD code in one evening
How to find 56 potential vulnerabilities in FreeBSD code in one eveningHow to find 56 potential vulnerabilities in FreeBSD code in one evening
How to find 56 potential vulnerabilities in FreeBSD code in one eveningPVS-Studio
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codeAndrey Karpov
 
Rechecking TortoiseSVN with the PVS-Studio Code Analyzer
Rechecking TortoiseSVN with the PVS-Studio Code AnalyzerRechecking TortoiseSVN with the PVS-Studio Code Analyzer
Rechecking TortoiseSVN with the PVS-Studio Code AnalyzerAndrey Karpov
 
Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6Andrey Karpov
 

Mais procurados (20)

Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?
 
Bugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioBugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-Studio
 
Documenting Bugs in Doxygen
Documenting Bugs in DoxygenDocumenting Bugs in Doxygen
Documenting Bugs in Doxygen
 
Source code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checkedSource code of WPF samples by Microsoft was checked
Source code of WPF samples by Microsoft was checked
 
CppCat Static Analyzer Review
CppCat Static Analyzer ReviewCppCat Static Analyzer Review
CppCat Static Analyzer Review
 
Checking OpenCV with PVS-Studio
Checking OpenCV with PVS-StudioChecking OpenCV with PVS-Studio
Checking OpenCV with PVS-Studio
 
Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016
 
PVS-Studio vs Clang
PVS-Studio vs ClangPVS-Studio vs Clang
PVS-Studio vs Clang
 
The Little Unicorn That Could
The Little Unicorn That CouldThe Little Unicorn That Could
The Little Unicorn That Could
 
A fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBoxA fresh eye on Oracle VM VirtualBox
A fresh eye on Oracle VM VirtualBox
 
Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggy
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLite
 
Checking VirtualDub
Checking VirtualDubChecking VirtualDub
Checking VirtualDub
 
Errors that static code analysis does not find because it is not used
Errors that static code analysis does not find because it is not usedErrors that static code analysis does not find because it is not used
Errors that static code analysis does not find because it is not used
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
 
Picking Mushrooms after Cppcheck
Picking Mushrooms after CppcheckPicking Mushrooms after Cppcheck
Picking Mushrooms after Cppcheck
 
How to find 56 potential vulnerabilities in FreeBSD code in one evening
How to find 56 potential vulnerabilities in FreeBSD code in one eveningHow to find 56 potential vulnerabilities in FreeBSD code in one evening
How to find 56 potential vulnerabilities in FreeBSD code in one evening
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
Rechecking TortoiseSVN with the PVS-Studio Code Analyzer
Rechecking TortoiseSVN with the PVS-Studio Code AnalyzerRechecking TortoiseSVN with the PVS-Studio Code Analyzer
Rechecking TortoiseSVN with the PVS-Studio Code Analyzer
 
Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6
 

Semelhante a PVS-Studio: analyzing ReactOS's code

Analysis of Godot Engine's Source Code
Analysis of Godot Engine's Source CodeAnalysis of Godot Engine's Source Code
Analysis of Godot Engine's Source CodePVS-Studio
 
Finding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-StudioFinding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-StudioPVS-Studio
 
Looking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopLooking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopPVS-Studio
 
LibRaw, Coverity SCAN, PVS-Studio
LibRaw, Coverity SCAN, PVS-StudioLibRaw, Coverity SCAN, PVS-Studio
LibRaw, Coverity SCAN, PVS-StudioAndrey Karpov
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellPVS-Studio
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project AnalyzedPVS-Studio
 
Errors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 librariesErrors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 librariesPVS-Studio
 
Accord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer HumankindAccord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer HumankindPVS-Studio
 
Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...Andrey Karpov
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youAndrey Karpov
 
Sony C#/.NET component set analysis
Sony C#/.NET component set analysisSony C#/.NET component set analysis
Sony C#/.NET component set analysisPVS-Studio
 
Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...
Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...
Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...PVS-Studio
 
PVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio
 
PVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio vs Chromium
PVS-Studio vs ChromiumAndrey Karpov
 
Analyzing the Dolphin-emu project
Analyzing the Dolphin-emu projectAnalyzing the Dolphin-emu project
Analyzing the Dolphin-emu projectPVS-Studio
 
PVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd CheckPVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd CheckAndrey Karpov
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsAndrey Karpov
 
Leo Tolstoy and static code analysis
Leo Tolstoy and static code analysisLeo Tolstoy and static code analysis
Leo Tolstoy and static code analysisPVS-Studio
 
Analyzing the Blender project with PVS-Studio
Analyzing the Blender project with PVS-StudioAnalyzing the Blender project with PVS-Studio
Analyzing the Blender project with PVS-StudioPVS-Studio
 

Semelhante a PVS-Studio: analyzing ReactOS's code (19)

Analysis of Godot Engine's Source Code
Analysis of Godot Engine's Source CodeAnalysis of Godot Engine's Source Code
Analysis of Godot Engine's Source Code
 
Finding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-StudioFinding bugs in the code of LLVM project with the help of PVS-Studio
Finding bugs in the code of LLVM project with the help of PVS-Studio
 
Looking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopLooking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelop
 
LibRaw, Coverity SCAN, PVS-Studio
LibRaw, Coverity SCAN, PVS-StudioLibRaw, Coverity SCAN, PVS-Studio
LibRaw, Coverity SCAN, PVS-Studio
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
 
Errors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 librariesErrors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 libraries
 
Accord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer HumankindAccord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
 
Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for you
 
Sony C#/.NET component set analysis
Sony C#/.NET component set analysisSony C#/.NET component set analysis
Sony C#/.NET component set analysis
 
Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...
Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...
Microsoft opened the source code of Xamarin.Forms. We couldn't miss a chance ...
 
PVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio vs Chromium
PVS-Studio vs Chromium
 
PVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio vs Chromium
PVS-Studio vs Chromium
 
Analyzing the Dolphin-emu project
Analyzing the Dolphin-emu projectAnalyzing the Dolphin-emu project
Analyzing the Dolphin-emu project
 
PVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd CheckPVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd Check
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
 
Leo Tolstoy and static code analysis
Leo Tolstoy and static code analysisLeo Tolstoy and static code analysis
Leo Tolstoy and static code analysis
 
Analyzing the Blender project with PVS-Studio
Analyzing the Blender project with PVS-StudioAnalyzing the Blender project with PVS-Studio
Analyzing the Blender project with PVS-Studio
 

Mais de Andrey Karpov

60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста60 антипаттернов для С++ программиста
60 антипаттернов для С++ программистаAndrey Karpov
 
60 terrible tips for a C++ developer
60 terrible tips for a C++ developer60 terrible tips for a C++ developer
60 terrible tips for a C++ developerAndrey Karpov
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Andrey Karpov
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesAndrey Karpov
 
PVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewPVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewAndrey Karpov
 
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокPVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокAndrey Karpov
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Andrey Karpov
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesAndrey Karpov
 
Does static analysis need machine learning?
Does static analysis need machine learning?Does static analysis need machine learning?
Does static analysis need machine learning?Andrey Karpov
 
Typical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and JavaTypical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and JavaAndrey Karpov
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)Andrey Karpov
 
Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Andrey Karpov
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareThe Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareAndrey Karpov
 
Static Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineStatic Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineAndrey Karpov
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsAndrey Karpov
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++Andrey Karpov
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...Andrey Karpov
 

Mais de Andrey Karpov (20)

60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста60 антипаттернов для С++ программиста
60 антипаттернов для С++ программиста
 
60 terrible tips for a C++ developer
60 terrible tips for a C++ developer60 terrible tips for a C++ developer
60 terrible tips for a C++ developer
 
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...Ошибки, которые сложно заметить на code review, но которые находятся статичес...
Ошибки, которые сложно заметить на code review, но которые находятся статичес...
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
PVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature OverviewPVS-Studio in 2021 - Feature Overview
PVS-Studio in 2021 - Feature Overview
 
PVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибокPVS-Studio в 2021 - Примеры ошибок
PVS-Studio в 2021 - Примеры ошибок
 
PVS-Studio в 2021
PVS-Studio в 2021PVS-Studio в 2021
PVS-Studio в 2021
 
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
Make Your and Other Programmer’s Life Easier with Static Analysis (Unreal Eng...
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' Mistakes
 
Does static analysis need machine learning?
Does static analysis need machine learning?Does static analysis need machine learning?
Does static analysis need machine learning?
 
Typical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and JavaTypical errors in code on the example of C++, C#, and Java
Typical errors in code on the example of C++, C#, and Java
 
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
How to Fix Hundreds of Bugs in Legacy Code and Not Die (Unreal Engine 4)
 
Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?Game Engine Code Quality: Is Everything Really That Bad?
Game Engine Code Quality: Is Everything Really That Bad?
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source SoftwareThe Use of Static Code Analysis When Teaching or Developing Open-Source Software
The Use of Static Code Analysis When Teaching or Developing Open-Source Software
 
Static Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal EngineStatic Code Analysis for Projects, Built on Unreal Engine
Static Code Analysis for Projects, Built on Unreal Engine
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
 
The Great and Mighty C++
The Great and Mighty C++The Great and Mighty C++
The Great and Mighty C++
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 

Último (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

PVS-Studio: analyzing ReactOS's code

  • 1. PVS-Studio: analyzing ReactOS code Studio: ReactOS's Author: Andrey Karpov Date: 01.09.2011 Abstract Having checked ReactOS's code I managed to fulfill three of my wishes at once. Firstly, I had wanted for a long time to write an article on a common project. It's not interesting to check the source code of projects like Chromium: its quality is too high and a lot of resources are spent to maintain it, which are unavailable to common projects. Secondly, it's a good example to demonstrate the necessity of static analysis in a large project, especially when it is developed by a diverse and distributed team. Thirdly, I've got a confirmation that PVS-Studio is becoming even better and more useful Studio useful. PVS-Studio is becoming better and better I will start with the last point regarding the advantages of PVS-Studio tool. ReactOS indirectly confirms . that PVS-Studio is developing in a right direction. Here is the news about checking ReactOS with such Studio heavyweight as Coverity - "Coverity Redux [1]. Of course, I understand that our tool capabilities are Coverity Redux" tool's far more modest than those of Coverity. However, PVS Studio finds a whole lot of errors where Coverity PVS-Studio has found "a few new errors". Besides, you are not forced to send the code anywhere; you can just pick ". up and check any project. It means we're on the right track. What is ReactOS? ReactOS is a contemporary, free and open source operating system based on Windows XP/2003 open-source architecture. The system was written from scratch and has the purpose of replicating the Windows Windows-NT architecture created by Microsoft on all the layers from hardware to application layer. The size of the source code in C, C++ and Assembler is about 220 MbMbytes. References: • ReactOS Site. • Start Developing ReactOS ReactOS. • Wikipedia. ReactOS. • ReactOS - Open-Source Windows Clone Software To Seriously Look Forward To Source To.
  • 2. Errors in ReactOS Now let's speak about the whole lot of errors I have found in ReactOS's code. Of course, I won't describe them all in the article. Here I have laid out a text file with descriptions of errors found during analysis. The file contains diagnostic messages with file names and line numbers. I have also arranged the errors in a form of short code inserts and commented upon them. That's why those of you who would like to edit ReactOS should rely upon that file and not this article. Or rather download PVS-Studio and check the project yourselves. You see, I'm not familiar with the project, so I copied out only those errors that I've understood. And regarding many fragments, I don't know if they contain errors or not. So my analysis is rather superficial. We will provide you a registration key if you want to check the project. Errors you may come across in ReactOS are very diverse. It's a zoo of errors, really. There are misprints of one character. BOOL WINAPI GetMenuItemInfoA(...) { ... mii->cch = mii->cch; ... } This is how it should be actually written: "mii->cch = miiW->cch;". The letter 'W' was lost. As a result, applications can't trust the GetMenuItemInfoA function. Here you are another misprint of one character. This time it's incorrect comparison of two names. static void _Stl_loc_combine_names(_Locale_impl* L, const char* name1, const char* name2, locale::category c) { if ((c & locale::all) == 0 || strcmp(name1, name1) == 0) ... } Operators && and & are mixed up. It's a very common error. I come across it virtually in every project where bits or file attributes are being handled. static LRESULT APIENTRY ACEditSubclassProc() { ... if ((This->options && ACO_AUTOSUGGEST) &&
  • 3. ((HWND)wParam != This->hwndListBox)) ... } This is how the correct code must look: "(This->options & ACO_AUTOSUGGEST)". The sample below contains a similar error which causes the whole condition to be false all the time. void adns__querysend_tcp(adns_query qu, struct timeval now) { ... if (!(errno == EAGAIN || EWOULDBLOCK || errno == EINTR || errno == ENOSPC || errno == ENOBUFS || errno == ENOMEM)) { ... } If you look closely, you may notice an insidious fragment: "|| EWOULDBLOCK ||". By the way, in ReactOS I have found a lot of conditions which are always true or false. Some of them are not dangerous because, for instance, they are located in the assert() macro. But, in my opinion, there are some conditions which are crucial as well. INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen) { ... /* Check if error code was due to the host not being found */ if ((Status == SOCKET_ERROR) && (ErrorCode == WSAEHOSTUNREACH) && (ErrorCode == WSAENETUNREACH)) { ... } You agree that the implementation of functions like "connect" should be tested as thoroughly as possible, don't you? But here we have a condition which is always false. It's not easy to notice the defect quickly, so let me explain the error: (ErrorCode == 10065) && (ErrorCode == 10051)
  • 4. By the way, the part relating to sockets looks very raw. Perhaps it is explained by the fact that it's an accepted practice to define SOCKET as a signed type in the Linux world, while in Windows it's unsigned: typedef UINT_PTR SOCKET; As a result, we have various errors in comparison operations: void adns_finish(adns_state ads) { ... if (ads->tcpsocket >= 0) adns_socket_close(ads->tcpsocket); ... } The "ads->tcpsocket >= 0" expression is meaningless since it's always true. There are simply odd fragments. Most likely, these are incomplete or forgotten code fragments. if (ERROR_SUCCESS == hres) { Names[count] = HeapAlloc(GetProcessHeap(), 0, strlenW(szValue) + 1); if (Names[count]) strcmpW(Names[count], szValue); } Why would you call the "strcmpW", if you will not use the result in any way? There are errors in operations' priorities. VOID NTAPI AtapiDmaInit(...) { ... ULONG treg = 0x54 + (dev < 3) ? (dev << 1) : 7; ... } I will add parentheses to show how this expression really works: ULONG treg = (0x54 + (dev < 3)) ? (dev << 1) : 7; The next error can always be found in any large project. There are a couple of these errors in ReactOS too. I mean the extra semicolon - ';'.
  • 5. BOOLEAN CTEScheduleEvent(PCTE_DELAYED_EVENT Event, PVOID Context) { ... if (!Event->Queued); { Event->Queued = TRUE; Event->Context = Context; ExQueueWorkItem(&Event->WorkItem, CriticalWorkQueue); } ... } I am also fond of errors related to the initialization of array items. I don't know why. They are touching. Maybe it's just memories of my first experiments with arrays in Basic. HPALETTE CardWindow::CreateCardPalette() { ... //include button text colours cols[0] = RGB(0, 0, 0); cols[1] = RGB(255, 255, 255); //include the base background colour cols[1] = crBackgnd; //include the standard button colours... cols[3] = CardButton::GetHighlight(crBackgnd); cols[4] = CardButton::GetShadow(crBackgnd); ... }
  • 6. I may continue citing various interesting code fragments. Unfortunately, the article will become too long then so I have to stop. Let me remind you that you can read about the errors found in ReactOS in this file. I will only cite the following piece of code for dessert: #define SWAP(a,b,c) c = a; a = b; a = c An example of how it was used: BOOL FASTCALL IntEngGradientFillTriangle(...) { ... SWAP(v2,v3,t); ... } This is a masterpiece. Static code analysis I find ReactOS a very good example of a project where regular static analysis is a mandatory necessity. The reason is not the developers' skill. It's because the project is very large and contains various subsystems. It means that there are always a lot of people working on such a project. And in a large team there are always people whose programming skill is relatively worse or better; some programmers use one style and others use another style. But nobody is safe from errors. Look at the following code. This is just what one person had written in ReactOS: if ((res = setsockopt(....) == -1)) The code doesn't work as it was intended. The correct code is the following: if ((res = setsockopt(....)) == -1). If you adhere to practice of always writing a constant in the beginning, you will never make a wrong assignment inside the "if" operator. We have a different sort of error here. But if you follow the rule above when writing the code, then you won't make a mistake in the expression at hand as well: "if (-1 == res = setsockopt(....))". But even if you follow that practice, you can easily make a mistake in an alternative way. static DWORD CALLBACK RegistrationProc(LPVOID Parameter) { ...
  • 7. if (0 == LoadStringW(hDllInstance, IDS_UNKNOWN_ERROR, UnknownError, sizeof(UnknownError) / sizeof(UnknownError[0] - 20))) ... } The 0 constant is written nicely here. But the closing parenthesis is in a wrong place. It's a simple misprint. What for do I cite all these examples? To show you that no one of us programmers is ideal. Neither coding standards, nor programming technologies, nor self-discipline guarantee that you won't make mistakes in source code. In large projects you just cannot do without auxiliary technologies like dynamic and static analysis. I want to emphasize the following idea: I believe that static code analysis should be a mandatory component of the development cycle in the case of ReactOS and other large projects. Let me explain my statement. In such systems, you cannot get close to 100% code coverage when testing the code with unit-tests or regression tests. Well, to be more precise, you can, of course, but costs of creating and maintaining such tests will become unacceptably high. The reason is that the number of system's possible states and execution paths of code branches is too large. Some branches get control rarely but they do not get less important because of that. It is here that you can notice the advantage of static analysis. It checks the whole source code regardless of how often it gets control during the program's execution. Here is an example of checking a code that rarely gets control: static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnProgress(...) { ... if (This->szMimeType[0] != _T('0')) _tprintf(_T("Length: %I64u [%s]n"), This->Size, This->szMimeType); else _tprintf(_T("Length: %ulln"), This->Size); ...
  • 8. } It's most likely that the code was written incorrectly in the beginning. Then somebody noticed that the message was generated in a wrong way and fixed it by writing "%I64u". But he paid no attention to the code nearby, while it still has an incorrect format "%ull". This brunch seems to be called very rare. Static analysis won't miss that. It hadn't actually, since I can show you this example. Another good example is a large number of memory cleanup errors that I've found in ReactOS. I understand why there are so many of them. Nobody checks whether the memory is filled or not. Firstly, it's difficult to realize that you might make a mistake in such simple places. Secondly, it's not so easy to verify if some temporary buffer in a function has been cleared or not. Static analysis again comes to your aid here. Let me give you only a couple of examples. Virtually I have counted at least 13 errors of filling arrays with a constant value. #define MEMSET_BZERO(p,l) memset((p), 0, (l)) char *SHA384_End(SHA384_CTX* context, char buffer[]) { ... MEMSET_BZERO(context, sizeof(context)); ... } Only the first bytes of the array are cleared, since sizeof(context) returns the pointer's size instead of the structure's size. #define RtlFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length) #define IOPM_FULL_SIZE 8196 HalpRestoreIopm(VOID) { ... RtlFillMemory(HalpSavedIoMap, 0xFF, IOPM_FULL_SIZE); ... } Arguments are mixed up when using the RtlFillMemory macro. This is how the call should look: RtlFillMemory(HalpSavedIoMap, IOPM_FULL_SIZE, 0xFF);
  • 9. To tabs and spaces again I want to ask you beforehand not to start a flame on the topic in comments. I will simply tell you my opinion. You may agree with it or not, but let's not discuss it. There are two irreconcilable camps. One of them stands for using tabs in code because it allows you to adjust code presentation according to your preferences. The others say that it doesn't work anyway and there are no good reasons for using tabs. Tabs cause only harm and spoiled formatting. I refer to the latter camp. We may eternally repeat that everything will be okay if tabs are used in a right way. Unfortunately, people who say that work on one project in isolation, without interacting with the outer world. In any open-source or simply large project you cannot obtain a good code formatting if it is permitted to use tabulation of any kind. I won't get involved into abstract discussions. This time I will simply cite an obvious example from ReactOS's code to my opponents. ReactOS's coding standard has a good rule from the theoretical viewpoint [2]: Generic note about TABs usage: Don't use TABs for formatting; use TABs for indenting only and use only spaces for formatting. Example: NTSTATUS SomeApi(IN Type Param1, [spaces]IN Type Param2) { [TAB]ULONG MyVar; [TAB]MyVar = 0; [TAB]if ((MyVar == 3) && [TAB][sp](Param1 == TRUE)) [TAB]{ [TAB][TAB]CallSomeFunc(); ... TAB fans are satisfied. But I open up ReactOS's sources and observe spoiled formatting in many places. Why is that?
  • 10. The answer is obvious. Because it s hard to remember where you should press TAB and where you it's should press several spaces when the project is not the only one you are deal with. That's why people dealing constantly make mistakes. Since it comes to that, let's be practitioners, not theorists Why not forbid theorists. usage of tabs at all? Then we all will write code with the same formatting and if a violator appears who s starts using tabs, it will be easy to find and reprimand him. s, It's not a step backward in code fo s formatting! It's just a step forward! It's the next level of awareness. Theoretical beauty of indenting does not match practice. First of all, it's important to provide s unequivocal code representation and easy development process in a large team. The Google company understands that. Their formatting standard uses only spaces [3]. Those who stand for using tabs, please
  • 11. think it over why it is spaces that a distributed team of highly skilled professionals working on Chromium has chosen for formatting. And once again, the theoretical beauty of configurable indenting does not match practice. However nice the theory sounds, it's of no use if it doesn't work. And this is how things are in ReactOS. So my recommendation to the ReactOS development team is to modify their standard and to refuse usage of tabulation. Any tab should be considered a mistake and eliminated from the code. By the way, this practice will allow you to detect awful things like the following one in ReactOS's code: BOOLEAN KdInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { ... /* Check if this is a comma, a space or a tab */ if ((*DebugOptionEnd == ',') || (*DebugOptionEnd == ' ') || (*DebugOptionEnd == ' ')) ... } The last comparison is comparison to a tab, not a space, as it may seem. The right code must be the following: "(*DebugOptionEnd == 't')". Note for TAB fans. Please, don't tell me again how to use tabs in a right way. And this is not my code. Look, there is a concrete project like ReactOS. It has a badly formatted code. Now think how to save a new programmer opening the project's code from making guesses about what TAB size should be set in the editor's settings. Ideas like "they should have written it right from the beginning " are of no practical value. References 1. Newsletter 79. Coverity Redux. http://www.viva64.com/go.php?url=727 2. ReactOS. Coding Style. http://www.viva64.com/go.php?url=724 3. Google C++ Style Guide. http://www.viva64.com/go.php?url=679