Skip to content

Commit 804ae6b

Browse files
kzall0cnamhyung
authored andcommitted
uftrace: Align exact argument on calloc
Align argument for calloc call in some code and macro in utils.h file. Signed-off-by: Yunseong Kim <[email protected]>
1 parent 3ad5f45 commit 804ae6b

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

cmds/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ static int read_taskinfo(void *arg)
539539
else if (!strncmp(&buf[9], "tids=", 5)) {
540540
char *tids_str = &buf[14];
541541
char *endp = tids_str;
542-
int *tids = xcalloc(sizeof(*tids), info->nr_tid);
542+
int *tids = xcalloc(info->nr_tid, sizeof(*tids));
543543
int nr_tid = 0;
544544

545545
while (*endp != '\n') {

libmcount/record.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void prepare_shmem_buffer(struct mcount_thread_data *mtdp)
7373

7474
shmem->nr_buf = 2;
7575
shmem->max_buf = 2;
76-
shmem->buffer = xcalloc(sizeof(*shmem->buffer), 2);
76+
shmem->buffer = xcalloc(2, sizeof(*shmem->buffer));
7777

7878
for (idx = 0; idx < shmem->nr_buf; idx++) {
7979
shmem->buffer[idx] = allocate_shmem_buffer(buf, sizeof(buf), tid, idx);

libmcount/wrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static char **collect_uftrace_envp(void)
197197
n++;
198198
}
199199

200-
envp = xcalloc(sizeof(*envp), n + 2);
200+
envp = xcalloc(n + 2, sizeof(*envp));
201201

202202
for (i = k = 0; i < ARRAY_SIZE(uftrace_env); i++) {
203203
char *env_str;
@@ -232,7 +232,7 @@ static char **merge_envp(char *const *env1, char **env2)
232232
n += count_envp(env1);
233233
n += count_envp(env2);
234234

235-
envp = xcalloc(sizeof(*envp), n + 1);
235+
envp = xcalloc(n + 1, sizeof(*envp));
236236

237237
n = 0;
238238
for (i = 0; env1 && env1[i]; i++)

utils/kernel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ static int kernel_test_setup_handle(struct uftrace_kernel_reader *kernel,
17781778
int i;
17791779

17801780
handle->nr_tasks = NUM_TASK;
1781-
handle->tasks = xcalloc(sizeof(*handle->tasks), NUM_TASK);
1781+
handle->tasks = xcalloc(NUM_TASK, sizeof(*handle->tasks));
17821782

17831783
handle->time_range.start = handle->time_range.stop = 0;
17841784
handle->time_filter = 0;

utils/utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,16 @@ extern void setup_signal(void);
190190

191191
#define xzalloc(sz) \
192192
({ \
193-
void *__ptr = calloc(sz, 1); \
193+
void *__ptr = calloc(1, sz); \
194194
if (__ptr == NULL) { \
195195
pr_err("xzalloc"); \
196196
} \
197197
__ptr; \
198198
})
199199

200-
#define xcalloc(sz, n) \
200+
#define xcalloc(n, sz) \
201201
({ \
202-
void *__ptr = calloc(sz, n); \
202+
void *__ptr = calloc(n, sz); \
203203
if (__ptr == NULL) { \
204204
pr_err("xcalloc"); \
205205
} \

0 commit comments

Comments
 (0)