[sysprof: 44/63] libsysprof-capture: Open-code MAX and CLAMP macros
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof: 44/63] libsysprof-capture: Open-code MAX and CLAMP macros
- Date: Sat, 4 Jul 2020 18:33:02 +0000 (UTC)
commit b558e7b128ccaf9df3a4416f29724b4f72b707af
Author: Philip Withnall <withnall endlessm com>
Date: Thu Jul 2 13:04:30 2020 +0100
libsysprof-capture: Open-code MAX and CLAMP macros
The macros don’t seem to make things sufficiently much clearer that it
makes sense to provide them.
Signed-off-by: Philip Withnall <withnall endlessm com>
Helps: #40
src/libsysprof-capture/sysprof-capture-reader.c | 4 ++--
src/libsysprof-capture/sysprof-collector.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/libsysprof-capture/sysprof-capture-reader.c b/src/libsysprof-capture/sysprof-capture-reader.c
index 0cd80f9..12b3f87 100644
--- a/src/libsysprof-capture/sysprof-capture-reader.c
+++ b/src/libsysprof-capture/sysprof-capture-reader.c
@@ -165,7 +165,7 @@ sysprof_capture_reader_discover_end_time (SysprofCaptureReader *self)
const SysprofCaptureMark *mark = NULL;
if ((mark = sysprof_capture_reader_read_mark (self)))
- end_time = frame.time + MAX (0, mark->duration);
+ end_time = frame.time + ((mark->duration > 0) ? mark->duration : 0);
}
break;
@@ -1145,7 +1145,7 @@ sysprof_capture_reader_get_end_time (SysprofCaptureReader *self)
end_time = self->header.end_time;
}
- return MAX (self->end_time, end_time);
+ return (self->end_time > end_time) ? self->end_time : end_time;
}
/**
diff --git a/src/libsysprof-capture/sysprof-collector.c b/src/libsysprof-capture/sysprof-collector.c
index 0175073..49489c1 100644
--- a/src/libsysprof-capture/sysprof-collector.c
+++ b/src/libsysprof-capture/sysprof-collector.c
@@ -327,7 +327,7 @@ sysprof_collector_allocate (SysprofCaptureAddress alloc_addr,
else
n_addrs = 0;
- ev->n_addrs = CLAMP (n_addrs, 0, MAX_UNWIND_DEPTH);
+ ev->n_addrs = ((n_addrs < 0) ? 0 : (n_addrs > MAX_UNWIND_DEPTH) ? MAX_UNWIND_DEPTH : n_addrs);
ev->frame.len = sizeof *ev + sizeof (SysprofCaptureAddress) * ev->n_addrs;
ev->frame.type = SYSPROF_CAPTURE_FRAME_ALLOCATION;
ev->frame.cpu = _do_getcpu ();
@@ -364,7 +364,7 @@ sysprof_collector_sample (SysprofBacktraceFunc backtrace_func,
else
n_addrs = 0;
- ev->n_addrs = CLAMP (n_addrs, 0, MAX_UNWIND_DEPTH);
+ ev->n_addrs = ((n_addrs < 0) ? 0 : (n_addrs > MAX_UNWIND_DEPTH) ? MAX_UNWIND_DEPTH : n_addrs);
ev->frame.len = sizeof *ev + sizeof (SysprofCaptureAddress) * ev->n_addrs;
ev->frame.type = SYSPROF_CAPTURE_FRAME_SAMPLE;
ev->frame.cpu = _do_getcpu ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]