]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bkey.h
Update bcachefs sources to 6a20aede29 bcachefs: Fix quotas + snapshots
[bcachefs-tools-debian] / libbcachefs / bkey.h
index 2650bd639b55998c9b6a31f6ce2312520d687a22..727bed99554bde5336665569ecde728388f6b199 100644 (file)
@@ -611,20 +611,20 @@ struct bkey_s_##name {                                                    \
                                                                        \
 static inline struct bkey_i_##name *bkey_i_to_##name(struct bkey_i *k) \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return container_of(&k->k, struct bkey_i_##name, k);            \
 }                                                                      \
                                                                        \
 static inline const struct bkey_i_##name *                             \
 bkey_i_to_##name##_c(const struct bkey_i *k)                           \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return container_of(&k->k, struct bkey_i_##name, k);            \
 }                                                                      \
                                                                        \
 static inline struct bkey_s_##name bkey_s_to_##name(struct bkey_s k)   \
 {                                                                      \
-       EBUG_ON(k.k->type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k.k) && k.k->type != KEY_TYPE_##name);  \
        return (struct bkey_s_##name) {                                 \
                .k = k.k,                                               \
                .v = container_of(k.v, struct bch_##name, v),           \
@@ -633,7 +633,7 @@ static inline struct bkey_s_##name bkey_s_to_##name(struct bkey_s k)        \
                                                                        \
 static inline struct bkey_s_c_##name bkey_s_c_to_##name(struct bkey_s_c k)\
 {                                                                      \
-       EBUG_ON(k.k->type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k.k) && k.k->type != KEY_TYPE_##name);  \
        return (struct bkey_s_c_##name) {                               \
                .k = k.k,                                               \
                .v = container_of(k.v, struct bch_##name, v),           \
@@ -659,7 +659,7 @@ name##_i_to_s_c(const struct bkey_i_##name *k)                              \
                                                                        \
 static inline struct bkey_s_##name bkey_i_to_s_##name(struct bkey_i *k)        \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return (struct bkey_s_##name) {                                 \
                .k = &k->k,                                             \
                .v = container_of(&k->v, struct bch_##name, v),         \
@@ -669,7 +669,7 @@ static inline struct bkey_s_##name bkey_i_to_s_##name(struct bkey_i *k)     \
 static inline struct bkey_s_c_##name                                   \
 bkey_i_to_s_c_##name(const struct bkey_i *k)                           \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return (struct bkey_s_c_##name) {                               \
                .k = &k->k,                                             \
                .v = container_of(&k->v, struct bch_##name, v),         \