src/Instrumentation/: use sizeof in snprintf.
This commit is contained in:
parent
61aaf44495
commit
aeb75738ed
4 changed files with 8 additions and 8 deletions
|
@ -52,7 +52,7 @@ void KLN89AltPage::Update(double dt) {
|
||||||
_kln89->_userBaroSetting = (int)((float)_kln89->_userBaroSetting * 0.0295301 * 100 + 0.5);
|
_kln89->_userBaroSetting = (int)((float)_kln89->_userBaroSetting * 0.0295301 * 100 + 0.5);
|
||||||
}
|
}
|
||||||
char buf[6];
|
char buf[6];
|
||||||
snprintf(buf, 6, "%2i.%02i", _kln89->_userBaroSetting/100, _kln89->_userBaroSetting % 100);
|
snprintf(buf, sizeof(buf), "%2i.%02i", _kln89->_userBaroSetting/100, _kln89->_userBaroSetting % 100);
|
||||||
string s = buf;
|
string s = buf;
|
||||||
if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
|
if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
|
||||||
_kln89->DrawText(s, 2, 7, 3);
|
_kln89->DrawText(s, 2, 7, 3);
|
||||||
|
@ -69,7 +69,7 @@ void KLN89AltPage::Update(double dt) {
|
||||||
_kln89->_userBaroSetting = (int)(((float)_kln89->_userBaroSetting / 100.0) * 33.8637526 + 0.5);
|
_kln89->_userBaroSetting = (int)(((float)_kln89->_userBaroSetting / 100.0) * 33.8637526 + 0.5);
|
||||||
}
|
}
|
||||||
char buf[5];
|
char buf[5];
|
||||||
snprintf(buf, 5, "%4i", _kln89->_userBaroSetting);
|
snprintf(buf, sizeof(buf), "%4i", _kln89->_userBaroSetting);
|
||||||
string s = buf;
|
string s = buf;
|
||||||
if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
|
if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
|
||||||
_kln89->DrawText(s, 2, 8, 3);
|
_kln89->DrawText(s, 2, 8, 3);
|
||||||
|
|
|
@ -150,7 +150,7 @@ void KLN89AptPage::Update(double dt) {
|
||||||
if(hrDiff != 0) {
|
if(hrDiff != 0) {
|
||||||
_kln89->DrawText(ap->getLongitude() >= 0.0 ? "+" : "-", 2, 3, 2);
|
_kln89->DrawText(ap->getLongitude() >= 0.0 ? "+" : "-", 2, 3, 2);
|
||||||
char buf[3];
|
char buf[3];
|
||||||
snprintf(buf, 3, "%02i", hrDiff);
|
snprintf(buf, sizeof(buf), "%02i", hrDiff);
|
||||||
_kln89->DrawText((string)buf, 2, 4, 2);
|
_kln89->DrawText((string)buf, 2, 4, 2);
|
||||||
_kln89->DrawText("( DT)", 2, 6, 2);
|
_kln89->DrawText("( DT)", 2, 6, 2);
|
||||||
if(ap->getLongitude() >= 0.0) {
|
if(ap->getLongitude() >= 0.0) {
|
||||||
|
@ -159,7 +159,7 @@ void KLN89AptPage::Update(double dt) {
|
||||||
hrDiff--;
|
hrDiff--;
|
||||||
}
|
}
|
||||||
_kln89->DrawText(ap->getLongitude() >= 0.0 ? "+" : "-", 2, 7, 2);
|
_kln89->DrawText(ap->getLongitude() >= 0.0 ? "+" : "-", 2, 7, 2);
|
||||||
snprintf(buf, 3, "%02i", hrDiff);
|
snprintf(buf, sizeof(buf), "%02i", hrDiff);
|
||||||
_kln89->DrawText((string)buf, 2, 8, 2);
|
_kln89->DrawText((string)buf, 2, 8, 2);
|
||||||
}
|
}
|
||||||
// I guess we can make a heuristic guess as to fuel availability from the runway sizes
|
// I guess we can make a heuristic guess as to fuel availability from the runway sizes
|
||||||
|
|
|
@ -116,7 +116,7 @@ void KLN89CalPage::Update(double dt) {
|
||||||
if(!(_uLinePos == 3 && crsr && blink)) { _kln89->DrawText("--", 2, 13, 2); }
|
if(!(_uLinePos == 3 && crsr && blink)) { _kln89->DrawText("--", 2, 13, 2); }
|
||||||
}
|
}
|
||||||
if(_alarmAnnotate && _alarmIn.hr() < 10) {
|
if(_alarmAnnotate && _alarmIn.hr() < 10) {
|
||||||
sprintf(buf, "%01i", _alarmIn.hr());
|
snprintf(buf, sizeof(buf), "%01i", _alarmIn.hr());
|
||||||
if(!(_uLinePos == 4 && crsr && blink)) { _kln89->DrawText((string)buf, 2, 11, 1); }
|
if(!(_uLinePos == 4 && crsr && blink)) { _kln89->DrawText((string)buf, 2, 11, 1); }
|
||||||
sprintf(buf, "%02i", _alarmIn.min());
|
sprintf(buf, "%02i", _alarmIn.min());
|
||||||
if(!(_uLinePos == 5 && crsr && blink)) { _kln89->DrawText((string)buf, 2, 13, 1); }
|
if(!(_uLinePos == 5 && crsr && blink)) { _kln89->DrawText((string)buf, 2, 13, 1); }
|
||||||
|
|
|
@ -114,11 +114,11 @@ Clock::update (double delta_time_sec)
|
||||||
while (hour >= 24)
|
while (hour >= 24)
|
||||||
hour -= 24;
|
hour -= 24;
|
||||||
|
|
||||||
sprintf(_indicated_string, "%02d:%02d:%02d", hour, min, sec);
|
snprintf(_indicated_string, sizeof(_indicated_string), "%02d:%02d:%02d", hour, min, sec);
|
||||||
_string_node->setStringValue(_indicated_string);
|
_string_node->setStringValue(_indicated_string);
|
||||||
sprintf(_indicated_short_string, "%02d:%02d", hour, min);
|
snprintf(_indicated_short_string, sizeof(_indicated_short_string), "%02d:%02d", hour, min);
|
||||||
_string_node1->setStringValue(_indicated_short_string);
|
_string_node1->setStringValue(_indicated_short_string);
|
||||||
sprintf(_local_short_string, "%02d:%02d", lhour, min);
|
snprintf(_local_short_string, sizeof(_local_short_string), "%02d:%02d", lhour, min);
|
||||||
_string_node2->setStringValue(_local_short_string);
|
_string_node2->setStringValue(_local_short_string);
|
||||||
_is_serviceable = true;
|
_is_serviceable = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue