explain_adjtime(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– explain_adjtime(3) β€” the vibe guide πŸ’–

okay bestie, sit down, hydrate, and let me tell you about explain_adjtime β€” it's the Library Functions Manual entry that decodes your adjtime(2) errors so you actually know what went wrong instead of just staring at -1 like πŸ‘οΈπŸ‘„πŸ‘οΈ. no cap.


✨ NAME ✨

explain_adjtime β€” explain adjtime(2) errors. that's it. that's the whole job. and it does it flawlessly. πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/adjtime.h>
const char *explain_adjtime(const struct timeval *delta, struct timeval
*olddelta);
const char *explain_errno_adjtime(int errnum, const struct timeval
*delta, struct timeval *olddelta);
void explain_message_adjtime(char *message, int message_size, const
struct timeval *delta, struct timeval *olddelta);
void explain_message_errno_adjtime(char *message, int message_size, int
errnum, const struct timeval *delta, struct timeval *olddelta);

four functions. four little icons. all of them here to hold your hand through an error. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

These functions may be used to obtain explanations for errors returned by the adjtime(2) system call. basically: the syscall goes wrong, you call one of these, and you get actual words instead of cryptic nothingness. it's giving ✨customer service✨ but for your C code.


πŸ’œ explain_adjtime

const char *explain_adjtime(const struct timeval *delta, struct timeval
*olddelta);

The explain_adjtime function is used to obtain an explanation of an error returned by the adjtime(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. it over-delivers. we love that for it. πŸ‘‘

The errno global variable will be used to obtain the error value to be decoded. so like, it reads errno for you, no extra steps.

  • delta β€” the original delta, exactly as passed to the adjtime(2) system call. not a copy, not a remix, the exact same one. πŸ’―
  • olddelta β€” the original olddelta, exactly as passed to the adjtime(2) system call. same energy. ✨

Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.

Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. so if you're threading, bestie, be careful. this buffer gets recycled FAST. 😭

Example: This function is intended to be used in a fashion similar to the following example:

if (adjtime(delta, olddelta) < 0)
{
    fprintf(stderr, "%s\n", explain_adjtime(delta, olddelta));
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_adjtime_or_die(3) function. iykyk β€” it does the printing AND the dying for you. iconic.


πŸŽ€ explain_errno_adjtime

const char *explain_errno_adjtime(int errnum, const struct timeval
*delta, struct timeval *olddelta);

The explain_errno_adjtime function is used to obtain an explanation of an error returned by the adjtime(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail.

  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. 🚨 translation: errno is feral and other libc calls will stomp on it, so you gotta grab it first and hand it over yourself.
  • delta β€” the original delta, exactly as passed to the adjtime(2) system call.
  • olddelta β€” the original olddelta, exactly as passed to the adjtime(2) system call.

Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.

Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library.

Example: This function is intended to be used in a fashion similar to the following example:

if (adjtime(delta, olddelta) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_adjtime(err, delta, olddelta));
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_adjtime_or_die(3) function.


🌈 explain_message_adjtime

void explain_message_adjtime(char *message, int message_size, const
struct timeval *delta, struct timeval *olddelta);

The explain_message_adjtime function is used to obtain an explanation of an error returned by the adjtime(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail.

The errno global variable will be used to obtain the error value to be decoded.

  • message β€” the location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. πŸŽ‰ you bring the buffer, you get the safety. that's the deal.
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • delta β€” the original delta, exactly as passed to the adjtime(2) system call.
  • olddelta β€” the original olddelta, exactly as passed to the adjtime(2) system call.

Example: This function is intended to be used in a fashion similar to the following example:

if (adjtime(delta, olddelta) < 0)
{
    char message[3000];
    explain_message_adjtime(message, sizeof(message), delta, olddelta);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_adjtime_or_die(3) function.


🧚 explain_message_errno_adjtime

void explain_message_errno_adjtime(char *message, int message_size, int
errnum, const struct timeval *delta, struct timeval *olddelta);

The explain_message_errno_adjtime function is used to obtain an explanation of an error returned by the adjtime(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail.

  • message β€” the location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. πŸ’–
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. 🚨 (yes, again. errno really is like that.)
  • delta β€” the original delta, exactly as passed to the adjtime(2) system call.
  • olddelta β€” the original olddelta, exactly as passed to the adjtime(2) system call.

Example: This function is intended to be used in a fashion similar to the following example:

if (adjtime(delta, olddelta) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_adjtime(message, sizeof(message), err, delta, olddelta);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_adjtime_or_die(3) function.


πŸ‘‘ SEE ALSO πŸ‘‘


libexplain version 1.4 Copyright (C) 2009 Peter Miller


and that's the whole page, bestie!! πŸŽ€ you made it to the end, so proud of you fr fr. this was explain_adjtime(3) from the Library Functions Manual, brought to you by libexplain version 1.4, with copyright held by Peter Miller, 2009. go forth and decode those errors, you absolute legend. πŸ’…βœ¨πŸ¦‹πŸŒΈπŸ’–

πŸ“¦ where this page comes from