From: Aschref Ben Thabet <aschref.ben-tha...@embedded-brains.de> Using FILENAME_MAX as a parameter in strncpy function can gererate warnings of type: -Wstringop-truncation. Replacing it with sizeof (distination_buffer) can avoid this warning. --- cpukit/libmisc/shell/main_edit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c index 6e88916ad0..feefd6bff1 100644 --- a/cpukit/libmisc/shell/main_edit.c +++ b/cpukit/libmisc/shell/main_edit.c @@ -286,7 +286,7 @@ static struct editor *find_editor(struct env *env, char *filename) { struct editor *ed = env->current; struct editor *start = ed; - if (!realpath(filename, fn)) memcpy(fn, filename, FILENAME_MAX); + if (!realpath(filename, fn)) strncpy(fn, filename, sizeof(fn)-1); do { if (strcmp(fn, ed->filename) == 0) return ed; @@ -297,8 +297,9 @@ static struct editor *find_editor(struct env *env, char *filename) { static int new_file(struct editor *ed, char *filename) { if (*filename) { - memcpy(ed->filename, filename, FILENAME_MAX); - } else { + strncpy(ed->filename, filename, sizeof(ed->filename)-1); + } + else { sprintf(ed->filename, "Untitled-%d", ++ed->env->untitled); ed->newfile = 1; } @@ -1775,8 +1776,8 @@ static void save_editor(struct editor *ed) { return; } } - memcpy( - ed->filename, (const char*) ed->env->linebuf, FILENAME_MAX); + strncpy( + ed->filename, (const char*)ed->env->linebuf, sizeof(ed->filename)-1); ed->newfile = 0; } -- 2.26.2 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel