Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing initialization of variables in classes/structs found by Cppcheck #43636

Open
qarmin opened this issue Nov 18, 2020 · 10 comments
Open

Missing initialization of variables in classes/structs found by Cppcheck #43636

qarmin opened this issue Nov 18, 2020 · 10 comments

Comments

@qarmin
Copy link
Contributor

qarmin commented Nov 18, 2020

Godot version:
4.0.dev.custom_build.dd5485142

Issue description:
A lot of variables(812 but some are not counted and some are false positives) aren't initialized in constructors or directly where there are created in classe like(look at non initialized left variable which should be nullptr):

List<Face>::Element *left, *right = nullptr;

which may cause(and caused before) hard to reproduce errors.

How to fix them?

  1. Open Cppcheck report from below, open one of reports and read error e.g. Member variable 'FaceConnect::left' is not initialized in the constructor. and initialize this variable with default values like
class HashingContext : public Reference {
	void *ctx;
        int rar;
        bool q;
public:
	HashingContext() {}
	~HashingContext();
};

should be changed to

class HashingContext : public Reference {
	void *ctx = nullptr;
        int rar = 0;
        bool q = false;
public:
	HashingContext() {}
	~HashingContext();
};

not (it is harder to read)

class HashingContext : public Reference {
	void *ctx;
        int rar;
        bool q;
public:
	HashingContext() {
        ctx = nullptr;
        rar = 0;
        q = false;
}
	~HashingContext();
};

You can also move some value initialization from constructors to place where are created in structs/classes.

Cppcheck Report

Cppcheck report to download(remove .zip extension) - report.7z.zip
To view results, just open index.html file and only select at the left side uninitMemberVar
Zrzut ekranu z 2020-11-18 09-46-13

Command which I used to generate this report

cppcheck -q -j8 -ithirdparty -i3rdparty -itests -itest -itoolchain -itools  --enable=all --force --output-file=cppcheck.xml --xml --xml-version=2 .;cppcheck-htmlreport --source-dir=. --title=project --file=cppcheck.xml --report-dir=report;xdg-open report/index.html
@valdaarhun
Copy link

Hi. I am new to contributing to godot and would like to work on this issue.

@qarmin
Copy link
Contributor Author

qarmin commented Dec 29, 2020

Entire servers/ folder is available to take

@valdaarhun
Copy link

Nice. I have already started working on the servers/ folder.

@KarthikSundar2002
Copy link

What is the progress in this issue? Is the issue fixed? If not, I would like to lend a hand.

@qarmin
Copy link
Contributor Author

qarmin commented Jan 8, 2021

Looks that all folders which contains Cppcheck errors have already closed or still open PR which will fix them.

@Ponnyou
Copy link

Ponnyou commented Mar 4, 2021

I noticed that this problem was still open. I would like to help if possible or has everything been checked and closed already?

@VVR20
Copy link

VVR20 commented Jan 21, 2022

Hi. I am new to contributing to Godot and would like to work on this issue if the problem is still open.

@Robotawi
Copy link

Robotawi commented Aug 4, 2022

Is any help still needed with this issue? @qarmin

@johnnyhuyhuynh
Copy link

johnnyhuyhuynh commented Sep 13, 2022

Is this still being worked on? @qarmin
If so, I would love to take on this issue.

@johnnyhuyhuynh
Copy link

I’ll work on this!

Harrison-Salzverg added a commit to Harrison-Salzverg/godot that referenced this issue Sep 27, 2022
@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 27, 2023
@YuriSizov YuriSizov modified the milestones: 4.1, 4.x Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants