Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Echelon9 on April 05, 2015, 08:20:59 am
-
For those that aren't aware, the FS2Open engine has a debug console. Recent versions of Clang compiler (i.e. 3.5+) report a warning on some very odd code within consoleparse.cpp:
if (strncmp(str1, Cp, strlen(str1) == 0)) {
^ Size argument in 'strncmp' call is a comparison.
^ Fix-it: Did you mean to compare the result of 'strncmp' instead?
// Do stuff
The suggested patch is as follows:
Index: code/debugconsole/consoleparse.cpp
===================================================================
--- code/debugconsole/consoleparse.cpp (revision 11296)
+++ code/debugconsole/consoleparse.cpp (working copy)
@@ -492,10 +492,10 @@
dc_ignore_gray_space();
- if (strncmp(str1, Cp, strlen(str1) == 0)) {
+ if (strncmp(str1, Cp, strlen(str1)) == 0) {
str_found = str1;
i = 0;
- } else if (strncmp(str2, Cp, strlen(str2) == 0)) {
+ } else if (strncmp(str2, Cp, strlen(str2)) == 0) {
str_found = str2;
i = 1;
}
@@ -563,7 +563,7 @@
{
dc_ignore_gray_space();
- if (strncmp(pstr, Cp, strlen(pstr) != 0)) {
+ if (strncmp(pstr, Cp, strlen(pstr)) != 0) {
return false;
} // Else, optional string was found
-
That does look like the intended behavior. Question is, does the intended behavior work? :)
-
how the hell did I miss that. lol. :banghead:
[Edit] Just for clarification, Yes, that is the intended behavior of the dc_required_string functions.
-
Additionally, dc_required_string_either() isn't currently called anywhere, so correcting its behavior shouldn't break anything.
-
z64555, do you mind if I leave it to you to test and commit the patch?
-
Yeah, I can do that. I'll try to get it done soonish.
-
Fix committed 1130