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};
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -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;
|
||||
|
14
src/io.c
14
src/io.c
@ -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);
|
||||
|
||||
|
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 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user