fixed warnings

This commit is contained in:
Simon Stürz 2014-10-18 20:01:15 +02:00 committed by Michael Zanetti
parent 1cc0c4dd15
commit 71bce5a281

View File

@ -61,7 +61,7 @@ bool Gpio::exportGpio()
return false; return false;
} }
int len = snprintf(buf, sizeof(buf), "%d", m_gpio); size_t len = snprintf(buf, sizeof(buf), "%d", m_gpio);
write(fd, buf, len); write(fd, buf, len);
close(fd); close(fd);
@ -78,7 +78,7 @@ bool Gpio::unexportGpio()
//qDebug() << "ERROR: could not open /sys/class/gpio/unexport"; //qDebug() << "ERROR: could not open /sys/class/gpio/unexport";
return false; return false;
} }
int len = snprintf(buf, sizeof(buf), "%d", m_gpio); size_t len = snprintf(buf, sizeof(buf), "%d", m_gpio);
write(fd, buf, len); write(fd, buf, len);
close(fd); close(fd);
@ -126,13 +126,21 @@ bool Gpio::setDirection(int dir)
return false; return false;
} }
if(dir == INPUT){ if(dir == INPUT){
write(fd, "in", 3); if(write(fd, "in", 3) != 3){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
m_dir = INPUT; m_dir = INPUT;
close(fd); close(fd);
return true; return true;
} }
if(dir == OUTPUT){ if(dir == OUTPUT){
write(fd, "out", 4); if(write(fd, "out", 4) != 4){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
m_dir = OUTPUT; m_dir = OUTPUT;
close(fd); close(fd);
return true; return true;
@ -169,12 +177,20 @@ bool Gpio::setValue(unsigned int value)
} }
if(value == LOW){ if(value == LOW){
write(fd, "0", 2); if(write(fd, "0", 2) != 2){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
close(fd); close(fd);
return true; return true;
} }
if(value == HIGH){ if(value == HIGH){
write(fd, "1", 2); if(write(fd, "1", 2) != 2){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
close(fd); close(fd);
return true; return true;
} }
@ -257,17 +273,29 @@ bool Gpio::setEdgeInterrupt(int edge)
} }
if(edge == EDGE_FALLING){ if(edge == EDGE_FALLING){
write(fd, "falling", 8); if(write(fd, "falling", 8) != 8){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
close(fd); close(fd);
return true; return true;
} }
if(edge == EDGE_RISING){ if(edge == EDGE_RISING){
write(fd, "rising", 7); if(write(fd, "rising", 7) != 7){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
close(fd); close(fd);
return true; return true;
} }
if(edge == EDGE_BOTH){ if(edge == EDGE_BOTH){
write(fd, "both", 5); if(write(fd, "both", 5) != 5){
qDebug() << "ERROR: could not set edge interrupt";
close(fd);
return false;
}
close(fd); close(fd);
return true; return true;
} }