Issue information

Issue ID
#5617
Status
New
Severity
None
Started
Hercules Elf Bot
Apr 24, 2012 10:38
Last Post
Hercules Elf Bot
Apr 28, 2012 6:41
Confirmation
N/A

Hercules Elf Bot - Apr 24, 2012 10:38

Originally posted by [b]Tiera[/b]
[color=#008000]To the developers put up the results of the analysis code. Information relevant to r15950.
WL - warning level, degree of importance.
OP - optimisation analisys.


WL1:
Results for battle.c:
The 'dat' pointer was utilized before it was verified against nullptr. Check lines: 202, 204.
The 'src' pointer was utilized before it was verified against nullptr. Check lines: 4196, 4199.
The 'target' pointer was utilized before it was verified against nullptr. Check lines: 4196, 4200.

Results for clif.c:
The 'sd' pointer was utilized before it was verified against nullptr. Check lines: 4453, 4472.
Odd semicolon ';' after 'for' operator. Line:6352.
The 'src' pointer was utilized before it was verified against nullptr. Check lines: 6757, 6760.
There are identical sub-expressions to the left and to the right of the '&&' operator: i < 10 && i < 10. Line:12935.
There are identical sub-expressions to the left and to the right of the '&&' operator: i < 10 && i < 10. Line:12981.
There are identical sub-expressions to the left and to the right of the '&&' operator: i < 10 && i < 10. Line:12981.


Results for mob.c:
The memset function receives the pointer and its size as arguments. It is possibly a mistake. Inspect the third argument. Line:966.
A call of the 'memset' function will lead to underflow of the buffer 'md->lootitem'. Line:966.
A call of the 'memset' function will lead to underflow of the buffer 'mob_db_data[ mob_id ]->skill'. Line:4211.

Results for pc.c:
The 'sd' pointer was utilized before it was verified against nullptr. Check lines: 6231, 6243.
The 'id' pointer was utilized before it was verified against nullptr. Check lines: 7738, 7760.
The 'id' pointer was utilized before it was verified against nullptr. Check lines: 7738, 7768.

Results for pet.c:
The 'sd->pd' pointer was utilized before it was verified against nullptr. Check lines: 417, 420.

Results for skill.c:
The 'src' pointer was utilized before it was verified against nullptr. Check lines: 4529, 4532.
The 'src' pointer was utilized before it was verified against nullptr. Check lines: 4529, 4533.
The 'src' pointer was utilized before it was verified against nullptr. Check lines: 4529, 4534.
The 'src' pointer was utilized before it was verified against nullptr. Check lines: 4529, 4535.
The 'bl' pointer was utilized before it was verified against nullptr. Check lines: 4529, 4537.
The 'bl' pointer was utilized before it was verified against nullptr. Check lines: 4529, 4538.
The 'sd' pointer was utilized before it was verified against nullptr. Check lines: 11829, 11832.
The 'group' pointer was utilized before it was verified against nullptr. Check lines: 14553, 14559.

Results for status.c:
The 'bl' pointer was utilized before it was verified against nullptr. Check lines: 3142, 3145.
It's odd to compare 0 or 1 with a value of 516. Line:3281.
The 'sd' pointer was utilized before it was verified against nullptr. Check lines: 3526, 3541.
The 'sd' pointer was utilized before it was verified against nullptr. Check lines: 3551, 3564.
The 'sd' pointer was utilized before it was verified against nullptr. Check lines: 3551, 3571.
The 'bl' pointer was utilized before it was verified against nullptr. Check lines: 3706, 3712.
The 'bl' pointer was utilized before it was verified against nullptr. Check lines: 8932, 8936.

Results for unit.c:
The 'sc->data[SC_RUN]' pointer was utilized before it was verified against nullptr. Check lines: 425, 438.
The 'sc->data[SC_WUGDASH]' pointer was utilized before it was verified against nullptr. Check lines: 498, 509.

WL3:
Results for clif.c:
Incorrect format. Consider checking the third actual argument of the 'sprintf' function. The SIGNED integer type argument is expected. Line:8259.

Results for guild.c:
The 'gc' pointer is used simultaneously as an array and as a pointer to single object. Check lines: 1863, 1873.
The 'gc' pointer is used simultaneously as an array and as a pointer to single object. Check lines: 1863, 1880.

Results for skill.c:
The code containing the collection of similar blocks. Check items '2', '3', '4', '0', '1', '2' in lines 13064, 13065, 13066, 13067, 13068, 13069.

OP:
Results for mysql_com.h:
On 32-bit platform, structure size can be reduced from 20 to 16 bytes by rearranging the fields according to their sizes in decreasing order. Line:378

Results for utils.c:
Consider inspecting the condition. The 'FindFileData.cFileName' pointer is always not equal to NULL. Line:135.

Results for map.h:
On 32-bit platform, structure size can be reduced from 28 to 24 bytes by rearranging the fields according to their sizes in decreasing order. Line:579.

Results for battle.c:
On 32-bit platform, structure size can be reduced from 32 to 28 bytes by rearranging the fields according to their sizes in decreasing order. Line:187.

Results for map.c:
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'. Line:3456.
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'. Line:3489.

Results for pc_groups.c:
On 32-bit platform, structure size can be reduced from 40 to 36 bytes by rearranging the fields according to their sizes in decreasing order. Line:19.

Results for pc.c:
A part of conditional expression is always true: 0x0fff. Line:6880.

Results for script.c:
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'. Line:13139.

I hope this information will be useful for the developers.[/color]

This post has been edited by Tiera on Apr 24, 2012 10:45

Hercules Elf Bot - Apr 24, 2012 10:59

Originally posted by [b]MarkZD[/b]
About optimization part, althouth it can look minimal, I think all possible optimizations should be used while coding, not just mentioning those above, each peaces makes very little difference separated but when it's all joined it makes the rules in the end.

Special carefull should always be used, otherwise we will start making codes with no care so in any place in future we will start making a OOP system because it's easy and fast, so after we'll start coding Windows SO.

Thanks, Tiera.

I'm not criticizing actual job, it's really great, just commenting out, cause we can always do better.

This post has been edited by MarkZD on Dec 12, 2012 13:50

Hercules Elf Bot - Apr 28, 2012 6:41

Originally posted by [b]Tiera[/b]
[color=#008000]Any comments from devs?[/color]