Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.
/ readsb Public archive

fix warnings when compiling with gcc8 #14

Merged
merged 1 commit into from
Jun 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix warnings when compiling with gcc8
E.g. when compiling with gcc8 with warnings as errors you'll get the following:

    mode_s.c: In function 'nav_modes_to_string':
    mode_s.c:1626:9: error: 'strncat' specified bound 10 equals source length [-Werror=stringop-overflow=]
    strncat(buf, "autopilot ", 10);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This error is indicating that you should be using strcat instead of strncat
since the length of source is same as the bound.
  • Loading branch information
nnathan committed Jun 26, 2019
commit e3c3eb849f4886e348219b83a9bea0956636cbe5
12 changes: 6 additions & 6 deletions mode_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -1623,17 +1623,17 @@ static const char *nav_modes_to_string(nav_modes_t flags) {

buf[0] = 0;
if (flags & NAV_MODE_AUTOPILOT)
strncat(buf, "autopilot ", 10);
strcat(buf, "autopilot ");
if (flags & NAV_MODE_VNAV)
strncat(buf, "vnav ", 6);
strcat(buf, "vnav ");
if (flags & NAV_MODE_ALT_HOLD)
strncat(buf, "althold ", 8);
strcat(buf, "althold ");
if (flags & NAV_MODE_APPROACH)
strncat(buf, "approach ", 9);
strcat(buf, "approach ");
if (flags & NAV_MODE_LNAV)
strncat(buf, "lnav ", 5);
strcat(buf, "lnav ");
if (flags & NAV_MODE_TCAS)
strncat(buf, "tcas ", 5);
strcat(buf, "tcas ");

if (buf[0] != 0)
buf[strlen(buf) - 1] = 0;
Expand Down