1
0
Fork 0

Fix compiler warnings

This commit is contained in:
Stuart Buchanan 2020-04-12 21:52:19 +01:00
parent b561cc8fac
commit 9b20c08db3
3 changed files with 55 additions and 55 deletions

View file

@ -66,7 +66,7 @@ private:
}; };
std::vector<ServerInfo> m_servers; std::vector<ServerInfo> m_servers;
int m_currentIndex = 0; unsigned int m_currentIndex = 0;
}; };
#endif // MPSERVERSMODEL_H #endif // MPSERVERSMODEL_H

View file

@ -160,7 +160,7 @@ namespace HID
case AD_AlphanumericDisplay: return "alphanumeric"; case AD_AlphanumericDisplay: return "alphanumeric";
case AD_CharacterReport: return "character-report"; case AD_CharacterReport: return "character-report";
case AD_DisplayData: return "display-data"; case AD_DisplayData: return "display-data";
case AD_DisplayBrightness: return "display-brightness"; case AD_DisplayBrightness: return "display-brightness";
case AD_7SegmentDirectMap: return "seven-segment-direct"; case AD_7SegmentDirectMap: return "seven-segment-direct";
case AD_14SegmentDirectMap: return "fourteen-segment-direct"; case AD_14SegmentDirectMap: return "fourteen-segment-direct";
@ -244,7 +244,7 @@ public:
bool Open() override; bool Open() override;
void Close() override; void Close() override;
void Configure(SGPropertyNode_ptr node) override; void Configure(SGPropertyNode_ptr node) override;
void update(double dt) override; void update(double dt) override;
const char *TranslateEventName(FGEventData &eventData) override; const char *TranslateEventName(FGEventData &eventData) override;
void Send( const char * eventName, double value ) override; void Send( const char * eventName, double value ) override;
@ -307,21 +307,21 @@ private:
int maybeSignExtend(Item* item, int inValue); int maybeSignExtend(Item* item, int inValue);
void defineReport(SGPropertyNode_ptr reportNode); void defineReport(SGPropertyNode_ptr reportNode);
std::vector<Report*> _reports; std::vector<Report*> _reports;
std::string _hidPath; std::string _hidPath;
hid_device* _device = nullptr; hid_device* _device = nullptr;
bool _haveNumberedReports = false; bool _haveNumberedReports = false;
bool _debugRaw = false; bool _debugRaw = false;
/// set if we parsed the device description our XML /// set if we parsed the device description our XML
/// instead of from the USB data. Useful on Windows where the data /// instead of from the USB data. Useful on Windows where the data
/// is inaccessible, or devices with broken descriptors /// is inaccessible, or devices with broken descriptors
bool _haveLocalDescriptor = false; bool _haveLocalDescriptor = false;
/// allow specifying the descriptor as hex bytes in XML /// allow specifying the descriptor as hex bytes in XML
std::vector<uint8_t>_rawXMLDescriptor; std::vector<uint8_t>_rawXMLDescriptor;
// all sets which will be send on the next update() call. // all sets which will be send on the next update() call.
std::set<Report*> _dirtyReports; std::set<Report*> _dirtyReports;
}; };
@ -347,7 +347,7 @@ FGHIDDevice::FGHIDDevice(hid_device_info *devInfo, FGHIDEventInput *)
std::wstring manufacturerName, productName; std::wstring manufacturerName, productName;
productName = devInfo->product_string ? std::wstring(devInfo->product_string) productName = devInfo->product_string ? std::wstring(devInfo->product_string)
: L"unknown HID device"; : L"unknown HID device";
if (devInfo->manufacturer_string) { if (devInfo->manufacturer_string) {
manufacturerName = std::wstring(devInfo->manufacturer_string); manufacturerName = std::wstring(devInfo->manufacturer_string);
SetName(simgear::strutils::convertWStringToUtf8(manufacturerName) + " " + SetName(simgear::strutils::convertWStringToUtf8(manufacturerName) + " " +
@ -377,25 +377,25 @@ void FGHIDDevice::Configure(SGPropertyNode_ptr node)
{ {
// base class first // base class first
FGInputDevice::Configure(node); FGInputDevice::Configure(node);
if (node->hasChild("hid-descriptor")) { if (node->hasChild("hid-descriptor")) {
_haveLocalDescriptor = true; _haveLocalDescriptor = true;
if (debugEvents) { if (debugEvents) {
SG_LOG(SG_INPUT, SG_INFO, GetUniqueName() << " will configure using local HID descriptor"); SG_LOG(SG_INPUT, SG_INFO, GetUniqueName() << " will configure using local HID descriptor");
} }
for (auto report : node->getChild("hid-descriptor")->getChildren("report")) { for (auto report : node->getChild("hid-descriptor")->getChildren("report")) {
defineReport(report); defineReport(report);
} }
} }
if (node->hasChild("hid-raw-descriptor")) { if (node->hasChild("hid-raw-descriptor")) {
_rawXMLDescriptor = simgear::strutils::decodeHex(node->getStringValue("hid-raw-descriptor")); _rawXMLDescriptor = simgear::strutils::decodeHex(node->getStringValue("hid-raw-descriptor"));
if (debugEvents) { if (debugEvents) {
SG_LOG(SG_INPUT, SG_INFO, GetUniqueName() << " will configure using XML-defined raw HID descriptor"); SG_LOG(SG_INPUT, SG_INFO, GetUniqueName() << " will configure using XML-defined raw HID descriptor");
} }
} }
if (node->getBoolValue("hid-debug-raw")) { if (node->getBoolValue("hid-debug-raw")) {
_debugRaw = true; _debugRaw = true;
} }
@ -418,17 +418,17 @@ bool FGHIDDevice::Open()
SG_LOG(SG_INPUT, SG_WARN, "HID: " << GetUniqueName() << " failed to read HID descriptor"); SG_LOG(SG_INPUT, SG_WARN, "HID: " << GetUniqueName() << " failed to read HID descriptor");
return false; return false;
} }
_rawXMLDescriptor.resize(descriptorSize); _rawXMLDescriptor.resize(descriptorSize);
} }
#endif #endif
if (!_haveLocalDescriptor) { if (!_haveLocalDescriptor) {
bool ok = parseUSBHIDDescriptor(); bool ok = parseUSBHIDDescriptor();
if (!ok) if (!ok)
return false; return false;
} }
for (auto& v : handledEvents) { for (auto& v : handledEvents) {
auto reportItem = itemWithName(v.first); auto reportItem = itemWithName(v.first);
if (!reportItem.second) { if (!reportItem.second) {
@ -440,13 +440,13 @@ bool FGHIDDevice::Open()
if (debugEvents) { if (debugEvents) {
SG_LOG(SG_INPUT, SG_INFO, "\tfound item for event:" << v.first); SG_LOG(SG_INPUT, SG_INFO, "\tfound item for event:" << v.first);
} }
reportItem.second->event = event; reportItem.second->event = event;
} }
return true; return true;
} }
bool FGHIDDevice::parseUSBHIDDescriptor() bool FGHIDDevice::parseUSBHIDDescriptor()
{ {
#if defined(SG_WINDOWS) #if defined(SG_WINDOWS)
@ -457,12 +457,12 @@ bool FGHIDDevice::parseUSBHIDDescriptor()
return false; return false;
} }
#endif #endif
if (_debugRaw) { if (_debugRaw) {
SG_LOG(SG_INPUT, SG_INFO, "\nHID: descriptor for:" << GetUniqueName()); SG_LOG(SG_INPUT, SG_INFO, "\nHID: descriptor for:" << GetUniqueName());
{ {
std::ostringstream byteString; std::ostringstream byteString;
for (auto i=0; i<_rawXMLDescriptor.size(); ++i) { for (auto i=0; i<_rawXMLDescriptor.size(); ++i) {
byteString << hexTable[_rawXMLDescriptor[i] >> 4]; byteString << hexTable[_rawXMLDescriptor[i] >> 4];
byteString << hexTable[_rawXMLDescriptor[i] & 0x0f]; byteString << hexTable[_rawXMLDescriptor[i] & 0x0f];
@ -471,15 +471,15 @@ bool FGHIDDevice::parseUSBHIDDescriptor()
SG_LOG(SG_INPUT, SG_INFO, "\tbytes: " << byteString.str()); SG_LOG(SG_INPUT, SG_INFO, "\tbytes: " << byteString.str());
} }
} }
hid_item* rootItem = nullptr; hid_item* rootItem = nullptr;
hid_parse_reportdesc(_rawXMLDescriptor.data(), _rawXMLDescriptor.size(), &rootItem); hid_parse_reportdesc(_rawXMLDescriptor.data(), _rawXMLDescriptor.size(), &rootItem);
if (debugEvents) { if (debugEvents) {
SG_LOG(SG_INPUT, SG_INFO, "\nHID: scan for:" << GetUniqueName()); SG_LOG(SG_INPUT, SG_INFO, "\nHID: scan for:" << GetUniqueName());
} }
parseCollection(rootItem); parseCollection(rootItem);
hid_free_reportdesc(rootItem); hid_free_reportdesc(rootItem);
return true; return true;
} }
@ -669,7 +669,7 @@ void FGHIDDevice::sendReport(Report* report) const
} }
reportLength /= 8; reportLength /= 8;
if (_debugRaw) { if (_debugRaw) {
std::ostringstream byteString; std::ostringstream byteString;
for (size_t i=0; i<reportLength; ++i) { for (size_t i=0; i<reportLength; ++i) {
@ -679,7 +679,7 @@ void FGHIDDevice::sendReport(Report* report) const
} }
SG_LOG(SG_INPUT, SG_INFO, "sending bytes: " << byteString.str()); SG_LOG(SG_INPUT, SG_INFO, "sending bytes: " << byteString.str());
} }
// send the data, based on the report type // send the data, based on the report type
if (report->type == HID::ReportType::Feature) { if (report->type == HID::ReportType::Feature) {
@ -748,13 +748,13 @@ void FGHIDDevice::SendFeatureReport(unsigned int reportId, const std::string& da
if (!_device) { if (!_device) {
return; return;
} }
if (_debugRaw) { if (_debugRaw) {
SG_LOG(SG_INPUT, SG_INFO, GetName() << ": FGHIDDevice: Sending feature report:" << (int) reportId << ", len=" << data.size()); SG_LOG(SG_INPUT, SG_INFO, GetName() << ": FGHIDDevice: Sending feature report:" << (int) reportId << ", len=" << data.size());
{ {
std::ostringstream byteString; std::ostringstream byteString;
for (int i=0; i<data.size(); ++i) { for (unsigned int i=0; i<data.size(); ++i) {
byteString << hexTable[data[i] >> 4]; byteString << hexTable[data[i] >> 4];
byteString << hexTable[data[i] & 0x0f]; byteString << hexTable[data[i] & 0x0f];
byteString << " "; byteString << " ";
@ -797,7 +797,7 @@ void FGHIDDevice::Send(const char *eventName, double value)
item.second->lastValue = intValue; item.second->lastValue = intValue;
_dirtyReports.insert(item.first); _dirtyReports.insert(item.first);
} }
void FGHIDDevice::defineReport(SGPropertyNode_ptr reportNode) void FGHIDDevice::defineReport(SGPropertyNode_ptr reportNode)
{ {
const int nChildren = reportNode->nChildren(); const int nChildren = reportNode->nChildren();
@ -824,21 +824,21 @@ void FGHIDDevice::defineReport(SGPropertyNode_ptr reportNode)
bitCount += size; bitCount += size;
continue; continue;
} }
if (!strcmp(nd->getName(), "type") || !strcmp(nd->getName(), "id")) { if (!strcmp(nd->getName(), "type") || !strcmp(nd->getName(), "id")) {
continue; // already handled above continue; // already handled above
} }
// allow repeating items // allow repeating items
uint8_t count = nd->getIntValue("count", 1); uint8_t count = nd->getIntValue("count", 1);
std::string name = nd->getNameString(); std::string name = nd->getNameString();
const auto lastHypen = name.rfind("-"); const auto lastHypen = name.rfind("-");
std::string baseName = name.substr(0, lastHypen + 1); std::string baseName = name.substr(0, lastHypen + 1);
int baseIndex = std::stoi(name.substr(lastHypen + 1)); int baseIndex = std::stoi(name.substr(lastHypen + 1));
const bool isRelative = (name.find("rel-") == 0); const bool isRelative = (name.find("rel-") == 0);
const bool isSigned = nd->getBoolValue("is-signed", false); const bool isSigned = nd->getBoolValue("is-signed", false);
for (uint8_t i=0; i < count; ++i) { for (uint8_t i=0; i < count; ++i) {
std::ostringstream oss; std::ostringstream oss;
oss << baseName << (baseIndex + i); oss << baseName << (baseIndex + i);
@ -962,7 +962,7 @@ SGSubsystemMgr::Registrant<FGHIDEventInput> registrantFGHIDEventInput;
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
void FGHIDEventInput::FGHIDEventInputPrivate::evaluateDevice(hid_device_info* deviceInfo) void FGHIDEventInput::FGHIDEventInputPrivate::evaluateDevice(hid_device_info* deviceInfo)
{ {
// allocate an input device, and add to the base class to see if we have // allocate an input device, and add to the base class to see if we have
// a config // a config
p->AddDevice(new FGHIDDevice(deviceInfo, p)); p->AddDevice(new FGHIDDevice(deviceInfo, p));

View file

@ -1251,12 +1251,12 @@ NavDataCache::NavDataCache()
} }
} }
} // of retry loop } // of retry loop
double RADIUS_EARTH_M = 7000 * 1000.0; // 7000km is plenty double RADIUS_EARTH_M = 7000 * 1000.0; // 7000km is plenty
SGVec3d earthExtent(RADIUS_EARTH_M, RADIUS_EARTH_M, RADIUS_EARTH_M); SGVec3d earthExtent(RADIUS_EARTH_M, RADIUS_EARTH_M, RADIUS_EARTH_M);
Octree::global_spatialOctree = Octree::global_spatialOctree =
new Octree::Branch(SGBox<double>(-earthExtent, earthExtent), 1); new Octree::Branch(SGBox<double>(-earthExtent, earthExtent), 1);
// Update d->aptDatFilesInfo, d->metarDatPath, d->navDatPath, etc. // Update d->aptDatFilesInfo, d->metarDatPath, d->navDatPath, etc.
updateListsOfDatFiles(); updateListsOfDatFiles();
} }
@ -2038,7 +2038,7 @@ char** NavDataCache::searchAirportNamesAndIdents(const std::string& searchInput)
string heliport("HELIPORT"); string heliport("HELIPORT");
bool heli_p = searchInput.substr(0, heliport.length()) == heliport; bool heli_p = searchInput.substr(0, heliport.length()) == heliport;
auto pos = searchInput.find(":"); auto pos = searchInput.find(":");
string aFilter((pos != string::npos) ? searchInput.substr(pos+1) : searchInput); string aFilter((pos != string::npos) ? searchInput.substr(pos+1) : searchInput);
string searchTerm("%" + aFilter + "%"); string searchTerm("%" + aFilter + "%");
if (aFilter.empty() && !heli_p) { if (aFilter.empty() && !heli_p) {
@ -2315,24 +2315,24 @@ AirwayEdgeVec NavDataCache::airwayEdgesFrom(int network, PositionedID pos)
} }
d->reset(d->airwayEdgesFrom); d->reset(d->airwayEdgesFrom);
// find bidirectional / backwsards edges // find bidirectional / backwsards edges
// at present all edges are bidirectional // at present all edges are bidirectional
sqlite3_bind_int(d->airwayEdgesTo, 1, network); sqlite3_bind_int(d->airwayEdgesTo, 1, network);
sqlite3_bind_int64(d->airwayEdgesTo, 2, pos); sqlite3_bind_int64(d->airwayEdgesTo, 2, pos);
while (d->stepSelect(d->airwayEdgesTo)) { while (d->stepSelect(d->airwayEdgesTo)) {
result.push_back(AirwayEdge( result.push_back(AirwayEdge(
sqlite3_column_int(d->airwayEdgesTo, 0), sqlite3_column_int(d->airwayEdgesTo, 0),
sqlite3_column_int64(d->airwayEdgesTo, 1) sqlite3_column_int64(d->airwayEdgesTo, 1)
)); ));
} }
d->reset(d->airwayEdgesTo); d->reset(d->airwayEdgesTo);
return result; return result;
} }
AirwayRef NavDataCache::loadAirway(int airwayID) AirwayRef NavDataCache::loadAirway(int airwayID)
{ {
sqlite3_bind_int(d->loadAirway, 1, airwayID); sqlite3_bind_int(d->loadAirway, 1, airwayID);
@ -2371,7 +2371,7 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
// linearize // linearize
PositionedIDVec result; PositionedIDVec result;
while (!rawEdges.empty()) { while (!rawEdges.empty()) {
bool didAddEdge = false; bool didAddEdge = false;
std::set<PositionedID> seen; std::set<PositionedID> seen;
@ -2379,31 +2379,31 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
PositionedIDDeque linearAirway; PositionedIDDeque linearAirway;
PositionedID firstId = rawEdges.front().first, PositionedID firstId = rawEdges.front().first,
lastId = rawEdges.front().second; lastId = rawEdges.front().second;
// first edge is trivial // first edge is trivial
linearAirway.push_back(firstId); linearAirway.push_back(firstId);
linearAirway.push_back(lastId); linearAirway.push_back(lastId);
seen.insert(firstId); seen.insert(firstId);
seen.insert(lastId); seen.insert(lastId);
rawEdges.pop_front(); rawEdges.pop_front();
while (!rawEdges.empty()) { while (!rawEdges.empty()) {
Edge e = rawEdges.front(); Edge e = rawEdges.front();
rawEdges.pop_front(); rawEdges.pop_front();
bool seenFirst = (seen.find(e.first) != seen.end()); bool seenFirst = (seen.find(e.first) != seen.end());
bool seenSecond = (seen.find(e.second) != seen.end()); bool seenSecond = (seen.find(e.second) != seen.end());
// duplicated segment, should be impossible // duplicated segment, should be impossible
assert(!(seenFirst && seenSecond)); assert(!(seenFirst && seenSecond));
if (!seenFirst && !seenSecond) { if (!seenFirst && !seenSecond) {
// push back to try later on // push back to try later on
nextDeque.push_back(e); nextDeque.push_back(e);
if (rawEdges.empty()) { if (rawEdges.empty()) {
rawEdges = nextDeque; rawEdges = nextDeque;
nextDeque.clear(); nextDeque.clear();
if (!didAddEdge) { if (!didAddEdge) {
// we have a disjoint, need to start a new section // we have a disjoint, need to start a new section
// break out of the inner while loop so the outer // break out of the inner while loop so the outer
@ -2412,10 +2412,10 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
} }
didAddEdge = false; didAddEdge = false;
} }
continue; continue;
} }
// we have an exterior edge, grow our current linear piece // we have an exterior edge, grow our current linear piece
if (seenFirst && (e.first == firstId)) { if (seenFirst && (e.first == firstId)) {
linearAirway.push_front(e.second); linearAirway.push_front(e.second);
@ -2435,20 +2435,20 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
seen.insert(e.first); seen.insert(e.first);
} }
didAddEdge = true; didAddEdge = true;
if (rawEdges.empty()) { if (rawEdges.empty()) {
rawEdges = nextDeque; rawEdges = nextDeque;
nextDeque.clear(); nextDeque.clear();
} }
} }
if (!result.empty()) if (!result.empty())
result.push_back(0); result.push_back(0);
result.insert(result.end(), linearAirway.begin(), linearAirway.end()); result.insert(result.end(), linearAirway.begin(), linearAirway.end());
} // outer loop } // outer loop
SG_LOG(SG_AUTOPILOT, SG_WARN, "Airway:" << id); SG_LOG(SG_AUTOPILOT, SG_WARN, "Airway:" << id);
for (int i=0; i<result.size(); ++i) { for (unsigned int i=0; i<result.size(); ++i) {
if (result.at(i) == 0) { if (result.at(i) == 0) {
SG_LOG(SG_AUTOPILOT, SG_WARN, i << " <break>"); SG_LOG(SG_AUTOPILOT, SG_WARN, i << " <break>");
} else { } else {
@ -2456,7 +2456,7 @@ PositionedIDVec NavDataCache::airwayWaypts(int id)
} }
} }
return result; return result;
} }