libsysprof-analyze: fix various swap calculations

This commit is contained in:
Christian Hergert
2023-07-10 12:10:49 -07:00
parent af0470a381
commit c0b46530a4

View File

@ -135,11 +135,11 @@ swap_int32 (gboolean needs_swap,
#endif #endif
} }
static inline int static inline gint64
swap_int64 (gboolean needs_swap, swap_int64 (gboolean needs_swap,
gint64 value) gint64 value)
{ {
if (!needs_swap) if G_LIKELY (!needs_swap)
return value; return value;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
@ -1150,7 +1150,7 @@ sysprof_document_load_worker (GTask *task,
{ {
const SysprofCaptureMark *mark = (const SysprofCaptureMark *)tainted; const SysprofCaptureMark *mark = (const SysprofCaptureMark *)tainted;
const char *endptr = (const char *)tainted + ptr->length; const char *endptr = (const char *)tainted + ptr->length;
gint64 duration = self->needs_swap ? GUINT64_SWAP_LE_BE (mark->duration) : mark->duration; gint64 duration = swap_int64 (self->needs_swap, mark->duration);
if (t + duration > guessed_end_nsec) if (t + duration > guessed_end_nsec)
guessed_end_nsec = t + duration; guessed_end_nsec = t + duration;