From 3e4a097e70b5d12b3be237c97b9c47a6f9cc535a Mon Sep 17 00:00:00 2001 From: night0721 Date: Mon, 4 Nov 2024 23:53:11 +0000 Subject: [PATCH] Resolve compiler warnings and udpate CFLAGS --- Makefile | 6 +++--- include/commands.h | 2 +- include/history.h | 2 +- src/90s.c | 4 ++-- src/commands.c | 4 ++-- src/history.c | 2 +- src/job.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index cc6d976..4f5004d 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,16 @@ .POSIX: .SUFFIXES: -VERSION = 1.0 +VERSION = "1.0" TARGET = 90s MANPAGE = $(TARGET).1 PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/share/man/man1 -CFLAGS = -O3 -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -DVERSION=$(VERSION) +CFLAGS = -Os -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -DVERSION=$(VERSION) -D_DEFAULT_SOURCE -SRC = src/*.c +SRC != find src -name *.c INCLUDE = include $(TARGET): $(SRC) diff --git a/include/commands.h b/include/commands.h index 0621168..4c5d8ac 100644 --- a/include/commands.h +++ b/include/commands.h @@ -2,7 +2,7 @@ #define COMMANDS_H_ char *replace_absolute_home(char *str); -int num_builtins(); +int num_builtins(void); bool is_builtin(char *command); int execute(char **args, int fd, int options); int execute_pipe(char ***args); diff --git a/include/history.h b/include/history.h index 83f5aa1..45b69bf 100644 --- a/include/history.h +++ b/include/history.h @@ -4,7 +4,7 @@ extern int cmd_count; void save_command_history(char *args); -void check_history_file(); +void check_history_file(void); char *read_command(int direction); char **get_all_history(bool check); diff --git a/src/90s.c b/src/90s.c index c3add9d..f5b8c1c 100644 --- a/src/90s.c +++ b/src/90s.c @@ -35,7 +35,7 @@ void change_terminal_attribute(int option) { } } -char **setup_path_variable() { +char **setup_path_variable(void) { char *envpath = getenv("PATH"); if (envpath == NULL) { fprintf(stderr, "90s: PATH environment variable is missing\n"); @@ -95,7 +95,7 @@ void shiftright(int chars) { printf("\033[%dC", chars); } -void clearline() { +void clearline(void) { printf("\033[K"); // clear line to the right of cursor } diff --git a/src/commands.c b/src/commands.c index 5941c02..637ced7 100644 --- a/src/commands.c +++ b/src/commands.c @@ -58,7 +58,7 @@ char *shortcut_expand_dirs[] = { "/usr/local/bin", }; -char *gethome() { +char *gethome(void) { char *home = getenv("HOME"); if (home == NULL) { fprintf(stderr, "Error: HOME environment variable not set.\n"); @@ -118,7 +118,7 @@ char *replace_absolute_home(char *str) { } // number of built in commands -int num_builtins() { +int num_builtins(void) { return sizeof(builtin_cmds) / sizeof(char *); } diff --git a/src/history.c b/src/history.c index 709ba13..6756964 100644 --- a/src/history.c +++ b/src/history.c @@ -21,7 +21,7 @@ FILE *open_history_file(char *mode) { } return history_file; } -void check_history_file() { +void check_history_file(void) { char *env_home; env_home = getenv("XDG_CONFIG_HOME"); if (env_home == NULL) { diff --git a/src/job.c b/src/job.c index 5fc0bc4..0ac6a74 100644 --- a/src/job.c +++ b/src/job.c @@ -13,7 +13,7 @@ typedef struct job { job *jobs = NULL; -int num_jobs() { +int num_jobs(void) { job *current = jobs; int count = 0; while (current != NULL) {