mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Make CodeQL happy
This commit is contained in:
parent
d647e21779
commit
148d60b9ea
2 changed files with 12 additions and 12 deletions
18
glfw/wl_client_side_decorations.c
vendored
18
glfw/wl_client_side_decorations.c
vendored
|
|
@ -92,11 +92,11 @@ create_shadow_tile(_GLFWwindow *window) {
|
|||
const size_t margin = (size_t)round(decs.metrics.width * decs.for_window_state.fscale);
|
||||
if (st.data && st.for_decoration_size == margin) return margin;
|
||||
st.for_decoration_size = margin;
|
||||
free(st.data);
|
||||
st.segments = 7;
|
||||
st.stride = st.segments * margin;
|
||||
st.corner_size = margin * (st.segments - 1) / 2;
|
||||
kernel_type* mask = create_shadow_mask(st.stride, st.stride, margin, 2 * margin + 1, (kernel_type)0.7, 32 * margin);
|
||||
free(st.data);
|
||||
st.data = malloc(sizeof(uint32_t) * st.stride * st.stride);
|
||||
if (st.data) for (size_t i = 0; i < st.stride * st.stride; i++) st.data[i] = ((uint8_t)(mask[i] * 255)) << 24;
|
||||
free(mask);
|
||||
|
|
@ -210,7 +210,7 @@ scale(unsigned thickness, float factor) {
|
|||
|
||||
static void
|
||||
render_minimize(uint8_t *out, unsigned width, unsigned height) {
|
||||
memset(out, 0, width * height);
|
||||
memset(out, 0, (size_t)width * height);
|
||||
unsigned thickness = height / 12;
|
||||
unsigned baseline = height - thickness * 2;
|
||||
unsigned side_margin = scale(thickness, 3.8f);
|
||||
|
|
@ -220,7 +220,7 @@ render_minimize(uint8_t *out, unsigned width, unsigned height) {
|
|||
|
||||
static void
|
||||
render_maximize(uint8_t *out, unsigned width, unsigned height) {
|
||||
memset(out, 0, width * height);
|
||||
memset(out, 0, (size_t)width * height);
|
||||
unsigned thickness = height / 12, half_thickness = thickness / 2;
|
||||
unsigned baseline = height - thickness * 2;
|
||||
unsigned side_margin = scale(thickness, 3.0f);
|
||||
|
|
@ -234,7 +234,7 @@ render_maximize(uint8_t *out, unsigned width, unsigned height) {
|
|||
|
||||
static void
|
||||
render_restore(uint8_t *out, unsigned width, unsigned height) {
|
||||
memset(out, 0, width * height);
|
||||
memset(out, 0, (size_t)width * height);
|
||||
unsigned thickness = height / 12, half_thickness = thickness / 2;
|
||||
unsigned baseline = height - thickness * 2;
|
||||
unsigned side_margin = scale(thickness, 3.0f);
|
||||
|
|
@ -277,7 +277,7 @@ render_line(uint8_t *buf, unsigned width, unsigned height, unsigned thickness, i
|
|||
|
||||
static void
|
||||
render_close(uint8_t *out, unsigned width, unsigned height) {
|
||||
memset(out, 0, width * height);
|
||||
memset(out, 0, (size_t)width * height);
|
||||
unsigned thickness = height / 12;
|
||||
unsigned baseline = height - thickness * 2;
|
||||
unsigned side_margin = scale(thickness, 3.3f);
|
||||
|
|
@ -313,10 +313,10 @@ static void
|
|||
render_button(void(*which)(uint8_t *, unsigned, unsigned), bool antialias, uint32_t *dest, uint8_t *src, unsigned height, unsigned dest_stride, unsigned src_width, unsigned dest_left, uint32_t bg, uint32_t fg) {
|
||||
if (antialias) {
|
||||
static const unsigned factor = 4;
|
||||
uint8_t *big_src = malloc(factor * factor * height * src_width);
|
||||
uint8_t *big_src = malloc((size_t)factor * factor * height * src_width);
|
||||
if (big_src) {
|
||||
which(big_src, src_width * factor, height * factor);
|
||||
memset(src, 0, src_width * height);
|
||||
memset(src, 0, (size_t)src_width * height);
|
||||
downsample(src, big_src, src_width, height, factor);
|
||||
free(big_src);
|
||||
} else which(src, src_width, height);
|
||||
|
|
@ -346,8 +346,8 @@ render_title_bar(_GLFWwindow *window, bool to_front_buffer) {
|
|||
uint8_t *output = to_front_buffer ? decs.titlebar.buffer.data.front : decs.titlebar.buffer.data.back;
|
||||
|
||||
// render text part
|
||||
int button_size = decs.titlebar.buffer.height;
|
||||
int num_buttons = 1;
|
||||
size_t button_size = decs.titlebar.buffer.height;
|
||||
unsigned num_buttons = 1;
|
||||
if (window->wl.wm_capabilities.maximize) num_buttons++;
|
||||
if (window->wl.wm_capabilities.minimize) num_buttons++;
|
||||
if (window->wl.title && window->wl.title[0] && _glfw.callbacks.draw_text) {
|
||||
|
|
|
|||
6
glfw/wl_window.c
vendored
6
glfw/wl_window.c
vendored
|
|
@ -869,7 +869,7 @@ create_single_color_buffer(int width, int height, pixel color) {
|
|||
float alpha = color.alpha / 255.f;
|
||||
color.red = (uint8_t)(alpha * color.red); color.green = (uint8_t)(alpha * color.green); color.blue = (uint8_t)(alpha * color.blue);
|
||||
int shm_format = color.alpha == 0xff ? WL_SHM_FORMAT_XRGB8888 : WL_SHM_FORMAT_ARGB8888;
|
||||
const size_t size = 4 * width * height;
|
||||
const size_t size = (size_t)4 * width * height;
|
||||
int fd = createAnonymousFile(size);
|
||||
if (fd < 0) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: failed to create anonymous file");
|
||||
|
|
@ -1569,7 +1569,7 @@ _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, const GLFWimage* imag
|
|||
struct wl_buffer* *buffers = malloc(sizeof(struct wl_buffer*) * count);
|
||||
if (!buffers) return;
|
||||
size_t total_data_size = 0;
|
||||
for (int i = 0; i < count; i++) total_data_size += images[i].width * images[i].height * 4;
|
||||
for (int i = 0; i < count; i++) total_data_size += (size_t)images[i].width * images[i].height * 4;
|
||||
int fd = createAnonymousFile(total_data_size);
|
||||
if (fd < 0) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Creating a buffer file for %ld B failed: %s", (long)total_data_size, strerror(errno));
|
||||
|
|
@ -1587,7 +1587,7 @@ _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, const GLFWimage* imag
|
|||
struct xdg_toplevel_icon_v1 *icon = xdg_toplevel_icon_manager_v1_create_icon(_glfw.wl.xdg_toplevel_icon_manager_v1);
|
||||
size_t pos = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
const size_t sz = images[i].width * images[i].height * 4;
|
||||
const size_t sz = (size_t)images[i].width * images[i].height * 4;
|
||||
convert_glfw_image_to_wayland_image(images + i, data + pos);
|
||||
buffers[i] = wl_shm_pool_create_buffer(
|
||||
pool, pos, images[i].width, images[i].height, images[i].width * 4, WL_SHM_FORMAT_ARGB8888);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue