calloc/xcalloc: fix argument order
Subsystems (3)
PATCH 1/1 calloc/xcalloc: fix argument order
calloc() and xcalloc() takes @nmemb first and then @size. fix all w/ pattern "calloc\s*(\s*sizeof".
Signed-off-by Arjun Sreedharan <[email protected]>
--- scripts/kconfig/mconf.c | 4 ++-- tools/perf/ui/hist.c | 4 ++-- tools/thermal/tmon/sysfs.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
scripts/kconfig/mconf.c +2 -2
@@ -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; }
tools/perf/ui/hist.c +2 -2
@@ -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;
tools/thermal/tmon/sysfs.c +3 -3
@@ -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" );
Signature · 1 line
1.8.1.msysgit.1
Em Sat, Dec 06, 2014 at 05:10:43PM +0530, Arjun Sreedharan escreveu:
Quoted 2 lines
calloc()andxcalloc()takes @nmemb first and then @size. fix all w/ pattern "calloc\s*(\s*sizeof".
Thanks, applied.
Quoted 65 lines
Signed-off-by Arjun Sreedharan <[email protected]>--- scripts/kconfig/mconf.c | 4 ++-- tools/perf/ui/hist.c | 4 ++-- tools/thermal/tmon/sysfs.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)scripts/kconfig/mconf.c +2
-2@@ -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; }tools/perf/ui/hist.c +2
-2@@ -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;tools/thermal/tmon/sysfs.c +3
-3@@ -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" );Signature · 1 line
1.8.1.msysgit.1
tip-bot for Arjun Sreedharan
merge bot[tip:perf/urgent] calloc/xcalloc: Fix argument order
In reply to Arjun Sreedharancalloc/xcalloc: Fix argument order
Commit-ID: e4e458b45c5861808674eebfea94cee2258bb2ea Gitweb: http://git.kernel.org/tip/e4e458b45c5861808674eebfea94cee2258bb2ea Author: Arjun Sreedharan <[email protected]> AuthorDate: Sat, 6 Dec 2014 17:10:43 +0530 Committer: Arnaldo Carvalho de Melo <[email protected]> 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 <[email protected]>
Cc "Yann E. MORIN" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- scripts/kconfig/mconf.c | 4 ++-- tools/perf/ui/hist.c | 4 ++-- tools/thermal/tmon/sysfs.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
scripts/kconfig/mconf.c +2 -2
@@ -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; }
tools/perf/ui/hist.c +2 -2
@@ -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;
tools/thermal/tmon/sysfs.c +3 -3
@@ -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" );