Skip to content

Comments

Avoid Compiler warnings#725

Merged
cron2 merged 7 commits intoOpenVPN:masterfrom
flichtenheld:compiler-warnings
Feb 18, 2025
Merged

Avoid Compiler warnings#725
cron2 merged 7 commits intoOpenVPN:masterfrom
flichtenheld:compiler-warnings

Conversation

@flichtenheld
Copy link
Member

Try to avoid various compiler warnings both in MinGW and MSVC builds.

openvpn.c:1709:29: warning: ISO C does not support the 'I'
 scanf flag [-Wformat=]
openvpn.c:1709:34: warning: format ‘%u’ expects argument
 of type ‘unsigned int *’, but argument 3 has type
 ‘long long unsigned int *’ [-Wformat=]

Switch to using portable identifiers.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Avoid
warning C4996: '_snwprintf': This function or variable may be unsafe

Also makes the code generally simpler.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Avoid
warning C4996: '_wfopen': This function or variable may be unsafe

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
But avoid -Wcast-function-type (from -Wextra)
since that is not useful for code using
GetProcAddress.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
This happens on newer MinGW versions:
openvpn.c:176:19: error: the comparison will always
evaluate as ‘false’ for the pointer operand in
‘flags + -1’ must not be NULL [-Werror=address]

Strictly speaking this is a false positive, but
the pointer handling is a bit weird, so make the
code more straight-forward.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
tray.c:783:36: error: the comparison will always
evaluate as ‘true’ for the pointer operand [...]
must not be NULL [-Werror=address]

True.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
echo.c:221:72: error: comparison of integer expressions of
different signedness: ‘long unsigned int’ and
‘time_t’ {aka ‘long int’} [-Werror=sign-compare]

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Copy link
Member

@lstipakov lstipakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested MinGW, but stared at the code and tested msvc build - looks good (as before).

@cron2 cron2 merged commit 5f84460 into OpenVPN:master Feb 18, 2025
10 checks passed
@flichtenheld flichtenheld deleted the compiler-warnings branch February 18, 2025 13:12
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.

3 participants