Skip to content

Commit 6b74fdc

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_checksum() returns 0 for unknown checksum type
This fixes missing guards on trying to calculate a checksum with an invalid/unknown checksum type; moving the guards up to e.g. btree_io.c might be "more correct", but doesn't buy us anything - an unknown checksum type will always be flagged as at least a checksum error so we aren't losing any safety doing it this way and it makes it less likely to accidentally pop an assert we don't want. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent c06a8b7 commit 6b74fdc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/bcachefs/checksum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ struct bch_csum bch2_checksum(struct bch_fs *c, unsigned type,
233233
return ret;
234234
}
235235
default:
236-
BUG();
236+
return (struct bch_csum) {};
237237
}
238238
}
239239

@@ -307,7 +307,7 @@ static struct bch_csum __bch2_checksum_bio(struct bch_fs *c, unsigned type,
307307
return ret;
308308
}
309309
default:
310-
BUG();
310+
return (struct bch_csum) {};
311311
}
312312
}
313313

0 commit comments

Comments
 (0)