diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-25 22:28:34 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-28 11:41:03 -0400 |
commit | 99caca2c70f312c4a2504a7e7a9c92a91426d885 (patch) | |
tree | 6ac490ba2a93cf0c74f16b54323beea4d254826d /libbcachefs/errcode.c | |
parent | 7af94e14b5a9945c28a3c34e58b920e81c696a53 (diff) |
Update bcachefs sources to 24c6361e20 bcachefs: Fix a trans path overflow in bch2_btree_delete_range_trans()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/errcode.c')
-rw-r--r-- | libbcachefs/errcode.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libbcachefs/errcode.c b/libbcachefs/errcode.c index 9da8a597..cc9ce0be 100644 --- a/libbcachefs/errcode.c +++ b/libbcachefs/errcode.c @@ -15,7 +15,7 @@ static const char * const bch2_errcode_strs[] = { #define BCH_ERR_0 0 static unsigned bch2_errcode_parents[] = { -#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = BCH_ERR_##class, +#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = class, BCH_ERRCODES() #undef x }; @@ -49,3 +49,14 @@ bool __bch2_err_matches(int err, int class) return err == class; } + +int __bch2_err_class(int err) +{ + err = -err; + BUG_ON((unsigned) err >= BCH_ERR_MAX); + + while (err >= BCH_ERR_START && bch2_errcode_parents[err - BCH_ERR_START]) + err = bch2_errcode_parents[err - BCH_ERR_START]; + + return -err; +} |