public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] calloc/xcalloc: fix argument order
@ 2014-12-06 11:40 Arjun Sreedharan
  2014-12-09 12:31 ` Arnaldo Carvalho de Melo
  2014-12-12  8:18 ` [tip:perf/urgent] calloc/xcalloc: Fix " tip-bot for Arjun Sreedharan
  0 siblings, 2 replies; 3+ messages in thread
From: Arjun Sreedharan @ 2014-12-06 11:40 UTC (permalink / raw)
  To: Yann E. MORIN
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, LKML

calloc() and xcalloc() takes @nmemb first and then @size.
fix all w/ pattern "calloc\s*(\s*sizeof".

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
---
 scripts/kconfig/mconf.c    | 4 ++--
 tools/perf/ui/hist.c       | 4 ++--
 tools/thermal/tmon/sysfs.c | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 14cea74..4dd3755 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -330,10 +330,10 @@ static void set_subtitle(void)
 	list_for_each_entry(sp, &trail, entries) {
 		if (sp->text) {
 			if (pos) {
-				pos->next = xcalloc(sizeof(*pos), 1);
+				pos->next = xcalloc(1, sizeof(*pos));
 				pos = pos->next;
 			} else {
-				subtitles = pos = xcalloc(sizeof(*pos), 1);
+				subtitles = pos = xcalloc(1, sizeof(*pos));
 			}
 			pos->text = sp->text;
 		}
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 2af1837..dc0d095 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -162,8 +162,8 @@ static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,
 		return ret;
 
 	nr_members = evsel->nr_members;
-	fields_a = calloc(sizeof(*fields_a), nr_members);
-	fields_b = calloc(sizeof(*fields_b), nr_members);
+	fields_a = calloc(nr_members, sizeof(*fields_a));
+	fields_b = calloc(nr_members, sizeof(*fields_b));
 
 	if (!fields_a || !fields_b)
 		goto out;
diff --git a/tools/thermal/tmon/sysfs.c b/tools/thermal/tmon/sysfs.c
index dfe4548..1c12536 100644
--- a/tools/thermal/tmon/sysfs.c
+++ b/tools/thermal/tmon/sysfs.c
@@ -446,7 +446,7 @@ int probe_thermal_sysfs(void)
 		return -1;
 	}
 
