V631. Consider inspecting the 'Foo' function call. Defining an absolute path to the file or directory is considered a poor style.

The analyzer has detected a potential error that occurs when calling a function intended to handle files. An absolute path to a file or directory is passed into a function in one of the actual arguments. Using a function in such a way is dangerous, as there may be cases that this path doesn't exist on the user's computer.

Consider an example of incorrect code:

FILE *text = fopen("c:\\TEMP\\text.txt", "r");

A better way is to get the path to a file on certain conditions.

This is the correct code:

string fullFilePath = GetFilePath() + "text.txt";  
FILE *text = fopen(fullFilePath.c_str(), "r");

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-30, CWE-37, CWE-39.

You can look at examples of errors detected by the V631 diagnostic.

Bugs Found

Checked Projects
Collected Errors
14 111
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →