Parcourir la source

when possible, use sizeof instead of a hard-coded value for a string length

Nathalie Furmento il y a 7 ans
Parent
commit
ef395f6e4b

+ 6 - 7
doc/doxygen/chapters/code/disk_compute.c

@@ -37,7 +37,7 @@ int main(int argc, char **argv)
 	/* Initialize path and name */
 	char pid_str[16];
 	int pid = getpid();
-	snprintf(pid_str, 16, "%d", pid);
+	snprintf(pid_str, sizeof(pid_str), "%d", pid);
 
 	const char *name_file_start = "STARPU_DISK_COMPUTE_DATA_";
 	const char *name_file_end = "STARPU_DISK_COMPUTE_DATA_RESULT_";
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
 	int new_dd = starpu_disk_register(&starpu_disk_unistd_ops, (void *) base, 1024*1024*1);
 	/* can't write on /tmp/ */
 	if (new_dd == -ENOENT) goto enoent;
-	
+
 	unsigned dd = (unsigned) new_dd;
 
 	printf("TEST DISK MEMORY \n");
@@ -67,7 +67,7 @@ int main(int argc, char **argv)
 
 	starpu_malloc_flags((void **)&A, NX*sizeof(int), STARPU_MALLOC_COUNT);
 	starpu_malloc_flags((void **)&C, NX*sizeof(int), STARPU_MALLOC_COUNT);
- 
+
 	unsigned int j;
 	/* you register them in a vector */
 	for(j = 0; j < NX; ++j)
@@ -112,8 +112,8 @@ int main(int argc, char **argv)
 	/* register vector in starpu */
 	starpu_vector_data_register(&vector_handleA, dd, (uintptr_t) data, NX, sizeof(int));
 
-	/* and do what you want with it, here we copy it into an other vector */ 
-	starpu_vector_data_register(&vector_handleC, dd, (uintptr_t) data_result, NX, sizeof(int));	
+	/* and do what you want with it, here we copy it into an other vector */
+	starpu_vector_data_register(&vector_handleC, dd, (uintptr_t) data_result, NX, sizeof(int));
 
 	starpu_data_cpy(vector_handleC, vector_handleA, 0, NULL, NULL);
 
@@ -125,7 +125,7 @@ int main(int argc, char **argv)
 	starpu_disk_close(dd, data, NX*sizeof(int));
 	starpu_disk_close(dd, data_result, NX*sizeof(int));
 
-	/* check results */	
+	/* check results */
 	f = fopen(path_file_end, "rb+");
 	if (f == NULL)
 		goto enoent;
@@ -177,4 +177,3 @@ enoent:
 	return 77;
 }
 //! [To be included. You should update doxygen if you see this text.]
-

+ 8 - 8
examples/heat/dw_factolu_kernels.c

