@@ 42,6 42,14 @@ using namespace std::literals;
" %1$s [-s] [-{T|w}] [-HaIL] [-ublrpdt] am I\n"
+static_assert(USER_PROCESS >= 0);
+static_assert(BOOT_TIME >= 0);
+static_assert(LOGIN_PROCESS >= 0);
+static_assert(RUN_LVL >= 0);
+static_assert(DEAD_PROCESS >= 0);
+static_assert(INIT_PROCESS >= 0);
+static_assert(OLD_TIME >= 0);
+static_assert(NEW_TIME >= 0);
static_assert(USER_PROCESS < 16);
static_assert(BOOT_TIME < 16);
static_assert(LOGIN_PROCESS < 16);
@@ 226,7 234,7 @@ int main(int argc, const char * const * argv) {
continue;
auto ut_line = vore::utmpx::line(utx);
- if(ut_line.substr(0, filter.size()) != filter) // std::string_view::starts_with() is C++20
+ if(!filter.empty() && ut_line != filter)
continue;
std::optional<struct stat> sb;
@@ 342,9 350,7 @@ int main(int argc, const char * const * argv) {
break;
}
} else if(lookup) { // && !ips
- struct addrinfo hints {
- .ai_flags = AI_CANONNAME | AI_IDN | AI_CANONIDN
- };
+ const struct addrinfo hints { .ai_flags = AI_CANONNAME | AI_IDN | AI_CANONIDN };
if(struct addrinfo * ai; !getaddrinfo(MAYBE_DUPA(host), nullptr, &hints, &ai)) {
l.emplace_back(std::move((std::string{'('} += ai->ai_canonname) += ')'));
freeaddrinfo(ai);