diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index 57af6051b..3ce8aa44b 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -37,7 +37,7 @@ FilesystemNodePOSIX::FilesystemNodePOSIX(const string& path, bool verify) // Expand '~' to the HOME environment variable if(_path[0] == '~') { - string home = BSPF::getenv("HOME"); + const string& home = BSPF::getenv("HOME"); if(home != EmptyString) _path.replace(0, 1, home); } @@ -78,7 +78,7 @@ void FilesystemNodePOSIX::setFlags() string FilesystemNodePOSIX::getShortPath() const { // If the path starts with the home directory, replace it with '~' - string home = BSPF::getenv("HOME"); + const string& home = BSPF::getenv("HOME"); if(home != EmptyString && BSPF::startsWithIgnoreCase(_path, home)) { string path = "~"; @@ -106,7 +106,7 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) con return false; // Loop over dir entries using readdir - struct dirent* dp; + struct dirent* dp = nullptr; while ((dp = readdir(dirp)) != nullptr) { // Ignore all hidden files diff --git a/src/unix/SerialPortUNIX.cxx b/src/unix/SerialPortUNIX.cxx index 30ec04cda..c598e69e3 100644 --- a/src/unix/SerialPortUNIX.cxx +++ b/src/unix/SerialPortUNIX.cxx @@ -104,14 +104,14 @@ StringList SerialPortUNIX::portNames() // Check if port is valid; for now that means if it can be opened // Eventually we may extend this to do more intensive checks - auto isPortValid = [](const string& port) { + const auto isPortValid = [](const string& port) { int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); if(handle > 0) close(handle); return handle > 0; }; // Get all possible devices in the '/dev' directory - FilesystemNode::NameFilter filter = [](const FilesystemNode& node) { + const FilesystemNode::NameFilter filter = [](const FilesystemNode& node) { return BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyACM") || BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyUSB"); };