mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
lint: Use early exit/continue
This commit is contained in:
parent
99b729eb4d
commit
f0ab1331a5
1 changed files with 55 additions and 54 deletions
|
@ -930,7 +930,10 @@ static bool get_mac_address(unsigned char macaddr[MAC_ADDRESS_MAX_LEN],
|
||||||
struct ifaddrs *ifap;
|
struct ifaddrs *ifap;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
if (getifaddrs(&ifap) == 0) {
|
if (getifaddrs(&ifap) != 0) {
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
for (const ifaddrs *p = ifap; p; p = p->ifa_next) {
|
for (const ifaddrs *p = ifap; p; p = p->ifa_next) {
|
||||||
bool is_af_link = p->ifa_addr && p->ifa_addr->sa_family == AF_LINK;
|
bool is_af_link = p->ifa_addr && p->ifa_addr->sa_family == AF_LINK;
|
||||||
if (is_af_link && p->ifa_name && p->ifa_name[0] &&
|
if (is_af_link && p->ifa_name && p->ifa_name[0] &&
|
||||||
|
@ -945,7 +948,6 @@ static bool get_mac_address(unsigned char macaddr[MAC_ADDRESS_MAX_LEN],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeifaddrs(ifap);
|
freeifaddrs(ifap);
|
||||||
}
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1356,8 +1358,6 @@ class universal_notifier_named_pipe_t : public universal_notifier_t {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool poll() {
|
bool poll() {
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
// Check if we are past the readback time.
|
// Check if we are past the readback time.
|
||||||
if (this->readback_time_usec > 0 && get_time() >= this->readback_time_usec) {
|
if (this->readback_time_usec > 0 && get_time() >= this->readback_time_usec) {
|
||||||
// Read back what we wrote. We do nothing with the value.
|
// Read back what we wrote. We do nothing with the value.
|
||||||
|
@ -1372,10 +1372,11 @@ class universal_notifier_named_pipe_t : public universal_notifier_t {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if we are doing readability polling.
|
// Check to see if we are doing readability polling.
|
||||||
if (polling_due_to_readable_fd && pipe_fd >= 0) {
|
if (!polling_due_to_readable_fd || pipe_fd < 0) {
|
||||||
// We are polling, so we are definitely going to sync.
|
return false;
|
||||||
result = true;
|
}
|
||||||
|
|
||||||
|
// We are polling, so we are definitely going to sync.
|
||||||
// See if this is still readable.
|
// See if this is still readable.
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
|
@ -1393,9 +1394,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t {
|
||||||
drain_excessive_data();
|
drain_excessive_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1414,7 +1413,10 @@ static universal_notifier_t::notifier_strategy_t fetch_default_strategy_from_env
|
||||||
const size_t opt_count = sizeof options / sizeof *options;
|
const size_t opt_count = sizeof options / sizeof *options;
|
||||||
|
|
||||||
const char *var = getenv(UNIVERSAL_NOTIFIER_ENV_NAME);
|
const char *var = getenv(UNIVERSAL_NOTIFIER_ENV_NAME);
|
||||||
if (var != NULL && var[0] != '\0') {
|
if (var == NULL || var[0] == '\0') {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < opt_count; i++) {
|
for (i = 0; i < opt_count; i++) {
|
||||||
if (!strcmp(var, options[i].name)) {
|
if (!strcmp(var, options[i].name)) {
|
||||||
|
@ -1431,7 +1433,6 @@ static universal_notifier_t::notifier_strategy_t fetch_default_strategy_from_env
|
||||||
}
|
}
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue