Ver código fonte

Replace strcpy with memcpy to fix -O3 build

master
Nathaniel Walizer 11 meses atrás
pai
commit
f91369e98f
2 arquivos alterados com 6 adições e 5 exclusões
  1. +2
    -1
      Makefile
  2. +4
    -4
      src/file.c

+ 2
- 1
Makefile Ver arquivo

@@ -17,7 +17,8 @@ endif
CC = $(CROSS_COMPILE)gcc
LD = $(CC)
PFLAGS = -g
#PFLAGS += -O3 -s
#PFLAGS += -O3
#PFLAGS += -s
#PFLAGS += -DDEBUG_MAPPER
#PFLAGS += -DDEBUG_RENDER
#PFLAGS += -DDEBUG_PPU -DDEBUG_VRAM -DDEBUG_OAM


+ 4
- 4
src/file.c Ver arquivo

@@ -31,7 +31,7 @@ int make_filename(char* filename, int max_len,

// Part 1/4: Leading path
if (0 == status && orig_path_len <= remain) {
strncpy(filename, orig_name, orig_path_len);
memcpy(filename, orig_name, orig_path_len);
remain -= orig_path_len;
filename += orig_path_len;
} else {
@@ -42,7 +42,7 @@ int make_filename(char* filename, int max_len,
if (0 == status && NULL != subdir) {
int subdir_len = strlen(subdir);
if ((subdir_len + 1) <= remain) {
strncpy(filename, subdir, subdir_len);
memcpy(filename, subdir, subdir_len);
filename += subdir_len;
*filename++ = '/';
remain -= (subdir_len + 1);
@@ -53,7 +53,7 @@ int make_filename(char* filename, int max_len,

// Part 3/4: Basename
if (0 == status && orig_base_len <= remain) {
strncpy(filename, orig_name, orig_base_len);
memcpy(filename, orig_name, orig_base_len);
remain -= orig_base_len;
filename += orig_base_len;
} else {
@@ -65,7 +65,7 @@ int make_filename(char* filename, int max_len,
int ext_len = strlen(ext);
if ((ext_len + 1) <= remain) {
*filename++ = '.';
strncpy(filename, ext, ext_len);
memcpy(filename, ext, ext_len);
remain -= (ext_len + 1);
filename += ext_len;
} else {


Carregando…
Cancelar
Salvar