Merge pull request #25726 from dtardon/cleanups

Several small cleanups
This commit is contained in:
Yu Watanabe
2022-12-14 20:17:56 +09:00
committed by GitHub
9 changed files with 44 additions and 72 deletions
+1 -3
View File
@@ -37,7 +37,6 @@ int name_to_handle_at_loop(
int *ret_mnt_id,
int flags) {
_cleanup_free_ struct file_handle *h = NULL;
size_t n = ORIGINAL_MAX_HANDLE_SZ;
assert((flags & ~(AT_SYMLINK_FOLLOW|AT_EMPTY_PATH)) == 0);
@@ -50,6 +49,7 @@ int name_to_handle_at_loop(
* as NULL if there's no interest in either. */
for (;;) {
_cleanup_free_ struct file_handle *h = NULL;
int mnt_id = -1;
h = malloc0(offsetof(struct file_handle, f_handle) + n);
@@ -91,8 +91,6 @@ int name_to_handle_at_loop(
n = h->handle_bytes;
if (offsetof(struct file_handle, f_handle) + n < n) /* check for addition overflow */
return -EOVERFLOW;
h = mfree(h);
}
}
+5 -10
View File
@@ -10,6 +10,7 @@
bool ratelimit_below(RateLimit *r) {
usec_t ts;
bool good = false;
assert(r);
@@ -24,18 +25,12 @@ bool ratelimit_below(RateLimit *r) {
/* Reset counter */
r->num = 0;
goto good;
}
if (r->num < r->burst)
goto good;
good = true;
} else if (r->num < r->burst)
good = true;
r->num++;
return false;
good:
r->num++;
return true;
return good;
}
unsigned ratelimit_num_dropped(RateLimit *r) {