Add the clang::suppress attribute to places where allocation is done and
that rely on the cleanup attribute. Clang analyzer doesn't handle those
(yet), so keep it from giving us false positive.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/233
DBG(config->ctx, "modname=%s\n", modname);
- p = strdup(modname);
+ _clang_suppress_alloc_ p = strdup(modname);
if (!p)
return -ENOMEM;
size_t suffixlen = cmdlen - prefixlen - varlen;
size_t slen = cmdlen - varlen + options_len;
char *suffix = p + varlen;
- char *s = malloc(slen + 1);
+ _clang_suppress_alloc_ char *s = malloc(slen + 1);
if (!s)
return -ENOMEM;
_cleanup_free_ char *start;
char *end;
- start = memdup(path, len + 1);
+ _clang_suppress_alloc_ start = memdup(path, len + 1);
if (!start)
return -ENOMEM;
n_r++;
}
- stack = malloc(n_r * sizeof(void *));
+ _clang_suppress_alloc_ stack = malloc(n_r * sizeof(void *));
if (stack == NULL) {
ERR("No memory to report cycles\n");
goto out_list;
break;
case 'C': {
size_t bytes = sizeof(char *) * (n_config_paths + 2);
- void *tmp = realloc(config_paths, bytes);
+ _clang_suppress_alloc_ void *tmp = realloc(config_paths, bytes);
+
if (!tmp) {
fputs("Error: out-of-memory\n", stderr);
goto cmdline_failed;