Browse Source

navio_sysfs_rc_in: avoid dynamic memory allocation for path

sbg
Beat Küng 8 years ago committed by Lorenz Meier
parent
commit
b864983c5e
  1. 5
      src/drivers/navio_sysfs_rc_in/navio_sysfs_rc_in.cpp

5
src/drivers/navio_sysfs_rc_in/navio_sysfs_rc_in.cpp

@ -107,12 +107,11 @@ private:
int RcInput::navio_rc_init() int RcInput::navio_rc_init()
{ {
int i; int i;
char *buf; char buf[64];
for (i = 0; i < _channels; ++i) { for (i = 0; i < _channels; ++i) {
::asprintf(&buf, "%s/ch%d", RCINPUT_DEVICE_PATH_BASE, i); ::snprintf(buf, sizeof(buf), "%s/ch%d", RCINPUT_DEVICE_PATH_BASE, i);
int fd = ::open(buf, O_RDONLY); int fd = ::open(buf, O_RDONLY);
::free(buf);
if (fd < 0) { if (fd < 0) {
PX4_WARN("error: open %d failed", i); PX4_WARN("error: open %d failed", i);

Loading…
Cancel
Save