tree-wide: add FORMAT_TIMESPAN()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-07-09 11:03:36 +02:00
parent 5e62ac8b51
commit 5291f26d4a
60 changed files with 203 additions and 378 deletions
+2 -5
View File
@@ -120,13 +120,10 @@ int efi_get_variable(
n = st.st_size - 4;
if (DEBUG_LOGGING) {
char ts[FORMAT_TIMESPAN_MAX];
usec_t end;
end = now(CLOCK_MONOTONIC);
usec_t end = now(CLOCK_MONOTONIC);
if (end > begin + EFI_RETRY_DELAY)
log_debug("Detected slow EFI variable read access on %s: %s",
variable, format_timespan(ts, sizeof(ts), end - begin, 1));
variable, FORMAT_TIMESPAN(end - begin, 1));
}
/* Note that efivarfs interestingly doesn't require ftruncate() to update an existing EFI variable
+1
View File
@@ -129,6 +129,7 @@ static inline char* format_timestamp(char *buf, size_t l, usec_t t) {
* see C11 §6.5.2.5, and
* https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */
#define FORMAT_TIMESTAMP(t) format_timestamp((char[FORMAT_TIMESTAMP_MAX]){}, FORMAT_TIMESTAMP_MAX, t)
#define FORMAT_TIMESPAN(t, accuracy) format_timespan((char[FORMAT_TIMESPAN_MAX]){}, FORMAT_TIMESPAN_MAX, t, accuracy)
int parse_timestamp(const char *t, usec_t *usec);