summaryrefslogtreecommitdiff
path: root/libbcachefs/bkey.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-12-28 20:20:17 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2019-12-28 20:31:39 -0500
commitf0d907189f1545333efe9b101fc4ce4c07421c8a (patch)
tree1aa658bcc2a7ffa9de96c430627d627deb0e0f82 /libbcachefs/bkey.c
parentff2b85e039b2dc164477c1ac57844a6f456526aa (diff)
Update bcachefs sources to 86a99a7b7f bcachefs: Convert some enums to x-macros
Diffstat (limited to 'libbcachefs/bkey.c')
-rw-r--r--libbcachefs/bkey.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libbcachefs/bkey.c b/libbcachefs/bkey.c
index 4d0c9129..494126ae 100644
--- a/libbcachefs/bkey.c
+++ b/libbcachefs/bkey.c
@@ -173,8 +173,7 @@ static bool set_inc_field(struct pack_state *state, unsigned field, u64 v)
if (bits > state->bits) {
bits -= state->bits;
- /* avoid shift by 64 if bits is 0 - bits is never 64 here: */
- state->w |= (v >> 1) >> (bits - 1);
+ state->w |= v >> bits;
*state->p = state->w;
state->p = next_word(state->p);
@@ -183,7 +182,10 @@ static bool set_inc_field(struct pack_state *state, unsigned field, u64 v)
}
state->bits -= bits;
- state->w |= v << state->bits;
+
+ EBUG_ON(!state->bits);
+ /* avoid shift by 64: */
+ state->w |= (v << 1) << (state->bits - 1);
return true;
}
@@ -370,7 +372,7 @@ static bool set_inc_field_lossy(struct pack_state *state, unsigned field, u64 v)
if (bits > state->bits) {
bits -= state->bits;
- state->w |= (v >> 1) >> (bits - 1);
+ state->w |= v >> bits;
*state->p = state->w;
state->p = next_word(state->p);
@@ -379,7 +381,7 @@ static bool set_inc_field_lossy(struct pack_state *state, unsigned field, u64 v)
}
state->bits -= bits;
- state->w |= v << state->bits;
+ state->w |= (v << 1) << (state->bits - 1);
return ret;
}