A bunch of small changes
Created by: irwir
That is what was left after merging changes for 64-bit Windows (you did a good job then). This PR is supposed to decrease the number of warnings and slightly improve code style.
General considerations.
- Assignments of
NULL
to local variable afterfree()
were disliked by static analysers. The reason was: assigned value was never used. Also compilers might optimize it away. Therefore these assignment add very little to code safety, and could be dropped. If you still would like to keep it, a simple macro might be used to eliminate these assignments in Release configurations. - Use of the same parameter names in function declaration and definition should improve coding style.
- Enforced type consistency eliminates warnings (and prevents errors).
Additional comments.
connecthostport.c
Missed replacement: -1
should have been INVALID_SOCKET
.
ai_addrlen
field is declared as size_t
in MS VC, but parameter is int
(truncation warning fix).
minisoap.c
Declaration and initialization in one line.
minissdpc.c
Prefix dw
stands for DWORD
, which is defined as unsigned long
; and the correct format should be %lu
, not %ld
minissdpc.h
Parameter names changed to match function's definitions.
miniupnpc.c
strlen()
returns value of size_t
type in MS VC. Hence the change from int l, n;
to size_t
In UPNP_GetValidIGD
checks were removed because some conditions should be always true.
Quick explanation:
devlist
is not empty (line 581), therefore ndev
is at least 1 in line 591
desc
cannot be NULL
after lines 594-595
miniwget.c
The first i<n
condition was already verified in the loop header.
Change int l;
to size_t ;l
because of pointer arithmetics and sizeof.
minixml.h
Parentheses around macros and its parameters as a standard safety measure (static analysis).
upnpcommands.c
The constant UPNPCOMMAND_HTTP_ERROR
is defined as signed, but it had to be used both as signed and unsigned (type mismatch warning fix).