-	ptdata.tzi = calloc(sizeof(struct tz_info), ptdata.max_tz_instance+1);
+	ptdata.tzi = calloc(ptdata.max_tz_instance+1, sizeof(struct tz_info));
 	if (!ptdata.tzi) {
 		fprintf(stderr, "Err: allocate tz_info\n");
 		return -1;
@@ -454,8 +454,8 @@ int probe_thermal_sysfs(void)
 
 	/* we still show thermal zone information if there is no cdev */
 	if (ptdata.nr_cooling_dev) {
-		ptdata.cdi = calloc(sizeof(struct cdev_info),
-				ptdata.max_cdev_instance + 1);
+		ptdata.cdi = calloc(ptdata.max_cdev_instance + 1,
+				sizeof(struct cdev_info));
 		if (!ptdata.cdi) {
 			free(ptdata.tzi);
 			fprintf(stderr, "Err: allocate cdev_info\n");
-- 
1.8.1.msysgit.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] calloc/xcalloc: fix argument order
  2014-12-06 11:40 [PATCH] calloc/xcalloc: fix argument order Arjun Sreedharan
@ 2014-12-09 12:31 ` Arnaldo Carvalho de Melo
  2014-12-12  8:18 ` [tip:perf/urgent] calloc/xcalloc: Fix " tip-bot for Arjun Sreedharan
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-12-09 12:31 UTC (permalink / raw)
  To: Arjun Sreedharan
  Cc: Yann E. MORIN, Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML

Em Sat, Dec 06, 2014 at 05:10:43PM +0530, Arjun Sreedharan escreveu:
> calloc() and xcalloc() takes @nmemb first and then @size.
> fix all w/ pattern "calloc\s*(\s*sizeof".

Thanks, applied.
 
> Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
> ---
>  scripts/kconfig/mconf.c    | 4 ++--
>  tools/perf/ui/hist.c       | 4 ++--
>  tools/thermal/tmon/sysfs.c | 6 +++---
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
> index 14cea74..4dd3755 100644
> --- a/scripts/kconfig/mconf.c
> +++ b/scripts/kconfig/mconf.c
> @@ -330,10 +330,10 @@ static void set_subtitle(void)
>  	list_for_each_entry(sp, &trail, entries) {
>  		if (sp->text) {
>  			if (pos) {
> -				pos->next = xcalloc(sizeof(*pos), 1);
> +				pos->next = xcalloc(1, sizeof(*pos));
>  				pos = pos->next;
>  			} else {
> -				subtitles = pos = xcalloc(sizeof(*pos), 1);
> +				subtitles = pos = xcalloc(1, sizeof(*pos));
>  			}
>  			pos->text = sp->text;
>  		}
> diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> index 2af1837..dc0d095 100644
> --- a/tools/perf/ui/hist.c
> +++ b/tools/perf/ui/hist.c
> @@ -162,8 +162,8 @@ static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,
>  		return ret;
>  
>  	nr_members = evsel->nr_members;
> -	fields_a = calloc(sizeof(*fields_a), nr_members);
> -	fields_b = calloc(sizeof(*fields_b), nr_members);
> +	fields_a = calloc(nr_members, sizeof(*fields_a));
> +	fields_b = calloc(nr_members, sizeof(*fields_b));
>  
>  	if (!fields_a || !fields_b)
>  		goto out;
> diff --git a/tools/thermal/tmon/sysfs.c b/tools/thermal/tmon/sysfs.c
> index dfe4548..1c12536 100644
> --- a/tools/thermal/tmon/sysfs.c
> +++ b/tools/thermal/tmon/sysfs.c
> @@ -446,7 +446,7 @@ int probe_thermal_sysfs(void)
>  		return -1;
>  	}
>  
> -	ptdata.tzi = calloc(sizeof(struct tz_info), ptdata.max_tz_instance+1);
> +	ptdata.tzi = calloc(ptdata.max_tz_instance+1, sizeof(struct tz_info));
>  	if (!ptdata.tzi) {
>  		fprintf(stderr, "Err: allocate tz_info\n");
>  		return -1;
> @@ -454,8 +454,8 @@ int probe_thermal_sysfs(void)
>  
>  	/* we still show thermal zone information if there is no cdev */
>  	if (ptdata.nr_cooling_dev) {
> -		ptdata.cdi = calloc(sizeof(struct cdev_info),
> -				ptdata.max_cdev_instance + 1);
> +		ptdata.cdi = calloc(ptdata.max_cdev_instance + 1,
> +				sizeof(struct cdev_info));
>  		if (!ptdata.cdi) {
>  			free(ptdata.tzi);
>  			fprintf(stderr, "Err: allocate cdev_info\n");
> -- 
> 1.8.1.msysgit.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/urgent] calloc/xcalloc: Fix argument order
  2014-12-06 11:40 [PATCH] calloc/xcalloc: fix argument order Arjun Sreedharan
  2014-12-09 12:31 ` Arnaldo Carvalho de Melo
@ 2014-12-12  8:18 ` tip-bot for Arjun Sreedharan
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Arjun Sreedharan @ 2014-12-12  8:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: arjun024, linux-kernel, acme, paulus, a.p.zijlstra, tglx, hpa,
	mingo, mingo, yann.morin.1998

Commit-ID:  e4e458b45c5861808674eebfea94cee2258bb2ea
Gitweb:     http://git.kernel.org/tip/e4e458b45c5861808674eebfea94cee2258bb2ea
Author:     Arjun Sreedharan <arjun024@gmail.com>
AuthorDate: Sat, 6 Dec 2014 17:10:43 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 9 Dec 2014 10:06:29 -0300

calloc/xcalloc: Fix argument order

The calloc() and xcalloc() functions takes @nmemb first and then @size.  Fix all w/
pattern "calloc\s*(\s*sizeof".

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1417866043-1877-1-git-send-email-arjun024@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 scripts/kconfig/mconf.c    | 4 ++--
 tools/perf/ui/hist.c       | 4 ++--
 tools/thermal/tmon/sysfs.c | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 14cea74..4dd3755 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -330,10 +330,10 @@ static void set_subtitle(void)
 	list_for_each_entry(sp, &trail, entries) {
 		if (sp->text) {
 			if (pos) {
-				pos->next = xcalloc(sizeof(*pos), 1);
+				pos->next = xcalloc(1, sizeof(*pos));
 				pos = pos->next;
 			} else {
-				subtitles = pos = xcalloc(sizeof(*pos), 1);
+				subtitles = pos = xcalloc(1, sizeof(*pos));
 			}
 			pos->text = sp->text;
 		}
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 2af1837..dc0d095 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -162,8 +162,8 @@ static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,
 		return ret;
 
 	nr_members = evsel->nr_members;
-	fields_a = calloc(sizeof(*fields_a), nr_members);
-	fields_b = calloc(sizeof(*fields_b), nr_members);
+	fields_a = calloc(nr_members, sizeof(*fields_a));
+	fields_b = calloc(nr_members, sizeof(*fields_b));
 
 	if (!fields_a || !fields_b)
 		goto out;
diff --git a/tools/thermal/tmon/sysfs.c b/tools/thermal/tmon/sysfs.c
index dfe4548..1c12536 100644
--- a/tools/thermal/tmon/sysfs.c
+++ b/tools/thermal/tmon/sysfs.c
@@ -446,7 +446,7 @@ int probe_thermal_sysfs(void)
 		return -1;
 	}
 
-	ptdata.tzi = calloc(sizeof(struct tz_info), ptdata.max_tz_instance+1);
+	ptdata.tzi = calloc(ptdata.max_tz_instance+1, sizeof(struct tz_info));
 	if (!ptdata.tzi) {
 		fprintf(stderr, "Err: allocate tz_info\n");
 		return -1;
@@ -454,8 +454,8 @@ int probe_thermal_sysfs(void)
 
 	/* we still show thermal zone information if there is no cdev */
 	if (ptdata.nr_cooling_dev) {
-		ptdata.cdi = calloc(sizeof(struct cdev_info),
-				ptdata.max_cdev_instance + 1);
+		ptdata.cdi = calloc(ptdata.max_cdev_instance + 1,
+				sizeof(struct cdev_info));
 		if (!ptdata.cdi) {
 			free(ptdata.tzi);
 			fprintf(stderr, "Err: allocate cdev_info\n");

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-12  8:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-06 11:40 [PATCH] calloc/xcalloc: fix argument order Arjun Sreedharan
2014-12-09 12:31 ` Arnaldo Carvalho de Melo
2014-12-12  8:18 ` [tip:perf/urgent] calloc/xcalloc: Fix " tip-bot for Arjun Sreedharan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox