bool __bch2_snapshot_is_ancestor(struct bch_fs *c, u32 id, u32 ancestor)
 {
-       bool ret;
+#ifdef CONFIG_BCACHEFS_DEBUG
+       u32 orig_id = id;
+#endif
 
        guard(rcu)();
        struct snapshot_table *t = rcu_dereference(c->snapshots);
                while (id && id < ancestor - IS_ANCESTOR_BITMAP)
                        id = get_ancestor_below(t, id, ancestor);
 
-       ret = id && id < ancestor
+       bool ret = id && id < ancestor
                ? test_ancestor_bitmap(t, id, ancestor)
                : id == ancestor;
 
-       EBUG_ON(ret != __bch2_snapshot_is_ancestor_early(t, id, ancestor));
+       EBUG_ON(ret != __bch2_snapshot_is_ancestor_early(t, orig_id, ancestor));
        return ret;
 }