From 81c38e825c9dda9321cdcb73a2158fa8bd991867 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 15 Aug 2021 18:55:19 -0400 Subject: [PATCH] [client] remove all casts around malloc The cast is unnecessary in C and should be removed to avoid clutter. --- client/displayservers/X11/clipboard.c | 2 +- client/renderers/EGL/cursor.c | 4 ++-- client/renderers/EGL/damage.c | 2 +- client/renderers/EGL/desktop.c | 2 +- client/renderers/EGL/draw.c | 4 ++-- client/renderers/EGL/model.c | 8 ++++---- client/renderers/EGL/shader.c | 2 +- client/renderers/EGL/splash.c | 2 +- client/renderers/EGL/texture_buffer.c | 2 +- client/renderers/EGL/texture_dmabuf.c | 2 +- client/renderers/OpenGL/opengl.c | 2 +- client/src/app.c | 4 ++-- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/client/displayservers/X11/clipboard.c b/client/displayservers/X11/clipboard.c index d50ea313..379f52f0 100644 --- a/client/displayservers/X11/clipboard.c +++ b/client/displayservers/X11/clipboard.c @@ -153,7 +153,7 @@ static void x11CBReplyFn(void * opaque, LG_ClipboardData type, static void x11CBSelectionRequest(const XSelectionRequestEvent e) { - XEvent * s = (XEvent *)malloc(sizeof(*s)); + XEvent * s = malloc(sizeof(*s)); s->xselection.type = SelectionNotify; s->xselection.requestor = e.requestor; s->xselection.selection = e.selection; diff --git a/client/renderers/EGL/cursor.c b/client/renderers/EGL/cursor.c index b9b830ca..8bc7b10c 100644 --- a/client/renderers/EGL/cursor.c +++ b/client/renderers/EGL/cursor.c @@ -135,7 +135,7 @@ static void cursorTexFree(struct CursorTex * t) bool egl_cursorInit(EGL_Cursor ** cursor) { - *cursor = (EGL_Cursor *)malloc(sizeof(**cursor)); + *cursor = malloc(sizeof(**cursor)); if (!*cursor) { DEBUG_ERROR("Failed to malloc EGL_Cursor"); @@ -206,7 +206,7 @@ bool egl_cursorSetShape(EGL_Cursor * cursor, const LG_RendererCursor type, if (cursor->data) free(cursor->data); - cursor->data = (uint8_t *)malloc(size); + cursor->data = malloc(size); if (!cursor->data) { DEBUG_ERROR("Failed to malloc buffer for cursor shape"); diff --git a/client/renderers/EGL/damage.c b/client/renderers/EGL/damage.c index 99d4969d..30deb895 100644 --- a/client/renderers/EGL/damage.c +++ b/client/renderers/EGL/damage.c @@ -59,7 +59,7 @@ void egl_damageConfigUI(EGL_Damage * damage) bool egl_damageInit(EGL_Damage ** damage) { - *damage = (EGL_Damage *)malloc(sizeof(**damage)); + *damage = malloc(sizeof(**damage)); if (!*damage) { DEBUG_ERROR("Failed to malloc EGL_Damage"); diff --git a/client/renderers/EGL/desktop.c b/client/renderers/EGL/desktop.c index 4df1777b..5b10a814 100644 --- a/client/renderers/EGL/desktop.c +++ b/client/renderers/EGL/desktop.c @@ -116,7 +116,7 @@ static bool egl_initDesktopShader( bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop_, EGLDisplay * display, bool useDMA, int maxRects) { - EGL_Desktop * desktop = (EGL_Desktop *)calloc(1, sizeof(EGL_Desktop)); + EGL_Desktop * desktop = calloc(1, sizeof(EGL_Desktop)); if (!desktop) { DEBUG_ERROR("Failed to malloc EGL_Desktop"); diff --git a/client/renderers/EGL/draw.c b/client/renderers/EGL/draw.c index 9f299d84..03b3e183 100644 --- a/client/renderers/EGL/draw.c +++ b/client/renderers/EGL/draw.c @@ -25,7 +25,7 @@ void egl_drawTorus(EGL_Model * model, unsigned int pts, float x, float y, float inner, float outer) { - GLfloat * v = (GLfloat *)malloc(sizeof(*v) * (pts + 1) * 6); + GLfloat * v = malloc(sizeof(*v) * (pts + 1) * 6); GLfloat * dst = v; for(unsigned int i = 0; i <= pts; ++i) @@ -48,7 +48,7 @@ void egl_drawTorus(EGL_Model * model, unsigned int pts, float x, float y, void egl_drawTorusArc(EGL_Model * model, unsigned int pts, float x, float y, float inner, float outer, float s, float e) { - GLfloat * v = (GLfloat *)malloc(sizeof(*v) * (pts + 1) * 6); + GLfloat * v = malloc(sizeof(*v) * (pts + 1) * 6); GLfloat * dst = v; for(unsigned int i = 0; i <= pts; ++i) diff --git a/client/renderers/EGL/model.c b/client/renderers/EGL/model.c index 6e4a1c25..a7e35b51 100644 --- a/client/renderers/EGL/model.c +++ b/client/renderers/EGL/model.c @@ -54,7 +54,7 @@ void update_uniform_bindings(EGL_Model * model); bool egl_modelInit(EGL_Model ** model) { - *model = (EGL_Model *)malloc(sizeof(**model)); + *model = malloc(sizeof(**model)); if (!*model) { DEBUG_ERROR("Failed to malloc EGL_Model"); @@ -123,11 +123,11 @@ void egl_modelSetDefault(EGL_Model * model, bool flipped) void egl_modelAddVerts(EGL_Model * model, const GLfloat * verticies, const GLfloat * uvs, const size_t count) { - struct FloatList * fl = (struct FloatList *)malloc(sizeof(*fl)); + struct FloatList * fl = malloc(sizeof(*fl)); fl->count = count; - fl->v = (GLfloat *)malloc(sizeof(GLfloat) * count * 3); - fl->u = (GLfloat *)malloc(sizeof(GLfloat) * count * 2); + fl->v = malloc(sizeof(GLfloat) * count * 3); + fl->u = malloc(sizeof(GLfloat) * count * 2); memcpy(fl->v, verticies, sizeof(GLfloat) * count * 3); if (uvs) diff --git a/client/renderers/EGL/shader.c b/client/renderers/EGL/shader.c index 8acc4c30..aad017cc 100644 --- a/client/renderers/EGL/shader.c +++ b/client/renderers/EGL/shader.c @@ -38,7 +38,7 @@ struct EGL_Shader bool egl_shaderInit(EGL_Shader ** this) { - *this = (EGL_Shader *)calloc(1, sizeof(EGL_Shader)); + *this = calloc(1, sizeof(EGL_Shader)); if (!*this) { DEBUG_ERROR("Failed to malloc EGL_Shader"); diff --git a/client/renderers/EGL/splash.c b/client/renderers/EGL/splash.c index 0c870584..a81ffe31 100644 --- a/client/renderers/EGL/splash.c +++ b/client/renderers/EGL/splash.c @@ -51,7 +51,7 @@ struct EGL_Splash bool egl_splashInit(EGL_Splash ** splash) { - *splash = (EGL_Splash *)malloc(sizeof(**splash)); + *splash = malloc(sizeof(**splash)); if (!*splash) { DEBUG_ERROR("Failed to malloc EGL_Splash"); diff --git a/client/renderers/EGL/texture_buffer.c b/client/renderers/EGL/texture_buffer.c index 495fe0c4..c4b53dea 100644 --- a/client/renderers/EGL/texture_buffer.c +++ b/client/renderers/EGL/texture_buffer.c @@ -51,7 +51,7 @@ bool egl_texBufferInit(EGL_Texture ** texture, EGLDisplay * display) TextureBuffer * this; if (!*texture) { - this = (TextureBuffer *)calloc(1, sizeof(*this)); + this = calloc(1, sizeof(*this)); if (!this) { DEBUG_ERROR("Failed to malloc TexB"); diff --git a/client/renderers/EGL/texture_dmabuf.c b/client/renderers/EGL/texture_dmabuf.c index 2f410ffe..38535f02 100644 --- a/client/renderers/EGL/texture_dmabuf.c +++ b/client/renderers/EGL/texture_dmabuf.c @@ -57,7 +57,7 @@ static void egl_texDMABUFCleanup(TexDMABUF * this) static bool egl_texDMABUFInit(EGL_Texture ** texture, EGLDisplay * display) { - TexDMABUF * this = (TexDMABUF *)calloc(1, sizeof(*this)); + TexDMABUF * this = calloc(1, sizeof(*this)); *texture = &this->base.base; EGL_Texture * parent = &this->base.base; diff --git a/client/renderers/OpenGL/opengl.c b/client/renderers/OpenGL/opengl.c index 49663512..5c798d13 100644 --- a/client/renderers/OpenGL/opengl.c +++ b/client/renderers/OpenGL/opengl.c @@ -326,7 +326,7 @@ bool opengl_onMouseShape(LG_Renderer * renderer, const LG_RendererCursor cursor, { if (this->mouseData) free(this->mouseData); - this->mouseData = (uint8_t *)malloc(size); + this->mouseData = malloc(size); this->mouseDataSize = size; } diff --git a/client/src/app.c b/client/src/app.c index 5aa1f3c1..e6989148 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -216,7 +216,7 @@ void app_clipboardRequest(const LG_ClipboardReplyFn replyFn, void * opaque) if (!g_params.clipboardToLocal) return; - struct CBRequest * cbr = (struct CBRequest *)malloc(sizeof(*cbr)); + struct CBRequest * cbr = malloc(sizeof(*cbr)); cbr->type = g_state.cbType; cbr->replyFn = replyFn; @@ -661,7 +661,7 @@ KeybindHandle app_registerKeybind(int sc, KeybindFn callback, void * opaque, con return NULL; } - KeybindHandle handle = (KeybindHandle)malloc(sizeof(*handle)); + KeybindHandle handle = malloc(sizeof(*handle)); handle->sc = sc; handle->callback = callback; handle->opaque = opaque;