Skip to content

Commit

Permalink
Fix build with -Werror=calloc-transposed-args
Browse files Browse the repository at this point in the history
calloc() expects the number of elements as the first argument, and the
size of each element as the second one. Recent-enough gcc/clang started
warning about this, so let's fix the order of the arugments to avoid
build errors with -Werror.

[9/30] Compiling C object dfuzzer.p/src_suppression.c.o
../src/suppression.c: In function ‘df_suppression_load’:
../src/suppression.c:123:37: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  123 |                 item = calloc(sizeof(*item), 1);
      |                                     ^
../src/suppression.c:123:37: note: earlier argument should specify number of elements, later size of each element

Resolves #143
  • Loading branch information
mrc0mmand committed May 2, 2024
1 parent 1b2043c commit 067939b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/suppression.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int df_suppression_load(GList **suppressions, const char *service_name)
if (sscanf(line, "%ms %m[^\n]", &suppression, &description) < 1)
return df_fail_ret(-1, "Failed to parse line '%s'\n", line);

item = calloc(sizeof(*item), 1);
item = calloc(1, sizeof(*item));
if (!item)
return df_oom();

Expand Down

0 comments on commit 067939b

Please sign in to comment.