cper_bits_to_str(9)
π cper_bits_to_str(9) π
okay so bestie, welcome to the Kernel API Manual β this is cper_bits_to_str, and it literally does exactly what it says on the tin: it returns a string for set bits. no cap. π
β¨ NAME β¨
cper_bits_to_str β return a string for set bits π¦
πΈ SYNOPSIS πΈ
int cper_bits_to_str (char *buf , int buf_size , unsigned long bits ,
const char * const strs[] , unsigned int strs_size );
π ARGUMENTS π
bufβ the buffer where the output string goes, bestie. that's its whole job. π«Άbuf_sizeβ size of the output string buffer, so like, don't overflow it, iykyk πbitsβ the bit mask. the star of the show. πstrsβ a string array, indexed by bit position β so like slot 0 is bit 0's vibe, slot 1 is bit 1's vibe, you get it. β¨strs_sizeβ size of the string array, akastrs. yes, it needs its own size. it's that girl. π
π DESCRIPTION π
so here's the tea β: it adds the bitmask to buf in hexadecimal first. then, for each set bit in bits, it adds the corresponding string describing the bit in strs to buf. literally just appending the names of the bits that are turned on. ate. π₯
a typical example is giving:
const char * const bits[] = {
"bit 3 name",
"bit 4 name",
"bit 5 name",
};
char str[120];
unsigned int bitmask = BIT(3) | BIT(5);
#define MASK GENMASK(5,3)
cper_bits_to_str(str, sizeof(str), FIELD_GET(MASK, bitmask),
bits, ARRAY_SIZE(bits));
and the above code fills the string str with bit 3 name|bit 5 name. iconic. notice how bit 4 didn't make the cut β it wasn't set, so it gets no invite to the function. π
β RETURN β
number of bytes stored β or an error code if it's lower than zero. so like, check your return values, queen. π
π SEE ALSO π
- Kernel file
./drivers/firmware/efi/cper.c cper_print_bits(9)
k that's the whole page, ily, go read the source if you want more π§
this has been ./drivers/firmware/efi, October 2026, cper_bits_to_str(9) β mwah, bye bestie π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms