aboutsummaryrefslogtreecommitdiff
path: root/libs/libgui
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libgui')
-rw-r--r--libs/libgui/bmp.h4
-rw-r--r--libs/libgui/gfx.h25
-rw-r--r--libs/libgui/gui.h4
-rw-r--r--libs/libgui/msg.c4
-rw-r--r--libs/libgui/msg.h4
-rw-r--r--libs/libgui/png.c3
-rw-r--r--libs/libgui/psf.c3
-rw-r--r--libs/libgui/psf.h2
8 files changed, 24 insertions, 25 deletions
diff --git a/libs/libgui/bmp.h b/libs/libgui/bmp.h
index ff8360b..f7fb57f 100644
--- a/libs/libgui/bmp.h
+++ b/libs/libgui/bmp.h
@@ -11,7 +11,7 @@ struct bmp_header {
u32 size;
u32 reserved;
u32 offset;
-} __attribute__((packed));
+} PACKED;
struct bmp_info {
u32 size;
@@ -34,6 +34,6 @@ struct bmp {
u32 pitch;
};
-struct bmp *bmp_load(const char *path);
+struct bmp *bmp_load(const char *path) NONNULL;
#endif
diff --git a/libs/libgui/gfx.h b/libs/libgui/gfx.h
index 83736fd..082fe07 100644
--- a/libs/libgui/gfx.h
+++ b/libs/libgui/gfx.h
@@ -66,18 +66,21 @@ struct context {
u32 bytes;
};
-struct context *gfx_new_ctx(struct context *ctx, vec2 size, u8 bpp);
+struct context *gfx_new_ctx(struct context *ctx, vec2 size, u8 bpp) NONNULL;
struct font *gfx_resolve_font(enum font_type font_type);
-void gfx_write_char(struct context *ctx, vec2 pos, enum font_type font_type, u32 c, char ch);
-void gfx_write(struct context *ctx, vec2 pos, enum font_type font_type, u32 c, const char *text);
-void gfx_load_image(struct context *ctx, vec2 pos, const char *path);
-void gfx_load_image_filter(struct context *ctx, vec2 pos, enum gfx_filter filter, const char *path);
-void gfx_load_wallpaper(struct context *ctx, const char *path);
-void gfx_copy(struct context *dest, struct context *src, vec2 pos, vec2 size);
-void gfx_ctx_on_ctx(struct context *dest, struct context *src, vec2 pos);
-void gfx_draw_rectangle(struct context *ctx, vec2 pos1, vec2 pos2, u32 c);
-void gfx_fill(struct context *ctx, u32 c);
-void gfx_border(struct context *ctx, u32 c, u32 width);
+void gfx_write_char(struct context *ctx, vec2 pos, enum font_type font_type, u32 c,
+ char ch) NONNULL;
+void gfx_write(struct context *ctx, vec2 pos, enum font_type font_type, u32 c,
+ const char *text) NONNULL;
+void gfx_load_image(struct context *ctx, vec2 pos, const char *path) NONNULL;
+void gfx_load_image_filter(struct context *ctx, vec2 pos, enum gfx_filter filter,
+ const char *path) NONNULL;
+void gfx_load_wallpaper(struct context *ctx, const char *path) NONNULL;
+void gfx_copy(struct context *dest, struct context *src, vec2 pos, vec2 size) NONNULL;
+void gfx_ctx_on_ctx(struct context *dest, struct context *src, vec2 pos) NONNULL;
+void gfx_draw_rectangle(struct context *ctx, vec2 pos1, vec2 pos2, u32 c) NONNULL;
+void gfx_fill(struct context *ctx, u32 c) NONNULL;
+void gfx_border(struct context *ctx, u32 c, u32 width) NONNULL;
int gfx_font_height(enum font_type);
int gfx_font_width(enum font_type);
diff --git a/libs/libgui/gui.h b/libs/libgui/gui.h
index 5190155..f4c213b 100644
--- a/libs/libgui/gui.h
+++ b/libs/libgui/gui.h
@@ -23,9 +23,9 @@ res gui_redraw_window(u32 id);
res gui_fill(u32 win_id, u32 widget_id, enum gui_layer layer, u32 c);
res gui_load_image(u32 win_id, u32 widget_id, enum gui_layer layer, vec2 pos, vec2 size,
- const char *path);
+ const char *path) NONNULL;
res gui_load_image_filter(u32 win_id, u32 widget_id, enum gui_layer layer, vec2 pos, vec2 size,
- enum gfx_filter filter, const char *path);
+ enum gfx_filter filter, const char *path) NONNULL;
res gui_add_widget(u32 win_id, u32 widget_id, vec2 size, vec2 pos);
res gui_new_widget(u32 win_id, vec2 size, vec2 pos);
diff --git a/libs/libgui/msg.c b/libs/libgui/msg.c
index 73af242..051072e 100644
--- a/libs/libgui/msg.c
+++ b/libs/libgui/msg.c
@@ -8,11 +8,9 @@
res msg_send(u32 pid, enum message_type type, void *data, u32 size)
{
- if (!data)
- return -EFAULT;
assert((signed)pid != -1 && size >= sizeof(struct message_header));
char path[32] = { 0 };
- sprintf(path, "/proc/%d/msg", pid);
+ snprintf(path, sizeof(path), "/proc/%d/msg", pid);
struct message_header *header = data;
header->magic = MSG_MAGIC;
header->src = getpid();
diff --git a/libs/libgui/msg.h b/libs/libgui/msg.h
index 65fc640..c25e95e 100644
--- a/libs/libgui/msg.h
+++ b/libs/libgui/msg.h
@@ -66,7 +66,7 @@ enum message_type {
GUI_KEYBOARD,
};
-res msg_send(u32 pid, enum message_type type, void *data, u32 size);
-res msg_receive(void *buf, u32 size);
+res msg_send(u32 pid, enum message_type type, void *data, u32 size) NONNULL;
+res msg_receive(void *buf, u32 size) NONNULL;
#endif
diff --git a/libs/libgui/png.c b/libs/libgui/png.c
index 6f8f4b5..2ff3340 100644
--- a/libs/libgui/png.c
+++ b/libs/libgui/png.c
@@ -90,7 +90,8 @@ static void *png_realloc(void *ptr, u32 new_size)
static void png_free(void *ptr)
{
- free(ptr);
+ if (ptr)
+ free(ptr);
}
#else /*PNG_COMPILE_ALLOCATORS*/
/* TODO: support giving additional void* payload to the custom allocators */
diff --git a/libs/libgui/psf.c b/libs/libgui/psf.c
index e28c2d7..751421a 100644
--- a/libs/libgui/psf.c
+++ b/libs/libgui/psf.c
@@ -25,9 +25,6 @@ static int psf_verify(char *data)
struct font *psf_parse(char *data)
{
- if (!data)
- return NULL;
-
int version = psf_verify(data);
char *chars;
diff --git a/libs/libgui/psf.h b/libs/libgui/psf.h
index 63a3d1e..4d63118 100644
--- a/libs/libgui/psf.h
+++ b/libs/libgui/psf.h
@@ -43,6 +43,6 @@ struct psf2_header {
u32 width;
};
-struct font *psf_parse(char *data);
+struct font *psf_parse(char *data) NONNULL;
#endif