Merge remote-tracking branch 'origin/release-4-6' into HEAD
[alexxy/gromacs.git] / src / gromacs / mdlib / gmx_wallcycle.c
index ee4961c768e8fddf542740ccb935c42395647542..230ead9eb47414763061f07ec5ee27e9bff88ad5 100644 (file)
@@ -44,6 +44,7 @@
 #include "smalloc.h"
 #include "gmx_fatal.h"
 #include "md_logging.h"
+#include "string2.h"
 
 #ifdef GMX_LIB_MPI
 #include <mpi.h>
@@ -517,11 +518,11 @@ static void print_cycles(FILE *fplog, double c2t, const char *name,
     {
         if (n > 0)
         {
-            sprintf(num,"%10d",n);
+            snprintf(num,sizeof(num),"%10d",n);
             if (nthreads < 0)
-                sprintf(thstr, "N/A");
+                snprintf(thstr, sizeof(thstr), "N/A");
             else
-                sprintf(thstr, "%4d", nthreads);
+                snprintf(thstr, sizeof(thstr), "%4d", nthreads);
         }
         else
         {
@@ -542,8 +543,8 @@ static void print_gputimes(FILE *fplog, const char *name,
 
     if (n > 0)
     {
-        sprintf(num, "%10d", n);
-        sprintf(avg_perf, "%10.3f", t/n);
+        snprintf(num, sizeof(num), "%10d", n);
+        snprintf(avg_perf, sizeof(avg_perf), "%10.3f", t/n);
     }
     else
     {
@@ -624,9 +625,9 @@ void wallcycle_print(FILE *fplog, int nnodes, int npme, double realtime,
         {
             for(j=0; j<ewcNR; j++)
             {
-                sprintf(buf,"%-9s",wcn[i]);
+                snprintf(buf,9,"%-9s",wcn[i]);
                 buf[9] = ' ';
-                sprintf(buf+10,"%-9s",wcn[j]);
+                snprintf(buf+10,9,"%-9s",wcn[j]);
                 buf[19] = '\0';
                 print_cycles(fplog,c2t,buf,nnodes,
                              is_pme_counter(i) ? npme : npp,