Page MenuHomeClusterLabs Projects

Consider casting time_t values to intmax_t for display
Open, WishlistPublic

Assigned To
None
Authored By
nrwahl2
Wed, Jan 8, 5:10 PM
Tags
  • Restricted Project
  • Restricted Project
  • Restricted Project
Referenced Files
None
Subscribers

Description

This should be pretty easy but there's no real payoff and no likely risk of keeping the current behavior. So save it for if we need a break and want to work on something silly.

As of commit 18a93372, we can use the 'j' printf() modifier for (u)intmax_t. That commit is how I learned that intmax_t exists, and to be honest I was just trying to think of a use case. intmax_t refers to the largest signed integer type supported by the implementation.

Currently, we cast time_t values to long long for the printf() family of functions. The C standard allows time_t to be any numeric type; the POSIX standard allows time_t to be any integer type; and glibc allows time_t to be any signed integer type. Note that FreeBSD doesn't use glibc, but for our purposes it shouldn't matter if we assume it's signed. Even if it is signed, technically it could be bigger than long long.

We could also have a pcmk__xml_add_time_t() equivalent of crm_xml_add_ll() for convenience, to do the casting.

Note: Someone (linked below) is especially passionate that intmax_t is no good. I have barely skimmed this article.
https://thephd.dev/intmax_t-hell-c++-c


Similarly:

  • uintmax_t for rlim_t (currently in remove_core_file_limit())
  • intmax_t for pid_t
  • intmax_t for uid_t and gid_t (these may be either signed or unsigned integer types, and determining which one isn't worth the autoconf trouble)

Event Timeline

nrwahl2 triaged this task as Wishlist priority.Wed, Jan 8, 5:10 PM
nrwahl2 created this task.
nrwahl2 created this object with edit policy "Restricted Project (Project)".
nrwahl2 updated the task description. (Show Details)