cper_bits_to_str(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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, aka strs. 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 🌈


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