Issue information

Issue ID
#7909
Status
Fixed
Severity
None
Started
Vader
Dec 19, 2013 10:12
Last Post
Ind
Mar 22, 2014 21:30
Confirmation
Yes (1)
No (0)

Vader - Dec 19, 2013 10:12

[color=#0066ff][b]There are identical sub-expressions to the left and to the right of the '!=' operator: p->mod_death != p->mod_death char.c 503
The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 76, 80. raconf.c 76
There are identical sub-expressions to the left and to the right of the '&&' operator: p[1] == '-' && p[1] == '-' script.c 913
The 'masterstatus->speed' variable is assigned to itself. status.c 2074
Consider inspecting the condition. The 'FindFileData.cFileName' pointer is always not equal to NULL. utils.c 139
It is incorrect to compare the variable of BOOL type with TRUE. Correct expression is: 'TryEnterCriticalSection(& m->hMutex) != FALSE'. mutex.c 93
Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions. thread.c 194
Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) == 0' construct. A more efficient way is to check: str[0] == '\0'. login.c 502
Decreased performance. It is inefficient to identify an empty string by using 'strnlen(str) > 0' construct. A more efficient way is to check: str[0] != '\0'. login.c 983
Decreased performance. Calls to the 'strlen' function have being made multiple times when a condition for the loop's continuation was calculated. npc.c 2883
Decreased performance. The 'strlen' function is called twice in the specified expression to calculate length of the same string. irc-bot.c 282
Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) > 0' construct. A more efficient way is to check: str[0] != '\0'. log.c 367
Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) > 0' construct. A more efficient way is to check: str[0] != '\0'. map.c 3645[/b][/color]

Mhalicot - Dec 19, 2013 14:45

Maybe its because of your modified source files?

more info please.

pan - Dec 19, 2013 16:07

[quote name="Mhalicot" timestamp="1387464338"]
Maybe its because of your modified source files?

more info please.[/quote]I don't think they're errors, probably it's the output of some tool that's used to identify places that could be optimized

Vader - Dec 19, 2013 19:40

[b][color=#0066cc]This latest version of the clean emulator.[/color][/b]
[b][color=#0066cc]There are errors and optimization.[/color][/b]
[b][color=#0066cc]For example:[/color][/b][quote]
There are identical sub-expressions to the left and to the right of the '&&' operator: p[1] == '-' && p[1] == '-' script.c 913[/quote]
[b][color=#0066cc]this is a typo in the code, which may lead to a bug.[/color][/b]

[b][color=#0066cc]actually there should be so:[/color][/b]
[quote]
p[0] == '-' && p[1] == '-'[/quote]

[b][color=#0066cc]And yes, I used a code analyzer + personally checked.[/color][/b]

This post has been edited by Vader on Dec 19, 2013 19:45

Mhalicot - Dec 20, 2013 3:14

Confirmed after checking

char.c[code=:503] - p->mod_death != p->mod_death + p->mod_death != cp->mod_death[/code]
script.c[code=:913] - p[1] == '-' && p[1] + p[0] == '-' && p[1] [/code]
...

Vader - Dec 20, 2013 6:04

[b][color=#0066cc]Also check lines: 76, 80. raconf.c 76 and status.c 2074.[/color][/b]
[b][color=#0066cc]All other, its some perfomance optimisations.[/color][/b]

Ind - Mar 22, 2014 21:30

This the warnings were addressed some months ago but I forgot to update this, some windows-specific like[code=auto:0] Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions. thread.c 194 [/code]I did not address however as I believe they were intended.
Thank you!