diff options
author | Alejandro Colomar <alx@kernel.org> | 2023-05-27 15:56:08 +0200 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2023-05-31 21:45:36 +0200 |
commit | ec42bbe7a3d2811c40bd1c7d6016e918360251d8 (patch) | |
tree | 5da6016153bddba9359a3da24077bb03f78f7c0a | |
parent | 73508eac2c99c77c431cd2d889045f839fa57242 (diff) |
Use temporary variable
- Use the temporary variable more, as it helps readability: it removes
a derefecence, which itself allows removing some parentheses.
- Use a shorter name, which is more common with temporaries, and so
there's less to read.
- Assign to *ranges at the end of the function. It's the same, but
with the other changes, I think this makes it slightly clearer.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | lib/subordinateio.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 52d0e33d..4139674f 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -315,15 +315,16 @@ static bool have_range(struct commonio_db *db, static bool append_range(struct subid_range **ranges, const struct subordinate_range *new, int n) { - struct subid_range *alloced; + struct subid_range *sr; - alloced = REALLOC(*ranges, n + 1, struct subid_range); - if (!alloced) + sr = REALLOC(*ranges, n + 1, struct subid_range); + if (!sr) return false; - *ranges = alloced; - (*ranges)[n].start = new->start; - (*ranges)[n].count = new->count; + sr[n].start = new->start; + sr[n].count = new->count; + *ranges = sr; + return true; } |