This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix Werror=stringop-overflow in target.c


Hello.

This is fix of compilation error I see with --enable-offload-targets=nvptx-none=. It's explained
in very detail way here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83007#c1

Ready for trunk?
Martin

libgomp/ChangeLog:

2017-11-20  Martin Liska  <mliska@suse.cz>

	* target.c (gomp_target_init): Use proper string operation.
---
 libgomp/target.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)


diff --git a/libgomp/target.c b/libgomp/target.c
index 8ac05e8c641..4838dc98de6 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -2668,7 +2668,10 @@ gomp_target_init (void)
 	  }
 
 	strcpy (plugin_name, prefix);
-	strncat (plugin_name, cur, next ? next - cur : strlen (cur));
+	if (next)
+	  strncat (plugin_name, cur, next - cur);
+	else
+	  strcpy (plugin_name, cur);
 	strcat (plugin_name, suffix);
 
 	if (gomp_load_plugin_for_device (&current_device, plugin_name))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]