[tidy] move loop variable declaration to loop

This commit is contained in:
akallabeth
2024-01-30 10:25:38 +01:00
committed by akallabeth
parent 62f974a5c2
commit d7ebec5a65
345 changed files with 1568 additions and 2828 deletions

View File

@@ -462,7 +462,6 @@ int UwacDisplayDispatch(UwacDisplay* display, int timeout)
{
int ret = 0;
int count = 0;
int i = 0;
UwacTask* task = NULL;
struct epoll_event ep[16];
wl_display_dispatch_pending(display->display);
@@ -485,7 +484,7 @@ int UwacDisplayDispatch(UwacDisplay* display, int timeout)
count = epoll_wait(display->epoll_fd, ep, ARRAY_LENGTH(ep), timeout);
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
task = ep[i].data.ptr;
task->run(task, ep[i].events);
@@ -695,7 +694,6 @@ const UwacOutput* UwacDisplayGetOutput(UwacDisplay* display, int index)
if (display_count <= index)
return NULL;
i = 0;
wl_list_for_each(ret, &display->outputs, link)
{
if (i == index)

View File

@@ -327,14 +327,14 @@ static int update_key_pressed(UwacSeat* seat, uint32_t key)
static int update_key_released(UwacSeat* seat, uint32_t key)
{
uint32_t* keyPtr = NULL;
size_t toMove = 0;
bool found = false;
assert(seat);
size_t i = 0;
for (i = 0, keyPtr = seat->pressed_keys.data; i < seat->pressed_keys.size; i++, keyPtr++)
uint32_t* keyPtr = seat->pressed_keys.data;
for (; i < seat->pressed_keys.size; i++, keyPtr++)
{
if (*keyPtr == key)
{

View File

@@ -121,7 +121,6 @@ static ssize_t recvmsg_cloexec_fallback(int sockfd, struct msghdr* msg, int flag
ssize_t len = 0;
struct cmsghdr* cmsg = NULL;
unsigned char* data = NULL;
int* fd = NULL;
int* end = NULL;
len = recvmsg(sockfd, msg, flags);
@@ -141,7 +140,7 @@ static ssize_t recvmsg_cloexec_fallback(int sockfd, struct msghdr* msg, int flag
data = CMSG_DATA(cmsg);
end = (int*)(data + cmsg->cmsg_len - CMSG_LEN(0));
for (fd = (int*)data; fd < end; ++fd)
for (int* fd = (int*)data; fd < end; ++fd)
*fd = set_cloexec_or_close(*fd);
}

View File

@@ -58,9 +58,7 @@ static const struct wl_buffer_listener buffer_listener = { buffer_release };
static void UwacWindowDestroyBuffers(UwacWindow* w)
{
int i = 0;
for (i = 0; i < w->nbuffers; i++)
for (int i = 0; i < w->nbuffers; i++)
{
UwacBuffer* buffer = &w->buffers[i];
#ifdef UWAC_HAVE_PIXMAN_REGION
@@ -322,7 +320,6 @@ int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32
{
int ret = UWAC_SUCCESS;
UwacBuffer* newBuffers = NULL;
int i = 0;
int fd = 0;
void* data = NULL;
struct wl_shm_pool* pool = NULL;
@@ -361,7 +358,7 @@ int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32
goto error_mmap;
}
for (i = 0; i < nbuffers; i++)
for (int i = 0; i < nbuffers; i++)
{
int bufferIdx = w->nbuffers + i;
UwacBuffer* buffer = &w->buffers[bufferIdx];
@@ -389,13 +386,13 @@ error_mmap:
static UwacBuffer* UwacWindowFindFreeBuffer(UwacWindow* w, ssize_t* index)
{
ssize_t i = 0;
int ret = 0;
if (index)
*index = -1;
for (i = 0; i < w->nbuffers; i++)
size_t i = 0;
for (; i < w->nbuffers; i++)
{
if (!w->buffers[i].used)
{
@@ -683,19 +680,14 @@ static const struct wl_callback_listener frame_listener = { frame_done_cb };
static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale)
{
int nrects = 0;
int i = 0;
int x = 0;
int y = 0;
int w = 0;
int h = 0;
const pixman_box32_t* box = pixman_region32_rectangles(&buffer->damage, &nrects);
for (i = 0; i < nrects; i++, box++)
for (int i = 0; i < nrects; i++, box++)
{
x = ((int)floor(box->x1 / scale)) - 1;
y = ((int)floor(box->y1 / scale)) - 1;
w = ((int)ceil((box->x2 - box->x1) / scale)) + 2;
h = ((int)ceil((box->y2 - box->y1) / scale)) + 2;
const int x = ((int)floor(box->x1 / scale)) - 1;
const int y = ((int)floor(box->y1 / scale)) - 1;
const int w = ((int)ceil((box->x2 - box->x1) / scale)) + 2;
const int h = ((int)ceil((box->y2 - box->y1) / scale)) + 2;
wl_surface_damage(window->surface, x, y, w, h);
}
@@ -705,19 +697,14 @@ static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale)
static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale)
{
uint32_t nrects = 0;
uint32_t i = 0;
int x = 0;
int y = 0;
int w = 0;
int h = 0;
const RECTANGLE_16* box = region16_rects(&buffer->damage, &nrects);
for (i = 0; i < nrects; i++, box++)
for (UINT32 i = 0; i < nrects; i++, box++)
{
x = ((int)floor(box->left / scale)) - 1;
y = ((int)floor(box->top / scale)) - 1;
w = ((int)ceil((box->right - box->left) / scale)) + 2;
h = ((int)ceil((box->bottom - box->top) / scale)) + 2;
const int x = ((int)floor(box->left / scale)) - 1;
const int y = ((int)floor(box->top / scale)) - 1;
const int w = ((int)ceil((box->right - box->left) / scale)) + 2;
const int h = ((int)ceil((box->bottom - box->top) / scale)) + 2;
wl_surface_damage(window->surface, x, y, w, h);
}