mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-14 14:33:50 +08:00
tree-wide: Sprinkle _clang_suppress_alloc_
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
This commit is contained in:
parent
5322bb8fd1
commit
28ba117fc6
@ -241,7 +241,7 @@ static int kmod_config_add_blacklist(struct kmod_config *config, const char *mod
|
||||
|
||||
DBG(config->ctx, "modname=%s\n", modname);
|
||||
|
||||
p = strdup(modname);
|
||||
_clang_suppress_alloc_ p = strdup(modname);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -828,7 +828,7 @@ static int module_do_install_commands(struct kmod_module *mod, const char *optio
|
||||
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;
|
||||
|
||||
|
@ -419,7 +419,7 @@ int mkdir_p(const char *path, int len, mode_t mode)
|
||||
_cleanup_free_ char *start;
|
||||
char *end;
|
||||
|
||||
start = memdup(path, len + 1);
|
||||
_clang_suppress_alloc_ start = memdup(path, len + 1);
|
||||
if (!start)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -1913,7 +1913,7 @@ static void depmod_report_cycles(struct depmod *depmod, uint16_t n_mods, uint16_
|
||||
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;
|
||||
@ -2920,7 +2920,8 @@ static int do_depmod(int argc, char *argv[])
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user