PMERRSTR(3)

πŸ“¦
version 7.2.2 Β· 3 versions
, in arch rolling, centos-stream 10, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– PMERRSTR(3) β€” Library Functions Manual πŸ’–

okay bestie, sit down, because today we're talking about turning cursed little negative numbers into actual human-readable sentences. this is pmErrStr and pmErrStr_r, living their best lives in the PCP crew ✨


🌸 NAME 🌸

pmErrStr, pmErrStr_r β€” the girlies that convert a PMAPI error code into a string πŸ’…


πŸŽ€ C SYNOPSIS πŸŽ€

#include <pcp/pmapi.h>

const char *pmErrStr(int code);
char *pmErrStr_r(int code, char *buf, int buflen);

cc ... -lpcp

πŸ¦‹ DESCRIPTION πŸ¦‹

So what do these two actually do? They translate an error code into a text string, which is literally the whole point β€” you want something suitable for generating a diagnostic message, not just a sad lonely integer staring back at you 😭

The pmErrStr_r function does the exact same thing, but it's the responsible one: it stores the result in a user-supplied buffer buf of length buflen. And bestie, that buffer should have room for at least PM_MAXERRMSGLEN bytes β€” no skimping, she needs her space 🫢

By convention, all error codes are negative. That's just the rule, no cap.

The small values are assumed to be negated versions of the Unix error codes as defined in <errno.h>, and the strings returned are as per strerror(3). Cute, classic, vintage πŸ’–

The larger, negative error codes are Performance Metrics Application Programming Interface (PMAPI) error conditions, and pmErrStr(3) returns an appropriate PMAPI error string, as determined by code. So like… the number tells her which vibe to serve, and she serves it 🌈


⭐ NOTES ⭐

Listen up, this part is important!! 🚨

pmErrStr returns a pointer to a static buffer, so the returned value is only valid until the next call to pmErrStr β€” and hence it is not thread-safe. She's a one-at-a-time kind of girl, and she will absolutely get overwritten on you if you're not paying attention πŸ’€

Multi-threaded applications should use pmErrStr_r instead. Periodt. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯


mwah πŸ’‹ that's the whole page, you ate it, you understood it, main character energy fr fr.

This cutie is brought to you by the Performance Co-Pilot girlies β€” that's the PCP release, from the <pink>Performance Co-Pilot</pink> source, page PMERRSTR(3). ily, go read pmerr(1) next πŸŽ€βœ¨

πŸ“¦ where this page comes from