@@ -64,8 +64,8 @@ void display_stat_heat(void)
 	{
 		if (count_total_per_worker[worker])
 		{
-			char name[32];
-			starpu_worker_get_name(worker, name, 32);
+			char name[64];
+			starpu_worker_get_name(worker, name, sizeof(name));
 
 			FPRINTF(stderr, "\t\t%s -> %u / %u (%2.2f %%)\n", name, count_11_per_worker[worker], count_11_total, (100.0*count_11_per_worker[worker])/count_11_total);
 		}
@@ -76,8 +76,8 @@ void display_stat_heat(void)
 	{
 		if (count_total_per_worker[worker])
 		{
-			char name[32];
-			starpu_worker_get_name(worker, name, 32);
+			char name[64];
+			starpu_worker_get_name(worker, name, sizeof(name));
 
 			FPRINTF(stderr, "\t\t%s -> %u / %u (%2.2f %%)\n", name, count_12_per_worker[worker], count_12_total, (100.0*count_12_per_worker[worker])/count_12_total);
 		}
@@ -89,8 +89,8 @@ void display_stat_heat(void)
 	{
 		if (count_total_per_worker[worker])
 		{
-			char name[32];
-			starpu_worker_get_name(worker, name, 32);
+			char name[64];
+			starpu_worker_get_name(worker, name, sizeof(name));
 
 			FPRINTF(stderr, "\t\t%s -> %u / %u (%2.2f %%)\n", name, count_21_per_worker[worker], count_21_total, (100.0*count_21_per_worker[worker])/count_21_total);
 		}
@@ -101,8 +101,8 @@ void display_stat_heat(void)
 	{
 		if (count_total_per_worker[worker])
 		{
-			char name[32];
-			starpu_worker_get_name(worker, name, 32);
+			char name[64];
+			starpu_worker_get_name(worker, name, sizeof(name));
 
 			FPRINTF(stderr, "\t\t%s -> %u / %u (%2.2f %%)\n", name, count_22_per_worker[worker], count_22_total, (100.0*count_22_per_worker[worker])/count_22_total);
 		}

+ 3 - 3
examples/ppm_downscaler/yuv_downscaler.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2011, 2013-2015, 2017  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -48,8 +48,8 @@ void parse_args(int argc, char **argv)
 	}
 	else
 	{
-		snprintf(filename_in, 1024, "%s/examples/ppm_downscaler/%s", STARPU_BUILD_DIR, filename_in_default);
-		snprintf(filename_out, 1024, "%s/examples/ppm_downscaler/%s", STARPU_BUILD_DIR, filename_out_default);
+		snprintf(filename_in, sizeof(filename_in), "%s/examples/ppm_downscaler/%s", STARPU_BUILD_DIR, filename_in_default);
+		snprintf(filename_out, sizeof(filename_out), "%s/examples/ppm_downscaler/%s", STARPU_BUILD_DIR, filename_out_default);
 	}
 }
 

+ 2 - 2
examples/stencil/implicit-stencil.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  * Copyright (C) 2010-2012, 2014  Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -184,7 +184,7 @@ void f(unsigned task_per_worker[STARPU_NMAXWORKERS])
 	{
 		if (task_per_worker[worker])
 		{
-			char name[32];
+			char name[64];
 			starpu_worker_get_name(worker, name, sizeof(name));
 			FPRINTF(stderr,"\t%s -> %u (%2.2f%%)\n", name, task_per_worker[worker], (100.0*task_per_worker[worker])/total);
 		}

+ 2 - 2
examples/stencil/stencil.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  * Copyright (C) 2010-2012, 2014, 2017  Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -179,7 +179,7 @@ void f(unsigned task_per_worker[STARPU_NMAXWORKERS])
 	{
 		if (task_per_worker[worker])
 		{
-			char name[32];
+			char name[64];
 			starpu_worker_get_name(worker, name, sizeof(name));
 			FPRINTF(stderr,"\t%s -> %u (%2.2f%%)\n", name, task_per_worker[worker], (100.0*task_per_worker[worker])/total);
 		}

+ 2 - 2
src/common/fxt.c

@@ -85,14 +85,14 @@ static void _starpu_profile_set_tracefile(void)
 	if (!fxt_prefix)
 	     fxt_prefix = "/tmp/";
 
-	snprintf(_STARPU_PROF_FILE_USER, 128, "%s", fxt_prefix);
+	snprintf(_STARPU_PROF_FILE_USER, sizeof(_STARPU_PROF_FILE_USER), "%s", fxt_prefix);
 
 	user = starpu_getenv("USER");
 	if (!user)
 		user = "";
 
 	char suffix[128];
-	snprintf(suffix, 128, "prof_file_%s_%d", user, _starpu_id);
+	snprintf(suffix, sizeof(suffix), "prof_file_%s_%d", user, _starpu_id);
 
 	strcat(_STARPU_PROF_FILE_USER, suffix);
 }

+ 5 - 5
src/core/debug.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2013, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011  CNRS
+ * Copyright (C) 2010, 2011, 2017  CNRS
  * Copyright (C) 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -143,7 +143,7 @@
 		ayu_wipe_data(&__data); \
 		\
 		char __buf[32]; \
-		snprintf(__buf, 32, "%llu", (unsigned long long)(uintptr_t) (handle)); \
+		snprintf(__buf, sizeof(__buf), "%llu", (unsigned long long)(uintptr_t) (handle)); \
 		__data.common.client_id = __cli_id; \
 		__data.set_property.property_owner_id = __dep_id; \
 		__data.set_property.key = "dep_address_value"; \
@@ -180,7 +180,7 @@
 		if ((task) != NULL) \
 		{ \
 			char __buf[32]; \
-			snprintf(__buf, 32, "%d", ((struct starpu_task *)(task))->priority); \
+			snprintf(__buf, sizeof(__buf), "%d", ((struct starpu_task *)(task))->priority); \
 			__data.common.client_id = __cli_id; \
 			__data.set_property.property_owner_id = (job_id); \
 			__data.set_property.key = "priority"; \
@@ -212,7 +212,7 @@
 		ayu_wipe_data(&__data); \
 		\
 		char __buf[32]; \
-		snprintf(__buf, 32, "%d", (workerid)); \
+		snprintf(__buf, sizeof(__buf), "%d", (workerid));	\
 		__data.common.client_id = __cli_id; \
 		__data.set_property.property_owner_id = (job_id); \
 		__data.set_property.key = "worker"; \
@@ -260,7 +260,7 @@
 		ayu_wipe_data(&__data); \
 		\
 		char __buf[32]; \
-		snprintf(__buf, 32, "%d", (int)(worker_id)); \
+		snprintf(__buf, sizeof(__buf), "%d", (int)(worker_id));	\
 		__data.common.client_id = __cli_id; \
 		__data.set_property.property_owner_id = (job_id); \
 		__data.set_property.key = "worker"; \

+ 2 - 2
src/core/perfmodel/multiple_regression.c

@@ -270,11 +270,11 @@ int _starpu_multiple_regression(struct starpu_perfmodel_history_list *ptr, doubl
 	FILE *f=NULL;
 
 	char directory[300];
-	snprintf(directory, 300, "%s/.starpu/sampling/codelets/tmp", _starpu_get_home_path());
+	snprintf(directory, sizeof(directory), "%s/.starpu/sampling/codelets/tmp", _starpu_get_home_path());
 	_starpu_mkpath_and_check(directory, S_IRWXU);
 
 	char filepath[300];
-	snprintf(filepath, 300, "%s/%s.out", directory,codelet_name);
+	snprintf(filepath, sizeof(filepath), "%s/%s.out", directory,codelet_name);
 
 	long old_lines=0;
 	int calibrate = _starpu_get_calibrate_flag();

+ 45 - 44
src/debug/traces/starpu_fxt.c

@@ -629,7 +629,7 @@ static void register_user_thread(double timestamp, unsigned long tid, const char
 		char new_thread_container_alias[STARPU_POTI_STR_LEN];
 		thread_container_alias (new_thread_container_alias, STARPU_POTI_STR_LEN, prefix, tid);
 		char new_thread_container_name[STARPU_POTI_STR_LEN];
-		snprintf(new_thread_container_name, STARPU_POTI_STR_LEN, "%sUserThread%lu", prefix, tid);
+		snprintf(new_thread_container_name, sizeof(new_thread_container_name), "%sUserThread%lu", prefix, tid);
 		poti_CreateContainer(timestamp, new_thread_container_alias, "UT", program_container, new_thread_container_alias);
 #else
 		fprintf(out_paje_file, "7	%.9f	%st%lu	UT	%sp	%sUserThread%lu\n",
@@ -866,17 +866,17 @@ static void worker_set_detailed_state(double time, const char *prefix, long unsi
 	char X_str[STARPU_POTI_STR_LEN], Y_str[STARPU_POTI_STR_LEN], Z_str[STARPU_POTI_STR_LEN];
 	char iteration_str[STARPU_POTI_STR_LEN], subiteration_str[STARPU_POTI_STR_LEN];
 
-	snprintf(size_str, STARPU_POTI_STR_LEN, "%lu", size);
-	snprintf(parameters_str, STARPU_POTI_STR_LEN, "%s", parameters);
-	snprintf(footprint_str, STARPU_POTI_STR_LEN, "%08lx", footprint);
-	snprintf(tag_str, STARPU_POTI_STR_LEN, "%016llx", tag);
-	snprintf(jobid_str, STARPU_POTI_STR_LEN, "%s%lu", prefix, job_id);
-	snprintf(gflop_str, STARPU_POTI_STR_LEN, "%f", gflop);
-	snprintf(X_str, STARPU_POTI_STR_LEN, "%u", X);
-	snprintf(Y_str, STARPU_POTI_STR_LEN, "%u", Y);
-	snprintf(Z_str, STARPU_POTI_STR_LEN, "%u", Z);
-	snprintf(iteration_str, STARPU_POTI_STR_LEN, "%ld", iteration);
-	snprintf(subiteration_str, STARPU_POTI_STR_LEN, "%ld", subiteration);
+	snprintf(size_str, sizeof(size_str), "%lu", size);
+	snprintf(parameters_str, sizeof(parameters_str), "%s", parameters);
+	snprintf(footprint_str, sizeof(footprint_str), "%08lx", footprint);
+	snprintf(tag_str, sizeof(tag_str), "%016llx", tag);
+	snprintf(jobid_str, sizeof(jobid_str), "%s%lu", prefix, job_id);
+	snprintf(gflop_str, sizeof(gflop_str), "%f", gflop);
+	snprintf(X_str, sizeof(X_str), "%u", X);
+	snprintf(Y_str, sizeof(Y_str), "%u", Y);
+	snprintf(Z_str, sizeof(Z_str), "%u", Z);
+	snprintf(iteration_str, sizeof(iteration_str), "%ld", iteration);
+	snprintf(subiteration_str, sizeof(subiteration_str), "%ld", subiteration);
 
 #ifdef HAVE_POTI_INIT_CUSTOM
 	poti_user_SetState(_starpu_poti_extendedSetState, time, container, "WS", name, 11, size_str,
@@ -1044,12 +1044,12 @@ static void handle_new_mem_node(struct fxt_ev_64 *ev, struct starpu_fxt_options
 		char new_memmanager_container_alias[STARPU_POTI_STR_LEN], new_memmanager_container_name[STARPU_POTI_STR_LEN];
 		memnode_container_alias (new_memnode_container_alias, STARPU_POTI_STR_LEN, prefix, ev->param[0]);
 		/* TODO: ramkind */
-		snprintf(new_memnode_container_name, STARPU_POTI_STR_LEN, "%sMEMNODE%"PRIu64"", prefix, ev->param[0]);
+		snprintf(new_memnode_container_name, sizeof(new_memnode_container_name), "%sMEMNODE%"PRIu64"", prefix, ev->param[0]);
 		poti_CreateContainer(now, new_memnode_container_alias, "Mn", program_container, new_memnode_container_name);
 
 		memmanager_container_alias (new_memmanager_container_alias, STARPU_POTI_STR_LEN, prefix, ev->param[0]);
 		/* TODO: ramkind */
-		snprintf(new_memmanager_container_name, STARPU_POTI_STR_LEN, "%sMEMMANAGER%"PRIu64"", prefix, ev->param[0]);
+		snprintf(new_memmanager_container_name, sizeof(new_memmanager_container_name), "%sMEMMANAGER%"PRIu64"", prefix, ev->param[0]);
 		poti_CreateContainer(now, new_memmanager_container_alias, "Mm", new_memnode_container_alias, new_memmanager_container_name);
 #else
 		fprintf(out_paje_file, "7	%.9f	%smn%"PRIu64"	Mn	%sp	%sMEMNODE%"PRIu64"\n", now, prefix, ev->param[0], prefix, options->file_prefix, ev->param[0]);
@@ -1167,12 +1167,12 @@ static void handle_worker_init_start(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 		{
 			// If CUDA, workers might be streams, so create an unique name for each of them
 			int streamid = create_ordered_stream_id (prefixTOnodeid(prefix), devid);
-			snprintf(new_worker_container_name, STARPU_TRACE_STR_LEN, "%s%s%d_%d", prefix, kindstr, devid, streamid);
+			snprintf(new_worker_container_name, sizeof(new_worker_container_name), "%s%s%d_%d", prefix, kindstr, devid, streamid);
 		}
 		else
 		{
 			// If not CUDA, we suppose worker name is the prefix, the kindstr, and the devid
-			snprintf(new_worker_container_name, STARPU_TRACE_STR_LEN, "%s%s%d", prefix, kindstr, devid);
+			snprintf(new_worker_container_name, sizeof(new_worker_container_name), "%s%s%d", prefix, kindstr, devid);
 		}
 #ifdef STARPU_HAVE_POTI
 		char new_thread_container_alias[STARPU_POTI_STR_LEN];
@@ -1182,7 +1182,7 @@ static void handle_worker_init_start(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 		char memnode_container[STARPU_POTI_STR_LEN];
 		memnode_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, nodeid);
 		char new_thread_container_name[STARPU_POTI_STR_LEN];
-		snprintf(new_thread_container_name, STARPU_POTI_STR_LEN, "%sT%d", prefix, bindid);
+		snprintf(new_thread_container_name, sizeof(new_thread_container_name), "%sT%d", prefix, bindid);
 		if (new_thread)
 			poti_CreateContainer(now, new_thread_container_alias, "T", memnode_container, new_thread_container_name);
 		poti_CreateContainer(now, new_worker_container_alias, "W", new_thread_container_alias, new_worker_container_name);
@@ -1277,7 +1277,7 @@ static void handle_worker_deinit_end(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 static void create_paje_state_color(char *name, char *type, float red, float green, float blue)
 {
 	char color[STARPU_POTI_STR_LEN];
-	snprintf(color, STARPU_POTI_STR_LEN, "%f %f %f", red, green, blue);
+	snprintf(color, sizeof(color), "%f %f %f", red, green, blue);
 	poti_DefineEntityValue(name, type, name, color);
 }
 #endif
@@ -1583,22 +1583,23 @@ static void handle_codelet_details(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 #ifdef STARPU_HAVE_POTI
 			char container[STARPU_POTI_STR_LEN];
 			char typectx[STARPU_POTI_STR_LEN];
-			snprintf(typectx, STARPU_POTI_STR_LEN, "Ctx%u", sched_ctx);
-			worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, worker);
+			snprintf(typectx, sizeof(typectx), "Ctx%u", sched_ctx);
+			worker_container_alias(container, sizeof(container), prefix, worker);
 			poti_SetState(last_codelet_start[worker], container, typectx, _starpu_last_codelet_symbol[worker]);
+
 			char name[STARPU_POTI_STR_LEN];
-			snprintf(name, STARPU_POTI_STR_LEN, "%s", _starpu_last_codelet_symbol[worker]);
+			snprintf(name, sizeof(name), "%s", _starpu_last_codelet_symbol[worker]);
+
 			char size_str[STARPU_POTI_STR_LEN];
 			char parameters_str[STARPU_POTI_STR_LEN];
 			char footprint_str[STARPU_POTI_STR_LEN];
 			char tag_str[STARPU_POTI_STR_LEN];
 			char jobid_str[STARPU_POTI_STR_LEN];
-
-			snprintf(size_str, STARPU_POTI_STR_LEN, "%ld", ev->param[1]);
-			snprintf(parameters_str, STARPU_POTI_STR_LEN, "%s", parameters);
-			snprintf(footprint_str, STARPU_POTI_STR_LEN, "%08lx", ev->param[2]);
-			snprintf(tag_str, STARPU_POTI_STR_LEN, "%016lx", ev->param[4]);
-			snprintf(jobid_str, STARPU_POTI_STR_LEN, "%s%lu", prefix, job_id);
+			snprintf(size_str, sizeof(size_str), "%ld", ev->param[1]);
+			snprintf(parameters_str, sizeof(parameters_str), "%s", parameters);
+			snprintf(footprint_str, sizeof(footprint_str), "%08lx", ev->param[2]);
+			snprintf(tag_str, sizeof(tag_str), "%016lx", ev->param[4]);
+			snprintf(jobid_str, sizeof(jobid_str), "%s%lu", prefix, job_id);
 
 #ifdef HAVE_POTI_INIT_CUSTOM
 			poti_user_SetState(_starpu_poti_semiExtendedSetState, last_codelet_start[worker], container, typectx, name, 5, size_str,
@@ -1752,7 +1753,7 @@ static void handle_user_event(struct fxt_ev_64 *ev, struct starpu_fxt_options *o
 	unsigned long code = ev->param[0];
 #ifdef STARPU_HAVE_POTI
 	char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
-	snprintf(paje_value, STARPU_POTI_STR_LEN, "%lu", code);
+	snprintf(paje_value, sizeof(paje_value), "%lu", code);
 #endif
 
 	char *prefix = options->file_prefix;
@@ -2015,7 +2016,7 @@ static void handle_data_register(struct fxt_ev_64 *ev, struct starpu_fxt_options
 	{
 #ifdef STARPU_HAVE_POTI
 		char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
-		snprintf(paje_value, STARPU_POTI_STR_LEN, "%lx", handle);
+		snprintf(paje_value, sizeof(paje_value), "%lx", handle);
 		program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
 		poti_NewEvent(get_event_time_stamp(ev, options), container, "register", paje_value);
 #else
@@ -2034,7 +2035,7 @@ static void handle_data_unregister(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 	{
 #ifdef STARPU_HAVE_POTI
 		char paje_value[STARPU_POTI_STR_LEN], container[STARPU_POTI_STR_LEN];
-		snprintf(paje_value, STARPU_POTI_STR_LEN, "%lx", handle);
+		snprintf(paje_value, sizeof(paje_value), "%lx", handle);
 		program_container_alias (container, STARPU_POTI_STR_LEN, prefix);
 		poti_NewEvent(get_event_time_stamp(ev, options), container, "unregister", paje_value);
 #else
@@ -2056,7 +2057,7 @@ static void handle_data_invalidate(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 #ifdef STARPU_HAVE_POTI
 		char paje_value[STARPU_POTI_STR_LEN], memnode_container[STARPU_POTI_STR_LEN];
 		memmanager_container_alias(memnode_container, STARPU_POTI_STR_LEN, prefix, node);
-		snprintf(paje_value, STARPU_POTI_STR_LEN, "%lx", handle);
+		snprintf(paje_value, sizeof(paje_value), "%lx", handle);
 		poti_NewEvent(get_event_time_stamp(ev, options), memnode_container, "invalidate", paje_value);
 #else
 		fprintf(out_paje_file, "9	%.9f	invalidate	%smm%u	%lx\n", get_event_time_stamp(ev, options), prefix, node, handle);
@@ -2130,8 +2131,8 @@ static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 #ifdef STARPU_HAVE_POTI
 			char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_memnode_container[STARPU_POTI_STR_LEN];
 			char program_container[STARPU_POTI_STR_LEN];
-			snprintf(paje_value, STARPU_POTI_STR_LEN, "%u", size);
-			snprintf(paje_key, STARPU_POTI_STR_LEN, "com_%u", comid);
+			snprintf(paje_value, sizeof(paje_value), "%u", size);
+			snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
 			program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
 			memmanager_container_alias(src_memnode_container, STARPU_POTI_STR_LEN, prefix, src);
 			poti_StartLink(time, program_container, link_type, src_memnode_container, paje_value, paje_key);
@@ -2169,8 +2170,8 @@ static void handle_work_stealing(struct fxt_ev_64 *ev, struct starpu_fxt_options
 		char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_worker_container[STARPU_POTI_STR_LEN], dst_worker_container[STARPU_POTI_STR_LEN];
 		char program_container[STARPU_POTI_STR_LEN];
 
-		snprintf(paje_value, STARPU_POTI_STR_LEN, "%u", size);
-		snprintf(paje_key, STARPU_POTI_STR_LEN, "steal_%u", steal_number);
+		snprintf(paje_value, sizeof(paje_value), "%u", size);
+		snprintf(paje_key, sizeof(paje_key), "steal_%u", steal_number);
 		program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
 		worker_container_alias(src_worker_container, STARPU_POTI_STR_LEN, prefix, src);
 		worker_container_alias(dst_worker_container, STARPU_POTI_STR_LEN, prefix, dst);
@@ -2240,8 +2241,8 @@ static void handle_end_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 #ifdef STARPU_HAVE_POTI
 			char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
 			char dst_memnode_container[STARPU_POTI_STR_LEN], program_container[STARPU_POTI_STR_LEN];
-			snprintf(paje_value, STARPU_POTI_STR_LEN, "%u", size);
-			snprintf(paje_key, STARPU_POTI_STR_LEN, "com_%u", comid);
+			snprintf(paje_value, sizeof(paje_value), "%u", size);
+			snprintf(paje_key, sizeof(paje_key), "com_%u", comid);
 			program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);
 			memmanager_container_alias(dst_memnode_container, STARPU_POTI_STR_LEN, prefix, dst);
 			poti_EndLink(time, program_container, link_type, dst_memnode_container, paje_value, paje_key);
@@ -2553,7 +2554,7 @@ static void handle_task_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *op
 	char buffer[32];
 	if (options->per_task_colour)
 	{
-		snprintf(buffer, 32, "#%x%x%x",
+		snprintf(buffer, sizeof(buffer), "#%x%x%x",
 			 get_colour_symbol_red(name)/4,
 			 get_colour_symbol_green(name)/4,
 			 get_colour_symbol_blue(name)/4);
@@ -2591,7 +2592,7 @@ static void handle_tag_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *opt
 	char buffer[32];
 	if (options->per_task_colour)
 	{
-		snprintf(buffer, 32, "%.4f,%.4f,%.4f",
+		snprintf(buffer, sizeof(buffer), "%.4f,%.4f,%.4f",
 			 get_colour_symbol_red(name)/1024.0,
 			 get_colour_symbol_green(name)/1024.0,
 			 get_colour_symbol_blue(name)/1024.0);
@@ -2616,8 +2617,8 @@ static void handle_mpi_barrier(struct fxt_ev_64 *ev, struct starpu_fxt_options *
 	{
 #ifdef STARPU_HAVE_POTI
 		char container[STARPU_POTI_STR_LEN], paje_value[STARPU_POTI_STR_LEN];
-		snprintf(container, STARPU_POTI_STR_LEN, "%sp", options->file_prefix);
-		snprintf(paje_value, STARPU_POTI_STR_LEN, "%d", rank);
+		snprintf(container, sizeof(container), "%sp", options->file_prefix);
+		snprintf(paje_value, sizeof(paje_value), "%d", rank);
 		poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", paje_value);
 #else
 		fprintf(out_paje_file, "9	%.9f	prog_event	%sp	%d\n", get_event_time_stamp(ev, options), options->file_prefix, rank);
@@ -2932,7 +2933,7 @@ static void handle_string_event(struct fxt_ev_64 *ev, const char *event, struct
 	{
 #ifdef STARPU_HAVE_POTI
 		char container[STARPU_POTI_STR_LEN];
-		snprintf(container, STARPU_POTI_STR_LEN, "%sp", options->file_prefix);
+		snprintf(container, sizeof(container), "%sp", options->file_prefix);
 		poti_NewEvent(get_event_time_stamp(ev, options), container, "prog_event", event);
 #else
 		fprintf(out_paje_file, "9	%.9f	prog_event	%sp	%s\n", get_event_time_stamp(ev, options), options->file_prefix, event);
@@ -3074,11 +3075,11 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 #ifdef STARPU_HAVE_POTI
 		char new_program_container_alias[STARPU_POTI_STR_LEN], new_program_container_name[STARPU_POTI_STR_LEN];
 		program_container_alias(new_program_container_alias, STARPU_POTI_STR_LEN, prefix);
-		snprintf(new_program_container_name, STARPU_POTI_STR_LEN, "program %s", prefix);
+		snprintf(new_program_container_name, sizeof(new_program_container_name), "program %s", prefix);
 		poti_CreateContainer (0, new_program_container_alias, "P", "MPIroot", new_program_container_name);
 		char new_scheduler_container_alias[STARPU_POTI_STR_LEN], new_scheduler_container_name[STARPU_POTI_STR_LEN];
 		scheduler_container_alias(new_scheduler_container_alias, STARPU_POTI_STR_LEN, prefix);
-		snprintf(new_scheduler_container_name, STARPU_POTI_STR_LEN, "%sscheduler", prefix);
+		snprintf(new_scheduler_container_name, sizeof(new_scheduler_container_name), "%sscheduler", prefix);
 		if (!options->no_counter || !options->no_flops)
 		{
 			poti_CreateContainer(0.0, new_scheduler_container_alias, "Sc", new_program_container_alias, new_scheduler_container_name);

+ 2 - 2
src/debug/traces/starpu_fxt_mpi.c

@@ -318,8 +318,8 @@ static void display_all_transfers_from_trace(FILE *out_paje_file, unsigned n)
 				_starpu_fxt_dag_add_receive(dst, match->jobid, mpi_tag, id);
 #ifdef STARPU_HAVE_POTI
 			char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN];
-			snprintf(paje_value, STARPU_POTI_STR_LEN, "%lu", (long unsigned) size);
-			snprintf(paje_key, STARPU_POTI_STR_LEN, "mpicom_%lu", id);
+			snprintf(paje_value, sizeof(paje_value), "%lu", (long unsigned) size);
+			snprintf(paje_key, sizeof(paje_key), "mpicom_%lu", id);
 			snprintf(mpi_container, sizeof(mpi_container), "%d_mpict", src);
 			poti_StartLink(start_date, "MPIroot", "MPIL", mpi_container, paje_value, paje_key);
 			poti_SetVariable(start_date, mpi_container, "bwo_mpi", current_out_bandwidth[src]);

+ 1 - 1
src/top/starpu_top.c

@@ -133,7 +133,7 @@ static void starpu_top_send_devices_info(void)
 		char dev_type[10];
 		char dev_name[64];
 		starpu_top_get_device_type(i,dev_type);
-		starpu_worker_get_name(i, dev_name,64);
+		starpu_worker_get_name(i, dev_name,sizeof(dev_name));
 		snprintf(message, 128, "%u;%s;%s\n", i, dev_type, dev_name);
 		_starpu_top_message_add(_starpu_top_mt,message);
 	}

+ 9 - 9
src/top/starpu_top_task.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony Roy
- * Copyright (C) 2011, 2013, 2016 CNRS
+ * Copyright (C) 2011, 2013, 2016, 2017 CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -37,10 +37,10 @@ void _starpu_top_task_started(struct starpu_task *task,
 	char *str;
 	_STARPU_MALLOC(str, sizeof(char)*64);
 	snprintf(str, 64,
-				"START;%llu;%d;%llu\n",
-				taskid,
-				devid,
-				_starpu_top_timing_timespec_to_ms(ts));
+		 "START;%llu;%d;%llu\n",
+		 taskid,
+		 devid,
+		 _starpu_top_timing_timespec_to_ms(ts));
 
 	_starpu_top_message_add(_starpu_top_mt, str);
 }
@@ -55,9 +55,9 @@ void _starpu_top_task_ended(struct starpu_task *task,
 	char *str;
 	_STARPU_MALLOC(str, sizeof(char)*64);
 	snprintf(str, 64,
-				"END;%llu;%llu\n",
-				taskid,
-				_starpu_top_timing_timespec_to_ms(ts));
+		 "END;%llu;%llu\n",
+		 taskid,
+		 _starpu_top_timing_timespec_to_ms(ts));
 
 	_starpu_top_message_add(_starpu_top_mt, str);
 }
@@ -87,7 +87,7 @@ void starpu_top_task_prevision(struct starpu_task *task,
 	_starpu_clock_gettime(&now);
 	char *str;
 	_STARPU_MALLOC(str, sizeof(char)*200);
-	snprintf(str, 128,
+	snprintf(str, 200,
 		 "PREV;%llu;%d;%llu;%llu;%llu\n",
 		 taskid,
 		 devid,

+ 1 - 1
tests/main/mkdtemp.c

@@ -35,7 +35,7 @@ int do_test(char *(*func)(char *tmpl))
 		path = starpu_getenv("TMP");
 	if (!path)
 		path = "/tmp";
-	snprintf(dirname, 128, "%s/abcdef_XXXXXX", path);
+	snprintf(dirname, sizeof(dirname), "%s/abcdef_XXXXXX", path);
 	ptr = func(dirname);
 	FPRINTF(stderr, "Directory '%s' (res '%s')\n", dirname, ptr);
 

+ 3 - 3
tests/microbenchs/async_tasks_overhead.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -162,12 +162,12 @@ int main(int argc, char **argv)
                         char file[1024];
                         FILE *f;
 
-                        snprintf(file, 1024, "%s/async_tasks_overhead_total.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/async_tasks_overhead_total.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/1000000);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/async_tasks_overhead_per_task.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/async_tasks_overhead_per_task.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/ntasks);
                         fclose(f);

+ 3 - 3
tests/microbenchs/sync_tasks_overhead.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -115,12 +115,12 @@ int main(int argc, char **argv)
                         char file[1024];
                         FILE *f;
 
-                        snprintf(file, 1024, "%s/sync_tasks_overhead_total.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/sync_tasks_overhead_total.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/1000000);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/sync_tasks_overhead_per_task.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/sync_tasks_overhead_per_task.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing/ntasks);
                         fclose(f);

+ 7 - 7
tests/microbenchs/tasks_overhead.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011, 2013-2014, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -190,32 +190,32 @@ int main(int argc, char **argv)
                         char file[1024];
                         FILE *f;
 
-                        snprintf(file, 1024, "%s/tasks_overhead_total_submit.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/tasks_overhead_total_submit.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing_submit/1000000);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/tasks_overhead_per_task_submit.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/tasks_overhead_per_task_submit.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing_submit/ntasks);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/tasks_overhead_total_execution.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/tasks_overhead_total_execution.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing_exec/1000000);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/tasks_overhead_per_task_execution.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/tasks_overhead_per_task_execution.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, timing_exec/ntasks);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/tasks_overhead_total_submit_execution.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/tasks_overhead_total_submit_execution.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, (timing_submit+timing_exec)/1000000);
                         fclose(f);
 
-                        snprintf(file, 1024, "%s/tasks_overhead_per_task_submit_execution.dat", output_dir);
+                        snprintf(file, sizeof(file), "%s/tasks_overhead_per_task_submit_execution.dat", output_dir);
                         f = fopen(file, "a");
                         fprintf(f, "%s\t%f\n", bench_id, (timing_submit+timing_exec)/ntasks);
                         fclose(f);

+ 2 - 2
tests/microbenchs/tasks_size_overhead.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014, 2016-2017  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -291,7 +291,7 @@ int main(int argc, char **argv)
 					char file[1024];
 					FILE *f;
 
-					snprintf(file, 1024, "%s/tasks_size_overhead_total%s%s.dat", output_dir, sched?"_":"", sched?sched:"");
+					snprintf(file, sizeof(file), "%s/tasks_size_overhead_total%s%s.dat", output_dir, sched?"_":"", sched?sched:"");
 					f = fopen(file, "a");
 					fprintf(f, "%s\t%u\t%u\t%f\n", bench_id, ncpus, size, timing/1000000 /(ntasks*ncpus) *1000);
 					fclose(f);

+ 2 - 2
tests/overlap/overlap.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2012, 2015-2016  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
 
 	starpu_data_partition(handle, &f);
 
-	snprintf(symbolname, 128, "overlap_sleep_%d_%u", VECTORSIZE, TASKDURATION);
+	snprintf(symbolname, sizeof(symbolname), "overlap_sleep_%d_%u", VECTORSIZE, TASKDURATION);
 
 	model.symbol = symbolname;
 

+ 1 - 1
tests/perfmodels/regression_based.c

@@ -132,7 +132,7 @@ static void show_task_perfs(int size, struct starpu_task *task)
 	unsigned workerid;
 	for (workerid = 0; workerid < starpu_worker_get_count(); workerid++)
 	{
-		char name[16];
+		char name[32];
 		starpu_worker_get_name(workerid, name, sizeof(name));
 
 		unsigned nimpl;

+ 3 - 3
tools/starpu_perfmodel_plot.c

@@ -501,7 +501,7 @@ int main(int argc, char **argv)
 			{
 				starpu_fxt_generate_trace(&options.fxt_options);
 
-				snprintf(options.data_file_name, 256, "starpu_%s.data", options.symbol);
+				snprintf(options.data_file_name, sizeof(options.data_file_name), "starpu_%s.data", options.symbol);
 
 				FILE *data_file = fopen(options.data_file_name, "w+");
 				STARPU_ASSERT(data_file);
@@ -510,8 +510,8 @@ int main(int argc, char **argv)
 			}
 #endif
 
-			snprintf(gnuplot_file_name, 256, "starpu_%s.gp", options.symbol);
-			snprintf(options.avg_file_name, 256, "starpu_%s_avg.data", options.symbol);
+			snprintf(gnuplot_file_name, sizeof(gnuplot_file_name), "starpu_%s.gp", options.symbol);
+			snprintf(options.avg_file_name, sizeof(options.avg_file_name), "starpu_%s_avg.data", options.symbol);
 
 			FILE *gnuplot_file = fopen(gnuplot_file_name, "w+");
 			STARPU_ASSERT(gnuplot_file);