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

Commit

Permalink
fix warnings when compiling with gcc8
Browse files Browse the repository at this point in the history
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
1 parent 184cb8e commit e3c3eb8
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit e3c3eb8

Please sign in to comment.