Skip to content

Commit

Permalink
openvpn.c: Avoid -Waddress warnings with MinGW
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
flichtenheld authored and cron2 committed Feb 18, 2025
1 parent 528df5e commit 39c31ae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions openvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,23 @@ void
OnLogLine(connection_t *c, char *line)
{
HWND logWnd = GetDlgItem(c->hwndStatus, ID_EDT_LOG);
char *flags, *message;
time_t timestamp;
TCHAR *datetime;
const SETTEXTEX ste = { .flags = ST_SELECTION, .codepage = CP_UTF8 };

flags = strchr(line, ',') + 1;
if (flags - 1 == NULL)
char *flags = strchr(line, ',');
if (flags == NULL)
{
return;
}
flags++;

message = strchr(flags, ',') + 1;
if (message - 1 == NULL)
char *message = strchr(flags, ',');
if (message == NULL)
{
return;
}
message++;
size_t flag_size = message - flags - 1; /* message is always > flags */

/* Remove lines from log window if it is getting full */
Expand Down

0 comments on commit 39c31ae

Please sign in to comment.