Coverity fixes (#1790)

* Various coverity fixes (High Impact Outstanding)

* Removed typo in comment

* Removed wrong line of code.

* Minor fixes

* snprintf finally done right

* Added space

* Wind direction finally OK
This commit is contained in:
Michal Podhradsky
2016-07-11 15:58:23 -07:00
committed by GitHub
parent b3042ba955
commit 6b777fcbf3
10 changed files with 56 additions and 23 deletions
+16 -2
View File
@@ -506,10 +506,24 @@ static void init_jsbsim(double dt)
char buf[1024];
string rootdir;
string jsbsim_home = "/conf/simulator/jsbsim/";
string jsbsim_ic_name;
sprintf(buf, "%s/conf/simulator/jsbsim/", getenv("PAPARAZZI_HOME"));
rootdir = string(buf);
char* pprz_home = getenv("PAPARAZZI_HOME");
int cnt = -1;
if (strlen(pprz_home) < sizeof(buf)) {
cnt = snprintf(buf, strlen(pprz_home) + 1, "%s", pprz_home);
rootdir = string(buf) + jsbsim_home;
}
// check the results
if (cnt < 0){
// Either pprz_home path too long for the buffer
// or writing the string was not successful.
cout << "PPRZ_HOME not set correctly, exiting..." << endl;
exit(-1);
}
/* if jsbsim initial conditions are defined, use them
* otherwise use flightplan location
+1
View File
@@ -160,6 +160,7 @@ void nps_flightgear_send()
struct FGNetGUI gui;
gui.version = FG_NET_GUI_VERSION;
gui.padding1 = 0; // initialize the padding variable to zero
gui.latitude = fdm.lla_pos.lat;
gui.longitude = fdm.lla_pos.lon;
@@ -33,6 +33,7 @@ int nps_radio_control_spektrum_init(const char *device)
return -1;
}
struct termios termios;
termios.c_iflag = 0; // properly initialize variable
/* input modes */
termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | INPCK | ISTRIP | INLCR | IGNCR
| ICRNL | IUCLC | IXON | IXANY | IXOFF | IMAXBEL);