aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2020-11-05 17:30:39 +0100
committerMarvin Borner2020-11-05 17:32:53 +0100
commit63e86f792167e6cc2e9600d00b184a3c83fe7498 (patch)
tree31e2d583be3ebf34782f6ec37f6c524657c40686 /apps
parent916fca2161e76de67a5106b90baf00a57f2a0512 (diff)
Added warning flags and fixed them :)
Diffstat (limited to 'apps')
-rw-r--r--apps/Makefile3
-rw-r--r--apps/cc.c7
-rw-r--r--apps/files.c6
-rw-r--r--apps/test.c10
-rw-r--r--apps/window.c4
5 files changed, 16 insertions, 14 deletions
diff --git a/apps/Makefile b/apps/Makefile
index 2f6f430..322b7b6 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -5,7 +5,8 @@ CC = ccache ../cross/opt/bin/i686-elf-gcc
LD = ccache ../cross/opt/bin/i686-elf-ld
OC = ccache ../cross/opt/bin/i686-elf-objcopy
-CFLAGS = -Wall -Wextra -nostdlib -nostdinc -fno-builtin -std=c99 -m32 -pedantic-errors -I../libc/inc/ -I../libgui/inc/ -I../libtxt/inc/ -fPIE -Duserspace -Os
+WARNINGS = -Wall -Wextra -pedantic-errors -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wno-long-long
+CFLAGS = $(WARNINGS) -nostdlib -nostdinc -fno-builtin -std=c99 -m32 -I../libc/inc/ -I../libgui/inc/ -I../libtxt/inc/ -fPIE -Duserspace -Ofast
all: $(COBJS)
diff --git a/apps/cc.c b/apps/cc.c
index 6e989f9..6b571b1 100644
--- a/apps/cc.c
+++ b/apps/cc.c
@@ -5,6 +5,7 @@
#include <def.h>
#include <mem.h>
#include <print.h>
+#include <str.h>
#include <sys.h>
char *p, *lp, // current position in source code
@@ -744,7 +745,7 @@ void stmt()
int main(int argc, char **argv)
{
- int bt, ty, poolsz, *idmain;
+ int bt, poolsz, *idmain;
int *pc, *sp, *bp, a, cycle; // vm registers
int i, *t; // temps
@@ -777,8 +778,8 @@ int main(int argc, char **argv)
memset(e, 0, poolsz);
memset(data, 0, poolsz);
- p = "char else enum if int return sizeof while "
- "open read close printf malloc free memset memcmp exit void main";
+ p = strdup("char else enum if int return sizeof while "
+ "open read close printf malloc free memset memcmp exit void main");
i = Char;
while (i <= While) {
next();
diff --git a/apps/files.c b/apps/files.c
index 2176a99..c27e39c 100644
--- a/apps/files.c
+++ b/apps/files.c
@@ -17,7 +17,7 @@ struct dirent {
char name[];
};
-void render_list(char *path);
+void render_list(const char *path);
void on_click(struct event_mouse *event, struct element *elem)
{
(void)event;
@@ -31,7 +31,7 @@ void on_click(struct event_mouse *event, struct element *elem)
}
// TODO: Dir iterator as kernel syscall?
-void render_list(char *path)
+void render_list(const char *path)
{
static struct element *list = NULL;
if (list)
@@ -49,7 +49,7 @@ void render_list(char *path)
d->name[d->name_len] = '\0';
struct element *label = gui_add_label(list, 5, cnt * (gfx_font_height(FONT_16) + 5),
FONT_16, d->name, COLOR_BLACK, COLOR_WHITE);
- label->attributes = path;
+ label->attributes = (char *)path;
if (d->type_indicator == 2) // Dir
label->event.on_click = on_click;
diff --git a/apps/test.c b/apps/test.c
index 874136e..c47e060 100644
--- a/apps/test.c
+++ b/apps/test.c
@@ -63,11 +63,11 @@ void test_conv()
void test_mem()
{
- char *str0 = "";
- char *str1 = "";
- char *str2 = "12345";
- char *str3 = "12345";
- char *str4 = "12354";
+ const char *str0 = "";
+ const char *str1 = "";
+ const char *str2 = "12345";
+ const char *str3 = "12345";
+ const char *str4 = "12354";
equals(memcmp(str4, str2, strlen(str2)), 1);
equals(memcmp(str2, str4, strlen(str2)), -1);
equals(memcmp(str2, str3, strlen(str2)), 0);
diff --git a/apps/window.c b/apps/window.c
index 4f2aec7..7e1b4be 100644
--- a/apps/window.c
+++ b/apps/window.c
@@ -20,8 +20,8 @@ int main()
struct element *root = gui_init("test", 600, 400, COLOR_BG);
struct element *container =
gui_add_container(root, 0, 0, root->ctx->width / 2, root->ctx->height, COLOR_RED);
- struct element *button =
- gui_add_button(container, 10, 10, FONT_24, "Button", COLOR_WHITE, COLOR_BLACK);
+ struct element *button = gui_add_button(container, 10, 10, FONT_24, strdup("Button"),
+ COLOR_WHITE, COLOR_BLACK);
struct element *text_input =
gui_add_text_input(container, 10, 50, 200, FONT_24, COLOR_WHITE, COLOR_BLACK);
(void)text_input;