Compare commits

...

2 Commits

Author SHA1 Message Date
1f423b1d9b Fix warnings and errors reported by gcc 2023-11-04 14:22:20 +00:00
07a223f250 Switch to using gcc instead of clang 2023-11-04 14:21:44 +00:00
5 changed files with 17 additions and 20 deletions

View File

@ -20,7 +20,7 @@ FG_BR_MAGENTA="\033[95"
FG_BR_CYAN="\033[96"
FG_BR_WHITE="\033[97"
CC=clang
CC=gcc
AR=ar
CFLAGS="-Wall -Werror -pedantic -Iinclude -Iintern/c-cpp-aliases -Iintern/cpath/include "
@ -78,7 +78,7 @@ if [[ $BUILD_TYPE == "debug" ]]; then
else
mkdir -p dist
cp ./include/pak.h dist
CFLAGS+="-O3 "
CFLAGS+="-O3 -g "
PCKR_OUT="dist/pckr"
PAKRD_OUT="dist/libpakrd.a"
fi

View File

@ -7,10 +7,9 @@ argparser_t parse_args(i32 argc, char *argv[]) {
return (argparser_t){0};
}
argparser_t output = {
.succeeded = true,
.args = (pckr_args_t){0},
};
argparser_t output = {0};
output.succeeded = true;
output.args = (pckr_args_t){0};
realpath(argv[1], output.args.dir);
realpath(argv[2], output.args.output);

View File

@ -40,7 +40,7 @@ i64 darr_add(darr_t **darr, void *item) {
return INVALID_IDX;
}
(*darr)->capacity = orig->capacity + BASE_CAPACITY;
(*darr)->capacity += BASE_CAPACITY;
}
u64 index = (*darr)->count;

View File

@ -16,8 +16,8 @@ struct dirwalk {
u64 count;
FILE *current_file;
DIR *current_dir;
char dst[PATH_MAX];
DIR *directories[MAX_DIR_DEPTH];
char dst[PATH_MAX + 1];
DIR *directories[MAX_DIR_DEPTH + 1];
};
u64 get_file_length(FILE *fp) {
@ -73,7 +73,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
dirwalk_t *dw = *dirwalk;
char tmp[PATH_MAX] = {0};
char tmp[PATH_MAX + 1] = {0};
dirent_t *ep = NULL;
stat_t dirstat = {0};
@ -102,7 +102,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
result.reading = true;
result.fp = dw->current_file;
strncpy(result.name, ep->d_name, NAME_MAX);
strncpy(result.name, ep->d_name, NAME_MAX + 1);
return result;
}
@ -116,7 +116,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
if ((dirstat.st_mode & S_IFDIR) == S_IFDIR) {
memset(dw->dst, 0, length);
strncpy(dw->dst, tmp, length);
strncpy(dw->dst, tmp, length + 1);
dw->directories[(dw->count)++] = opendir(dw->dst);
@ -128,7 +128,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
result.reading = true;
result.fp = dw->current_file;
strncpy(result.name, ep->d_name, NAME_MAX);
strncpy(result.name, ep->d_name, NAME_MAX + 1);
return result;
}
@ -150,7 +150,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
u64 length = strlen(dw->dst);
strncpy(tmp, dw->dst, length);
strcpy(tmp, dw->dst);
memset(dw->dst, 0, length);

View File

@ -34,13 +34,11 @@ void write_pak(const pak_t *pak, toc_entry_t **toc_entries,
bool create_asset_pack(const char *dirpath, const char *output) {
bool created = false;
char dst[PATH_MAX] = {0};
char dst[PATH_MAX + 1] = {0};
u64 output_length = strlen(output);
strncpy(dst, output, output_length);
strcpy(dst, output);
u64 ext_length = strlen(PAK_EXT);
strncat(dst, PAK_EXT, ext_length);
strcat(dst, PAK_EXT);
FILE *fp = fopen(dst, "wb");
if (!fp) {
@ -252,7 +250,7 @@ toc_entry_t *create_toc_entry(const char *name, u64 offset) {
entry->offset = offset;
entry->length = length + 1;
strncpy(entry->name, name, length);
strcpy(entry->name, name);
return entry;
}