summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/i915/api_intel_bb.c2
-rw-r--r--tests/i915/gem_eio.c4
-rw-r--r--tests/i915/gem_exec_alignment.c4
-rw-r--r--tests/i915/gem_exec_capture.c2
-rw-r--r--tests/i915/gem_exec_fair.c2
-rw-r--r--tests/i915/gem_pxp.c4
-rw-r--r--tests/i915/gem_stress.c2
-rw-r--r--tests/i915/gem_tiled_swapping.c5
-rw-r--r--tests/i915/gem_userptr_blits.c2
-rw-r--r--tests/i915/i915_pm_rc6_residency.c2
-rw-r--r--tests/i915/kms_big_fb.c2
-rw-r--r--tests/i915/perf_pmu.c2
-rw-r--r--tests/kms_atomic_transition.c2
-rw-r--r--tests/kms_chamelium.c2
-rw-r--r--tests/kms_content_protection.c4
-rw-r--r--tests/kms_invalid_mode.c4
-rw-r--r--tests/kms_multipipe_modeset.c3
-rw-r--r--tests/kms_rotation_crc.c21
-rw-r--r--tests/kms_setmode.c11
-rw-r--r--tests/sw_sync.c5
20 files changed, 43 insertions, 42 deletions
diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
index 293720b4b..82943a341 100644
--- a/tests/i915/api_intel_bb.c
+++ b/tests/i915/api_intel_bb.c
@@ -904,7 +904,7 @@ static int compare_bufs(struct intel_buf *buf1, struct intel_buf *buf2,
return ret;
}
-#define LINELEN 76
+#define LINELEN 76ul
static int dump_base64(const char *name, struct intel_buf *buf)
{
void *ptr;
diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
index d9ff1981a..3d094433b 100644
--- a/tests/i915/gem_eio.c
+++ b/tests/i915/gem_eio.c
@@ -489,7 +489,7 @@ static void test_inflight(int fd, unsigned int wait)
max = gem_measure_ring_inflight(fd, -1, 0);
igt_require(max > 1);
- max = min(max - 1, ARRAY_SIZE(fence));
+ max = min_t(max, max - 1, ARRAY_SIZE(fence));
igt_debug("Using %d inflight batches\n", max);
for_each_ring(e, parent_fd) {
@@ -558,7 +558,7 @@ static void test_inflight_suspend(int fd)
max = gem_measure_ring_inflight(fd, -1, 0);
igt_require(max > 1);
- max = min(max - 1, ARRAY_SIZE(fence));
+ max = min_t(max, max - 1, ARRAY_SIZE(fence));
igt_debug("Using %d inflight batches\n", max);
fd = reopen_device(fd);
diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
index c4611bd1e..68b95c869 100644
--- a/tests/i915/gem_exec_alignment.c
+++ b/tests/i915/gem_exec_alignment.c
@@ -166,7 +166,7 @@ naughty_child(int i915, int link, uint32_t shared, unsigned int flags)
if (!gem_uses_full_ppgtt(i915))
gtt_size /= 2; /* We have to *share* our GTT! */
- ram_size = min(intel_get_total_ram_mb(), 4096);
+ ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
ram_size *= 1024 * 1024;
count = min(gtt_size, ram_size) / 16384;
@@ -376,7 +376,7 @@ setup_many(int i915, unsigned long *out)
if (!gem_uses_full_ppgtt(i915))
gtt_size /= 2; /* We have to *share* our GTT! */
- ram_size = min(intel_get_total_ram_mb(), 4096);
+ ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
ram_size *= 1024 * 1024;
count = min(gtt_size, ram_size) / 16384;
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 19f3836e3..7e0a8b8ad 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -566,7 +566,7 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
gtt, ram);
count = min(gtt, ram) / 4;
- count = min(count, 256); /* Keep the duration within reason */
+ count = min(count, 256ul); /* Keep the duration within reason */
igt_require(count > 1);
intel_require_memory(count, size, CHECK_RAM);
diff --git a/tests/i915/gem_exec_fair.c b/tests/i915/gem_exec_fair.c
index ef5a450f6..89945d40e 100644
--- a/tests/i915/gem_exec_fair.c
+++ b/tests/i915/gem_exec_fair.c
@@ -605,7 +605,7 @@ static void fair_child(int i915, const intel_ctx_t *ctx,
map = gem_mmap__device_coherent(i915, obj[0].handle,
0, 4096, PROT_WRITE);
igt_assert(map[0]);
- for (n = 1; n < min(count, 512); n++) {
+ for (n = 1; n < min(count, 512ul); n++) {
igt_assert(map[n]);
map[n - 1] = map[n] - map[n - 1];
}
diff --git a/tests/i915/gem_pxp.c b/tests/i915/gem_pxp.c
index 0430f4b8f..5f269bab9 100644
--- a/tests/i915/gem_pxp.c
+++ b/tests/i915/gem_pxp.c
@@ -1082,8 +1082,8 @@ static void test_display_protected_crc(int i915, igt_display_t *display)
for_each_connected_output(display, output) {
mode = igt_output_get_mode(output);
- width = max(width, mode->hdisplay);
- height = max(height, mode->vdisplay);
+ width = max_t(int, width, mode->hdisplay);
+ height = max_t(int, height, mode->vdisplay);
}
igt_create_color_fb(i915, width, height, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
diff --git a/tests/i915/gem_stress.c b/tests/i915/gem_stress.c
index 3e4d49076..3765ab14b 100644
--- a/tests/i915/gem_stress.c
+++ b/tests/i915/gem_stress.c
@@ -769,7 +769,7 @@ static void init(void)
if (options.num_buffers == 0) {
tmp = gem_aperture_size(drm_fd);
- tmp = min(256 * (1024 * 1024), tmp);
+ tmp = min(256 * 1024 * 1024u, tmp);
num_buffers = 2 * tmp / options.scratch_buf_size / 3;
num_buffers /= 2;
igt_info("using %u buffers\n", num_buffers);
diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
index d33b76dbd..d66b6ca7f 100644
--- a/tests/i915/gem_tiled_swapping.c
+++ b/tests/i915/gem_tiled_swapping.c
@@ -67,7 +67,7 @@ IGT_TEST_DESCRIPTION("Exercise swizzle code for swapping.");
static uint32_t current_tiling_mode;
#define PAGE_SIZE 4096
-#define AVAIL_RAM 512
+#define AVAIL_RAM 512ul
static uint32_t
create_bo(int fd)
@@ -183,7 +183,8 @@ igt_main
/* lock RAM, leaving only 512MB available */
count = intel_get_total_ram_mb() - intel_get_avail_ram_mb();
count = max(count + 64, AVAIL_RAM);
- lock_size = max(0, intel_get_total_ram_mb() - count);
+ count = intel_get_total_ram_mb() - count;
+ lock_size = max_t(long, 0, count);
igt_info("Mlocking %zdMiB of %ld/%ldMiB\n",
lock_size,
(long)intel_get_avail_ram_mb(),
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 0d0846742..93e4b25b7 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -1693,7 +1693,7 @@ static void test_forking_evictions(int fd, int size, int count,
* processes meaning swapping will be triggered system
* wide even if one process on it's own can't do it.
*/
- num_threads = min(sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
+ num_threads = min_t(int, sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
trash_count /= num_threads;
if (count > trash_count)
count = trash_count;
diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
index 96a951406..cf9eae902 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -345,7 +345,7 @@ static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
ctl[1]++;
/* aim for ~1% busy */
- usleep(min(elapsed / 10, 50 * 1000));
+ usleep(min_t(elapsed, elapsed / 10, 50 * 1000));
} while (!READ_ONCE(*ctl));
}
diff --git a/tests/i915/kms_big_fb.c b/tests/i915/kms_big_fb.c
index 308227c91..866590382 100644
--- a/tests/i915/kms_big_fb.c
+++ b/tests/i915/kms_big_fb.c
@@ -400,9 +400,9 @@ static bool test_plane(data_t *data)
static bool test_pipe(data_t *data)
{
+ uint16_t width, height;
drmModeModeInfo *mode;
igt_plane_t *primary;
- int width, height;
bool ret = false;
if (data->format == DRM_FORMAT_C8 &&
diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
index 1214cda8c..e9df0290d 100644
--- a/tests/i915/perf_pmu.c
+++ b/tests/i915/perf_pmu.c
@@ -1413,7 +1413,7 @@ static int target_num_interrupts(int i915)
{
const intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(i915);
- return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30);
+ return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30u);
}
static void
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index bc0a1c81b..9c0a91bf2 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -789,7 +789,7 @@ static void run_modeset_tests(data_t *data, int howmany, bool nonblocking, bool
unsigned iter_max;
igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
igt_output_t *output;
- unsigned width = 0, height = 0;
+ uint16_t width = 0, height = 0;
for (i = 0; i < data->display.n_outputs; i++)
igt_output_set_pipe(&data->display.outputs[i], PIPE_NONE);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 1ab411cec..11926bbcf 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -2399,7 +2399,7 @@ static void test_display_planes_random(data_t *data,
igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
/* Limit the number of planes to a reasonable scene. */
- overlay_planes_max = min(overlay_planes_max, 4);
+ overlay_planes_max = min(overlay_planes_max, 4u);
overlay_planes_count = (rand() % overlay_planes_max) + 1;
igt_debug("Using %d overlay planes\n", overlay_planes_count);
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index e8002df27..f2047173a 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -703,9 +703,9 @@ static void test_content_protection_cleanup(void)
static void create_fbs(void)
{
- igt_output_t *output;
- int width = 0, height = 0;
+ uint16_t width = 0, height = 0;
drmModeModeInfo *mode;
+ igt_output_t *output;
for_each_connected_output(&data.display, output) {
mode = igt_output_get_mode(output);
diff --git a/tests/kms_invalid_mode.c b/tests/kms_invalid_mode.c
index d4feba327..11960dfd7 100644
--- a/tests/kms_invalid_mode.c
+++ b/tests/kms_invalid_mode.c
@@ -195,8 +195,8 @@ test_output(data_t *data)
return 0;
igt_create_fb(data->drm_fd,
- max(mode.hdisplay, 64),
- max(mode.vdisplay, 64),
+ max_t(uint16_t, mode.hdisplay, 64),
+ max_t(uint16_t, mode.vdisplay, 64),
DRM_FORMAT_XRGB8888,
DRM_FORMAT_MOD_NONE,
&fb);
diff --git a/tests/kms_multipipe_modeset.c b/tests/kms_multipipe_modeset.c
index b1dbc73a3..97499508f 100644
--- a/tests/kms_multipipe_modeset.c
+++ b/tests/kms_multipipe_modeset.c
@@ -40,10 +40,11 @@ static void run_test(data_t *data, int valid_outputs)
igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
igt_crc_t ref_crcs[IGT_MAX_PIPES], new_crcs[IGT_MAX_PIPES];
igt_display_t *display = &data->display;
- int width = 0, height = 0, i = 0;
+ uint16_t width = 0, height = 0;
igt_pipe_t *pipe;
igt_plane_t *plane;
drmModeModeInfo *mode;
+ int i = 0;
for_each_connected_output(display, output) {
mode = igt_output_get_mode(output);
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 11401a6d0..a7f4d22f9 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -214,6 +214,11 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
igt_pipe_crc_start(data->pipe_crc);
}
+#define TEST_WIDTH(km) \
+ min_t((km)->hdisplay, (km)->hdisplay, TEST_MAX_WIDTH)
+#define TEST_HEIGHT(km) \
+ min_t((km)->vdisplay, (km)->vdisplay, TEST_MAX_HEIGHT)
+
static void prepare_fbs(data_t *data, igt_output_t *output,
igt_plane_t *plane, enum rectangle_type rect, uint32_t format)
{
@@ -234,8 +239,8 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
w = mode->hdisplay;
h = mode->vdisplay;
} else {
- w = min(TEST_MAX_WIDTH, mode->hdisplay);
- h = min(TEST_MAX_HEIGHT, mode->vdisplay);
+ w = TEST_WIDTH(mode);
+ h = TEST_HEIGHT(mode);
}
min_w = 256;
@@ -614,7 +619,7 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
int c)
{
if (data->planepos[c].origo & p_right) {
- p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay)
+ p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode)
+ mode->hdisplay);
p[c].x1 &= ~3;
/*
@@ -625,17 +630,17 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
*/
p[c].x1 -= mode->hdisplay & 2;
} else {
- p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay));
+ p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode));
p[c].x1 &= ~3;
}
if (data->planepos[c].origo & p_bottom) {
- p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay)
+ p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode)
+ mode->vdisplay);
p[c].y1 &= ~3;
p[c].y1 -= mode->vdisplay & 2;
} else {
- p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay));
+ p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode));
p[c].y1 &= ~3;
}
}
@@ -698,8 +703,8 @@ static void test_multi_plane_rotation(data_t *data, enum pipe pipe)
igt_display_require_output(display);
igt_display_commit2(display, COMMIT_ATOMIC);
- used_w = min(TEST_MAX_WIDTH, mode->hdisplay);
- used_h = min(TEST_MAX_HEIGHT, mode->vdisplay);
+ used_w = TEST_WIDTH(mode);
+ used_h = TEST_HEIGHT(mode);
p[0].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
p[1].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 80665204c..d62251742 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -421,15 +421,8 @@ static int test_stealing(int fd, struct crtc_config *crtc, uint32_t *ids)
return ret;
}
-static double frame_time(const drmModeModeInfo *kmode)
-{
- return 1000.0 * kmode->htotal * kmode->vtotal / kmode->clock;
-}
-
-static double line_time(const drmModeModeInfo *kmode)
-{
- return 1000.0 * kmode->htotal / kmode->clock;
-}
+#define frame_time(km) (1000.0 * (km)->htotal * (km)->vtotal / (km)->clock)
+#define line_time(km) (1000.0 * (km)->htotal / (km)->clock)
static void check_timings(int crtc_idx, const drmModeModeInfo *kmode)
{
diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index d3d2bec15..cbd773fcb 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -837,8 +837,9 @@ igt_main
igt_fixture {
igt_require_sw_sync();
multi_consumer_threads =
- min(multi_consumer_threads,
- sysconf(_SC_NPROCESSORS_ONLN));
+ min_t(multi_consumer_threads,
+ multi_consumer_threads,
+ sysconf(_SC_NPROCESSORS_ONLN));
}
igt_subtest("alloc_timeline")