Skip to content

Commit dc43f6a

Browse files
author
Kent Overstreet
committed
bcachefs: Mark bch_errcode helpers __attribute__((const))
These don't access global memory or defer pointer arguments - this enables CSE optimizations. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 66621f0 commit dc43f6a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

fs/bcachefs/errcode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ static const char * const bch2_errcode_strs[] = {
1313
NULL
1414
};
1515

16-
static unsigned bch2_errcode_parents[] = {
16+
static const unsigned bch2_errcode_parents[] = {
1717
#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = class,
1818
BCH_ERRCODES()
1919
#undef x
2020
};
2121

22+
__attribute__((const))
2223
const char *bch2_err_str(int err)
2324
{
2425
const char *errstr;
@@ -36,6 +37,7 @@ const char *bch2_err_str(int err)
3637
return errstr ?: "(Invalid error)";
3738
}
3839

40+
__attribute__((const))
3941
bool __bch2_err_matches(int err, int class)
4042
{
4143
err = abs(err);

fs/bcachefs/errcode.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,11 @@ enum bch_errcode {
357357
BCH_ERR_MAX
358358
};
359359

360-
const char *bch2_err_str(int);
361-
bool __bch2_err_matches(int, int);
360+
__attribute__((const)) const char *bch2_err_str(int);
362361

362+
__attribute__((const)) bool __bch2_err_matches(int, int);
363+
364+
__attribute__((const))
363365
static inline bool _bch2_err_matches(int err, int class)
364366
{
365367
return err < 0 && __bch2_err_matches(err, class);

0 commit comments

Comments
 (0)