Fix warnings and errors reported by gcc
This commit is contained in:
parent
07a223f250
commit
1f423b1d9b
@ -7,10 +7,9 @@ argparser_t parse_args(i32 argc, char *argv[]) {
|
|||||||
return (argparser_t){0};
|
return (argparser_t){0};
|
||||||
}
|
}
|
||||||
|
|
||||||
argparser_t output = {
|
argparser_t output = {0};
|
||||||
.succeeded = true,
|
output.succeeded = true;
|
||||||
.args = (pckr_args_t){0},
|
output.args = (pckr_args_t){0};
|
||||||
};
|
|
||||||
|
|
||||||
realpath(argv[1], output.args.dir);
|
realpath(argv[1], output.args.dir);
|
||||||
realpath(argv[2], output.args.output);
|
realpath(argv[2], output.args.output);
|
||||||
|
@ -40,7 +40,7 @@ i64 darr_add(darr_t **darr, void *item) {
|
|||||||
return INVALID_IDX;
|
return INVALID_IDX;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*darr)->capacity = orig->capacity + BASE_CAPACITY;
|
(*darr)->capacity += BASE_CAPACITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 index = (*darr)->count;
|
u64 index = (*darr)->count;
|
||||||
|
14
src/io.c
14
src/io.c
@ -16,8 +16,8 @@ struct dirwalk {
|
|||||||
u64 count;
|
u64 count;
|
||||||
FILE *current_file;
|
FILE *current_file;
|
||||||
DIR *current_dir;
|
DIR *current_dir;
|
||||||
char dst[PATH_MAX];
|
char dst[PATH_MAX + 1];
|
||||||
DIR *directories[MAX_DIR_DEPTH];
|
DIR *directories[MAX_DIR_DEPTH + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 get_file_length(FILE *fp) {
|
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;
|
dirwalk_t *dw = *dirwalk;
|
||||||
|
|
||||||
char tmp[PATH_MAX] = {0};
|
char tmp[PATH_MAX + 1] = {0};
|
||||||
|
|
||||||
dirent_t *ep = NULL;
|
dirent_t *ep = NULL;
|
||||||
stat_t dirstat = {0};
|
stat_t dirstat = {0};
|
||||||
@ -102,7 +102,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
|
|
||||||
result.reading = true;
|
result.reading = true;
|
||||||
result.fp = dw->current_file;
|
result.fp = dw->current_file;
|
||||||
strncpy(result.name, ep->d_name, NAME_MAX);
|
strncpy(result.name, ep->d_name, NAME_MAX + 1);
|
||||||
|
|
||||||
return result;
|
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) {
|
if ((dirstat.st_mode & S_IFDIR) == S_IFDIR) {
|
||||||
memset(dw->dst, 0, length);
|
memset(dw->dst, 0, length);
|
||||||
|
|
||||||
strncpy(dw->dst, tmp, length);
|
strncpy(dw->dst, tmp, length + 1);
|
||||||
|
|
||||||
dw->directories[(dw->count)++] = opendir(dw->dst);
|
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.reading = true;
|
||||||
result.fp = dw->current_file;
|
result.fp = dw->current_file;
|
||||||
strncpy(result.name, ep->d_name, NAME_MAX);
|
strncpy(result.name, ep->d_name, NAME_MAX + 1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
|
|
||||||
u64 length = strlen(dw->dst);
|
u64 length = strlen(dw->dst);
|
||||||
|
|
||||||
strncpy(tmp, dw->dst, length);
|
strcpy(tmp, dw->dst);
|
||||||
|
|
||||||
memset(dw->dst, 0, length);
|
memset(dw->dst, 0, length);
|
||||||
|
|
||||||
|
10
src/pak.c
10
src/pak.c
@ -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 create_asset_pack(const char *dirpath, const char *output) {
|
||||||
bool created = false;
|
bool created = false;
|
||||||
|
|
||||||
char dst[PATH_MAX] = {0};
|
char dst[PATH_MAX + 1] = {0};
|
||||||
|
|
||||||
u64 output_length = strlen(output);
|
strcpy(dst, output);
|
||||||
strncpy(dst, output, output_length);
|
|
||||||
|
|
||||||
u64 ext_length = strlen(PAK_EXT);
|
strcat(dst, PAK_EXT);
|
||||||
strncat(dst, PAK_EXT, ext_length);
|
|
||||||
|
|
||||||
FILE *fp = fopen(dst, "wb");
|
FILE *fp = fopen(dst, "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
@ -252,7 +250,7 @@ toc_entry_t *create_toc_entry(const char *name, u64 offset) {
|
|||||||
entry->offset = offset;
|
entry->offset = offset;
|
||||||
entry->length = length + 1;
|
entry->length = length + 1;
|
||||||
|
|
||||||
strncpy(entry->name, name, length);
|
strcpy(entry->name, name);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user