Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uftrace: Align exact argument on calloc #1936

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmds/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static int read_taskinfo(void *arg)
else if (!strncmp(&buf[9], "tids=", 5)) {
char *tids_str = &buf[14];
char *endp = tids_str;
int *tids = xcalloc(sizeof(*tids), info->nr_tid);
int *tids = xcalloc(info->nr_tid, sizeof(*tids));
int nr_tid = 0;

while (*endp != '\n') {
Expand Down
2 changes: 1 addition & 1 deletion libmcount/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void prepare_shmem_buffer(struct mcount_thread_data *mtdp)

shmem->nr_buf = 2;
shmem->max_buf = 2;
shmem->buffer = xcalloc(sizeof(*shmem->buffer), 2);
shmem->buffer = xcalloc(2, sizeof(*shmem->buffer));

for (idx = 0; idx < shmem->nr_buf; idx++) {
shmem->buffer[idx] = allocate_shmem_buffer(buf, sizeof(buf), tid, idx);
Expand Down
4 changes: 2 additions & 2 deletions libmcount/wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static char **collect_uftrace_envp(void)
n++;
}

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

for (i = k = 0; i < ARRAY_SIZE(uftrace_env); i++) {
char *env_str;
Expand Down Expand Up @@ -232,7 +232,7 @@ static char **merge_envp(char *const *env1, char **env2)
n += count_envp(env1);
n += count_envp(env2);

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

n = 0;
for (i = 0; env1 && env1[i]; i++)
Expand Down
2 changes: 1 addition & 1 deletion utils/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ static int kernel_test_setup_handle(struct uftrace_kernel_reader *kernel,
int i;

handle->nr_tasks = NUM_TASK;
handle->tasks = xcalloc(sizeof(*handle->tasks), NUM_TASK);
handle->tasks = xcalloc(NUM_TASK, sizeof(*handle->tasks));

handle->time_range.start = handle->time_range.stop = 0;
handle->time_filter = 0;
Expand Down
6 changes: 3 additions & 3 deletions utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ extern void setup_signal(void);

#define xzalloc(sz) \
({ \
void *__ptr = calloc(sz, 1); \
void *__ptr = calloc(1, sz); \
if (__ptr == NULL) { \
pr_err("xzalloc"); \
} \
__ptr; \
})

#define xcalloc(sz, n) \
#define xcalloc(n, sz) \
({ \
void *__ptr = calloc(sz, n); \
void *__ptr = calloc(n, sz); \
if (__ptr == NULL) { \
pr_err("xcalloc"); \
} \
Expand Down