fix stringop-truncation warnings

avoid gcc 8.1.0 diagnostics as per https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Warning-Options.html#index-Wstringop-truncation
This commit is contained in:
Dave Murphy 2018-05-08 16:15:34 +01:00
parent 6f248b9b9e
commit 8fb22120bd
3 changed files with 6 additions and 5 deletions

View File

@ -199,7 +199,7 @@ fsdev_fixpath(struct _reent *r,
strncpy(__fixedpath, path, PATH_MAX); strncpy(__fixedpath, path, PATH_MAX);
else else
{ {
strncpy(__fixedpath, __cwd, PATH_MAX); strcpy(__fixedpath, __cwd);
strncat(__fixedpath, path, PATH_MAX - strlen(__cwd)); strncat(__fixedpath, path, PATH_MAX - strlen(__cwd));
} }
@ -242,7 +242,8 @@ fsdev_getfspath(struct _reent *r,
return -1; return -1;
memset(outpath, 0, FS_MAX_PATH); memset(outpath, 0, FS_MAX_PATH);
strncpy(outpath, __fixedpath, FS_MAX_PATH); memcpy(outpath, __fixedpath,FS_MAX_PATH);
outpath[FS_MAX_PATH-1] = '\0';
return 0; return 0;
} }
@ -1038,7 +1039,7 @@ fsdev_chdir(struct _reent *r,
if(R_SUCCEEDED(rc)) if(R_SUCCEEDED(rc))
{ {
fsDirClose(&fd); fsDirClose(&fd);
strncpy(__cwd, __fixedpath, PATH_MAX); strcpy(__cwd, __fixedpath);
fsdev_fsdevice_cwd = device->id; fsdev_fsdevice_cwd = device->id;
return 0; return 0;
} }

View File

@ -36,7 +36,7 @@ void fsldrExit(void) {
} }
Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out) { Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out) {
char send_path[FS_MAX_PATH] = {0}; char send_path[FS_MAX_PATH+1] = {0};
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
ipcAddSendStatic(&c, send_path, FS_MAX_PATH, 0); ipcAddSendStatic(&c, send_path, FS_MAX_PATH, 0);

View File

@ -144,7 +144,7 @@ static Result _lrResolvePath(Service* s, u64 cmd_id, u64 tid, char *out) {
This is a helper function to perform the work for those funcs, given a command ID. This is a helper function to perform the work for those funcs, given a command ID.
*/ */
static Result _lrRedirectPath(Service* s, u64 cmd_id, u64 tid, const char *path) { static Result _lrRedirectPath(Service* s, u64 cmd_id, u64 tid, const char *path) {
char send_path[FS_MAX_PATH] = {0}; char send_path[FS_MAX_PATH+1] = {0};
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
ipcAddSendStatic(&c, send_path, FS_MAX_PATH, 0); ipcAddSendStatic(&c, send_path, FS_MAX_PATH, 0);