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

address two cppcheck findings #1799

Merged
merged 2 commits into from
Jul 25, 2017
Merged

Conversation

matthiaskrgr
Copy link
Contributor

No description provided.

This was found by cppcheck:
[src/gui/dialogs/wml_message.cpp:174] -> [src/gui/dialogs/wml_message.cpp:177]: (warning) Either the condition 'right' is redundant or there is possible null pointer dereference: right.

Code was as follows:

	if(left && !right) {
		dlg.reset(new wml_message_left(title, message, left->portrait, left->mirror));
	} else if(!left && right) {
		dlg.reset(new wml_message_right(title, message, right->portrait, right->mirror));
	} else {
		dlg.reset(new wml_message_double(title, message, left->portrait, left->mirror, right->portrait, right->mirror));
	}

left  right  => branch taken
 T	T         else {}
 T	F	  if {}
 F	T         elseif {}
 F	F         else {}   // we could possibly access left->foo and right->foo here

Make  else {}  into an explicit   else if (right && left) {}
…ion and definition the same.

Found by cppcheck:
[src/ai/configuration.hpp:108] -> [src/ai/configuration.cpp:178]: (warning) Function 'parse_side_config' argument order different: declaration 'side, cfg, parsed_cfg' definition 'side, original_cfg, cfg'

Rename arguments in declaration (configuration.hpp) from   'side, cfg, parsed_cfg'  to  'side, original_cfg, cfg'.
@CelticMinstrel
Copy link
Member

If you're renaming parameters, you also need to fix the doc comment.

@CelticMinstrel
Copy link
Member

As an aside, I'd prefer if you didn't put code in your commit messages. The code is right there in the diff, so adding it to the commit message is pointlessly redundant. (If the code was somehow unrelated to the diff, that might be a different story.)

@CelticMinstrel CelticMinstrel merged commit cca2776 into wesnoth:master Jul 25, 2017
@CelticMinstrel CelticMinstrel added this to the 1.13.9 milestone Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants