Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gendwarfksyms: use preferred form of sizeof for allocation

The preferred form is to use the variable being allocated to, rather
than explicitly supplying a type name which might become stale.

Also do this for memset.

Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Giuliano Procida and committed by
Masahiro Yamada
e06aa69d 87433e3e

+8 -8
+1 -1
scripts/gendwarfksyms/cache.c
··· 15 15 { 16 16 struct cache_item *ci; 17 17 18 - ci = xmalloc(sizeof(struct cache_item)); 18 + ci = xmalloc(sizeof(*ci)); 19 19 ci->key = key; 20 20 ci->value = value; 21 21 hash_add(cache->cache, &ci->hash, hash_32(key));
+2 -2
scripts/gendwarfksyms/die.c
··· 33 33 { 34 34 struct die *cd; 35 35 36 - cd = xmalloc(sizeof(struct die)); 36 + cd = xmalloc(sizeof(*cd)); 37 37 init_die(cd); 38 38 cd->addr = (uintptr_t)die->addr; 39 39 ··· 123 123 { 124 124 struct die_fragment *df; 125 125 126 - df = xmalloc(sizeof(struct die_fragment)); 126 + df = xmalloc(sizeof(*df)); 127 127 df->type = FRAGMENT_EMPTY; 128 128 list_add_tail(&df->list, &cd->fragments); 129 129 return df;
+1 -1
scripts/gendwarfksyms/dwarf.c
··· 634 634 * Note that the user of this feature is responsible for ensuring 635 635 * that the structure actually remains ABI compatible. 636 636 */ 637 - memset(&state.kabi, 0, sizeof(struct kabi_state)); 637 + memset(&state.kabi, 0, sizeof(state.kabi)); 638 638 639 639 res = checkp(process_die_container(&state, NULL, die, 640 640 check_union_member_kabi_status,
+1 -1
scripts/gendwarfksyms/kabi.c
··· 228 228 if (type == KABI_RULE_TYPE_UNKNOWN) 229 229 error("unsupported kABI rule type: '%s'", field); 230 230 231 - rule = xmalloc(sizeof(struct rule)); 231 + rule = xmalloc(sizeof(*rule)); 232 232 233 233 rule->type = type; 234 234 rule->target = xstrdup(get_rule_field(&rule_str, &left));
+1 -1
scripts/gendwarfksyms/symbols.c
··· 146 146 continue; 147 147 } 148 148 149 - sym = xcalloc(1, sizeof(struct symbol)); 149 + sym = xcalloc(1, sizeof(*sym)); 150 150 sym->name = name; 151 151 sym->addr.section = SHN_UNDEF; 152 152 sym->state = SYMBOL_UNPROCESSED;
+2 -2
scripts/gendwarfksyms/types.c
··· 43 43 if (!s) 44 44 return 0; 45 45 46 - entry = xmalloc(sizeof(struct type_list_entry)); 46 + entry = xmalloc(sizeof(*entry)); 47 47 entry->str = s; 48 48 entry->owned = owned; 49 49 list_add_tail(&entry->list, list); ··· 120 120 struct type_expansion *e; 121 121 122 122 if (__type_map_get(name, &e)) { 123 - e = xmalloc(sizeof(struct type_expansion)); 123 + e = xmalloc(sizeof(*e)); 124 124 type_expansion_init(e); 125 125 e->name = xstrdup(name); 126 126