Commit 8032f526 authored by Ville Syrjälä's avatar Ville Syrjälä

tests: Run lib/igt.cocci

Found some open coded min()/max()/swap() macros.
Signed-off-by: Ville Syrjälä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent e1bdab99
......@@ -33,6 +33,7 @@
#include "intel_chipset.h"
#include "drmtest.h"
#include "igt_aux.h"
#include "igt_debugfs.h"
#include "ioctl_wrappers.h"
......@@ -117,8 +118,7 @@ static void read_dfs(const char *fname, char *d, int maxlen)
static void _assert_dfs_entry(const char *fname, const char *s, bool inverse)
{
char tmp[1024];
const int l = strlen(s) < sizeof(tmp) ?
strlen(s) : sizeof(tmp);
const int l = min(strlen(s), sizeof(tmp));
read_dfs(fname, tmp, l + 1);
if (!inverse) {
......
......@@ -54,11 +54,8 @@ struct igt_eviction_test_ops
static void exchange_uint32_t(void *array, unsigned i, unsigned j)
{
uint32_t *i_arr = array;
uint32_t i_tmp;
i_tmp = i_arr[i];
i_arr[i] = i_arr[j];
i_arr[j] = i_tmp;
swap(i_arr[i], i_arr[j]);
}
static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
......
......@@ -171,11 +171,8 @@ static void render_copyfunc(struct igt_buf *src,
static void exchange_uint(void *array, unsigned i, unsigned j)
{
unsigned *i_arr = array;
unsigned i_tmp;
i_tmp = i_arr[i];
i_arr[i] = i_arr[j];
i_arr[j] = i_tmp;
swap(i_arr[i], i_arr[j]);
}
static void run_sync_test(int num_buffers, bool verify)
......
......@@ -570,11 +570,8 @@ static void init_set(unsigned set)
static void exchange_uint(void *array, unsigned i, unsigned j)
{
unsigned *i_arr = array;
unsigned i_tmp;
i_tmp = i_arr[i];
i_arr[i] = i_arr[j];
i_arr[j] = i_tmp;
swap(i_arr[i], i_arr[j]);
}
static void copy_tiles(unsigned *permutation)
......@@ -741,7 +738,7 @@ static void init(void)
if (options.num_buffers == 0) {
tmp = gem_aperture_size(drm_fd);
tmp = tmp > 256*(1024*1024) ? 256*(1024*1024) : tmp;
tmp = min(256 * (1024 * 1024), tmp);
num_buffers = 2 * tmp / options.scratch_buf_size / 3;
num_buffers /= 2;
igt_info("using %u buffers\n", num_buffers);
......
......@@ -165,7 +165,7 @@ static unsigned long gettime_us(void)
static void emit_dummy_load__bcs(struct test_output *o)
{
int i, limit;
drm_intel_bo *dummy_bo, *target_bo, *tmp_bo;
drm_intel_bo *dummy_bo, *target_bo;
struct igt_fb *fb_info = &o->fb_info[o->current_fb_id];
unsigned pitch = fb_info->stride;
......@@ -197,9 +197,7 @@ static void emit_dummy_load__bcs(struct test_output *o)
ADVANCE_BATCH();
}
tmp_bo = dummy_bo;
dummy_bo = target_bo;
target_bo = tmp_bo;
swap(dummy_bo, target_bo);
}
intel_batchbuffer_flush(batch);
......@@ -282,16 +280,12 @@ static void emit_dummy_load__rcs(struct test_output *o)
dst = &sb[1];
for (i = 0; i < limit; i++) {
struct igt_buf *tmp;
copyfunc(batch, NULL,
src, 0, 0,
o->fb_width, o->fb_height,
dst, 0, 0);
tmp = src;
src = dst;
dst = tmp;
swap(src, dst);
}
intel_batchbuffer_flush(batch);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment