Skip to content

Commit dcae02b

Browse files
use filename()
Signed-off-by: Pascal Bauer <[email protected]>
1 parent 64c4705 commit dcae02b

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

common/lib/kernel/devices/ip_device.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ size_t IpDevice::addr() const {
4141
}
4242

4343
bool IpDevice::is_path_valid(const std::filesystem::path unsafe_path) {
44-
// Split the string at last slash
45-
int pos = unsafe_path.u8string().rfind('/');
46-
std::string assumed_device_name = unsafe_path.u8string().substr(pos + 1);
44+
std::string assumed_device_name = unsafe_path.filename();
4745

4846
// Match format of hexaddr.devicename
4947
if (!std::regex_match(assumed_device_name,

common/lib/kernel/devices/platform_device.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,4 @@ std::filesystem::path PlatformDevice::override_path() const {
4848
return this->m_override_path;
4949
}
5050

51-
std::string PlatformDevice::name() const {
52-
size_t pos = this->m_path.u8string().rfind('/');
53-
return this->m_path.u8string().substr(pos + 1);
54-
}
51+
std::string PlatformDevice::name() const { return this->m_path.filename(); }

0 commit comments

Comments
 (0)