From b04a448b627337b867a27c8b8f7f2d197f55d11c Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Tue, 10 May 2016 10:01:45 +0200
Subject: [PATCH] bugfix: calloc arguments' wrong order

---
 common/utils/T/tracer/gui/xy_plot.c     | 4 ++--
 common/utils/T/tracer/logger/framelog.c | 4 ++--
 common/utils/T/tracer/view/xy.c         | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/utils/T/tracer/gui/xy_plot.c b/common/utils/T/tracer/gui/xy_plot.c
index ca17fb4eab..4c1a9e1034 100644
--- a/common/utils/T/tracer/gui/xy_plot.c
+++ b/common/utils/T/tracer/gui/xy_plot.c
@@ -258,8 +258,8 @@ void xy_plot_set_points(gui *_gui, widget *_this, int plot,
   if (npoints != this->plots[plot].npoints) {
     free(this->plots[plot].x);
     free(this->plots[plot].y);
-    this->plots[plot].x = calloc(sizeof(float), npoints);
-    this->plots[plot].y = calloc(sizeof(float), npoints);
+    this->plots[plot].x = calloc(npoints, sizeof(float));
+    this->plots[plot].y = calloc(npoints, sizeof(float));
     this->plots[plot].npoints = npoints;
   }
 
diff --git a/common/utils/T/tracer/logger/framelog.c b/common/utils/T/tracer/logger/framelog.c
index 3a5f17e0bc..a52bbe7f48 100644
--- a/common/utils/T/tracer/logger/framelog.c
+++ b/common/utils/T/tracer/logger/framelog.c
@@ -39,9 +39,9 @@ static void _event(void *p, event e)
     l->blength = nsamples * 10;
     free(l->x);
     free(l->buffer);
-    l->x = calloc(sizeof(float), l->blength);
+    l->x = calloc(l->blength, sizeof(float));
     if (l->x == NULL) abort();
-    l->buffer = calloc(sizeof(float), l->blength);
+    l->buffer = calloc(l->blength, sizeof(float));
     if (l->buffer == NULL) abort();
     /* update 'x' */
     for (i = 0; i < l->blength; i++)
diff --git a/common/utils/T/tracer/view/xy.c b/common/utils/T/tracer/view/xy.c
index b027472a73..1407a16a0e 100644
--- a/common/utils/T/tracer/view/xy.c
+++ b/common/utils/T/tracer/view/xy.c
@@ -74,8 +74,8 @@ static void set(view *_this, char *name, ...)
     free(this->x);
     free(this->y);
     this->length = va_arg(ap, int);
-    this->x = calloc(sizeof(float), this->length); if (this->x==NULL)abort();
-    this->y = calloc(sizeof(float), this->length); if (this->y==NULL)abort();
+    this->x = calloc(this->length, sizeof(float)); if (this->x==NULL)abort();
+    this->y = calloc(this->length, sizeof(float)); if (this->y==NULL)abort();
     this->insert_point = 0;
 
     va_end(ap);
@@ -104,8 +104,8 @@ view *new_view_xy(int length, float refresh_rate, gui *g, widget *w,
   ret->plot = xy_plot_new_plot(g, w, color);
 
   ret->length = length;
-  ret->x = calloc(sizeof(float), length); if (ret->x == NULL) abort();
-  ret->y = calloc(sizeof(float), length); if (ret->y == NULL) abort();
+  ret->x = calloc(length, sizeof(float)); if (ret->x == NULL) abort();
+  ret->y = calloc(length, sizeof(float)); if (ret->y == NULL) abort();
   ret->insert_point = 0;
 
   if (pthread_mutex_init(&ret->lock, NULL)) abort();
-- 
GitLab