From nobody Wed Oct 8 05:55:36 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CE41278E6A for ; Tue, 1 Jul 2025 15:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751383228; cv=none; b=dpuozZnr399bkwvkNzEARrO09ggQIS8YJZEB+bf0BHLTye7LkxKdrmEYZR0KE2QwTjeo5YEEeNuVQirkXJK8BLCGXXtPEv3EtV1ZFGltduEiCpJ/CW2MFxfS1353DKlTXxxgERU4APv67mr1cCicDs8oK6wZaweVIk9xhaGa5/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751383228; c=relaxed/simple; bh=NfqJHrC70KrRvRT03h3FKFqjbqq4oRnI9qpYzXDWrLA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tTQj+ACbI+wFkn8OgWe0hyU/zH0dp7AFDuEOdgEiqc+Eqmh+v67fFbRnBBmQrhJ6HuEot1TNupeQD3Zv1VjMZvUOK4ZROsArvWqFcNV/nWtU6mujv0mdQKH84TB8eBwzws99MYNvYNvJedJuDxzISEqgIsrtF/kY02E91BSvWgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--gprocida.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pQRS+CO1; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--gprocida.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pQRS+CO1" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3a4edf5bb4dso3820866f8f.0 for ; Tue, 01 Jul 2025 08:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1751383225; x=1751988025; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=n9NaebKJibAgutzsepKI6CuTfNuoKinu08ccOPT+zBg=; b=pQRS+CO1S0OD4r2odSckvrFg9DVVUSd8xdiJOWeMGCR+55gqjWstJivQNJinQ4nzYZ 27tNDv4lZx5DxRBgwCnd/vo4ZzMuRZ0UpTH42TSVo0sIbe3pAM9RM7EU+gJF29cZmcAs qA/GTXfd44U1Vrf+JnjU0dRil02iiIPZUIw9vdkAlGxwh0WFyRtIVn0poMT/2xoVIcMa tvhoH7sAMEUIvKMN67xAnPeyV+Wky9Fkfeo6RLu1kMEhXmzxrrhqUyYXE+pyxCPzn8YJ Q0OzGTIK7jL2Z9639Jrst9Lp91LqZV38zz+ILtPUtb28Xv6o/ZFVjV64sUQAm1FK82iE 9fPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751383225; x=1751988025; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n9NaebKJibAgutzsepKI6CuTfNuoKinu08ccOPT+zBg=; b=qKWQAf01cQxE5lmvCCvFFFQYCNFGW79ucRDewH5OHfgdl/2d+B00kEazhESeDAitFd 2qoHpfoQumPEUVHMA2KLjkNYZlox/n12DJUHjCWOeVJCjkF1GfbgTQfS7KTPnjoG7t43 IrCjzd7+mt0w8+uyc+t7K/pyu8mqHegpTUNtFTjbOT8RIzCXgqQUl2zJouknXv5mduOY xHjZLaWo/mO1TEzc2JI4afFDRTNpWBV02rYb/pNOMZGkrXOTRuxrl9tX4KptHYXd5tO1 41b8k9nvTywRhoCUgHSK1dutzPD6+WRhSd4Xb9UdUMBt+k/fGN8+nWfRIE6HVzwPYjnk diSA== X-Forwarded-Encrypted: i=1; AJvYcCUTGJyBxKckGFFmZlqa9cTAxgoPGOZ3eYqfbsFJuWlo7vLs9Vn8Zko/BJwT/DfwCFJwArg9iEVeL3dB3/8=@vger.kernel.org X-Gm-Message-State: AOJu0YzTzLjO9CgUoMnR7Lg1KVKmHP+I47C6L4RJFD/VfcObgEO5jTzl jXOlCPWjzJSqYd0IIAS2Bf822DJl9qiiUDM5aEBLXNXafHWK7B4gGSYZ9sBWL7OXrxlNm3+4Iqm FkVRuRdY5fkygvw== X-Google-Smtp-Source: AGHT+IHo0j0lmY49uISfqEt+SitHSrRX1NBmaGQGIgieiSEQyVwJA5vANI9q18/ygoSYgZtGRGtj2Nb+JtjrBQ== X-Received: from wmbds5.prod.google.com ([2002:a05:600c:6285:b0:451:d70f:eb87]) (user=gprocida job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:4a01:0:b0:3a1:fe77:9e1d with SMTP id ffacd0b85a97d-3a90d5a7e61mr14137301f8f.16.1751383225629; Tue, 01 Jul 2025 08:20:25 -0700 (PDT) Date: Tue, 1 Jul 2025 16:19:10 +0100 In-Reply-To: <20250701152000.2477659-1-gprocida@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250701152000.2477659-1-gprocida@google.com> X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250701152000.2477659-2-gprocida@google.com> Subject: [PATCH v2 1/2] gendwarfksyms: use preferred form of sizeof for allocation From: Giuliano Procida To: Masahiro Yamada , Sami Tolvanen , Greg Kroah-Hartman Cc: Giuliano Procida , linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Giuliano Procida Reviewed-by: Sami Tolvanen --- scripts/gendwarfksyms/cache.c | 2 +- scripts/gendwarfksyms/die.c | 4 ++-- scripts/gendwarfksyms/dwarf.c | 2 +- scripts/gendwarfksyms/kabi.c | 2 +- scripts/gendwarfksyms/symbols.c | 2 +- scripts/gendwarfksyms/types.c | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/gendwarfksyms/cache.c b/scripts/gendwarfksyms/cache.c index c9c19b86a686..1c640db93db3 100644 --- a/scripts/gendwarfksyms/cache.c +++ b/scripts/gendwarfksyms/cache.c @@ -15,7 +15,7 @@ void cache_set(struct cache *cache, unsigned long key, in= t value) { struct cache_item *ci; =20 - ci =3D xmalloc(sizeof(struct cache_item)); + ci =3D xmalloc(sizeof(*ci)); ci->key =3D key; ci->value =3D value; hash_add(cache->cache, &ci->hash, hash_32(key)); diff --git a/scripts/gendwarfksyms/die.c b/scripts/gendwarfksyms/die.c index 6183bbbe7b54..052f7a3f975a 100644 --- a/scripts/gendwarfksyms/die.c +++ b/scripts/gendwarfksyms/die.c @@ -33,7 +33,7 @@ static struct die *create_die(Dwarf_Die *die, enum die_st= ate state) { struct die *cd; =20 - cd =3D xmalloc(sizeof(struct die)); + cd =3D xmalloc(sizeof(*cd)); init_die(cd); cd->addr =3D (uintptr_t)die->addr; =20 @@ -123,7 +123,7 @@ static struct die_fragment *append_item(struct die *cd) { struct die_fragment *df; =20 - df =3D xmalloc(sizeof(struct die_fragment)); + df =3D xmalloc(sizeof(*df)); df->type =3D FRAGMENT_EMPTY; list_add_tail(&df->list, &cd->fragments); return df; diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c index 13ea7bf1ae7d..3538a7d9cb07 100644 --- a/scripts/gendwarfksyms/dwarf.c +++ b/scripts/gendwarfksyms/dwarf.c @@ -634,7 +634,7 @@ static int get_union_kabi_status(Dwarf_Die *die, Dwarf_= Die *placeholder, * Note that the user of this feature is responsible for ensuring * that the structure actually remains ABI compatible. */ - memset(&state.kabi, 0, sizeof(struct kabi_state)); + memset(&state.kabi, 0, sizeof(state.kabi)); =20 res =3D checkp(process_die_container(&state, NULL, die, check_union_member_kabi_status, diff --git a/scripts/gendwarfksyms/kabi.c b/scripts/gendwarfksyms/kabi.c index b3ade713778f..e3c2a3ccf51a 100644 --- a/scripts/gendwarfksyms/kabi.c +++ b/scripts/gendwarfksyms/kabi.c @@ -228,7 +228,7 @@ void kabi_read_rules(int fd) if (type =3D=3D KABI_RULE_TYPE_UNKNOWN) error("unsupported kABI rule type: '%s'", field); =20 - rule =3D xmalloc(sizeof(struct rule)); + rule =3D xmalloc(sizeof(*rule)); =20 rule->type =3D type; rule->target =3D xstrdup(get_rule_field(&rule_str, &left)); diff --git a/scripts/gendwarfksyms/symbols.c b/scripts/gendwarfksyms/symbol= s.c index 327f87389c34..35ed594f0749 100644 --- a/scripts/gendwarfksyms/symbols.c +++ b/scripts/gendwarfksyms/symbols.c @@ -146,7 +146,7 @@ void symbol_read_exports(FILE *file) continue; } =20 - sym =3D xcalloc(1, sizeof(struct symbol)); + sym =3D xcalloc(1, sizeof(*sym)); sym->name =3D name; sym->addr.section =3D SHN_UNDEF; sym->state =3D SYMBOL_UNPROCESSED; diff --git a/scripts/gendwarfksyms/types.c b/scripts/gendwarfksyms/types.c index 7bd459ea6c59..5344c7b9a9ce 100644 --- a/scripts/gendwarfksyms/types.c +++ b/scripts/gendwarfksyms/types.c @@ -43,7 +43,7 @@ static int type_list_append(struct list_head *list, const= char *s, void *owned) if (!s) return 0; =20 - entry =3D xmalloc(sizeof(struct type_list_entry)); + entry =3D xmalloc(sizeof(*entry)); entry->str =3D s; entry->owned =3D owned; list_add_tail(&entry->list, list); @@ -120,7 +120,7 @@ static struct type_expansion *type_map_add(const char *= name, struct type_expansion *e; =20 if (__type_map_get(name, &e)) { - e =3D xmalloc(sizeof(struct type_expansion)); + e =3D xmalloc(sizeof(*e)); type_expansion_init(e); e->name =3D xstrdup(name); =20 --=20 2.50.0.727.gbf7dc18ff4-goog From nobody Wed Oct 8 05:55:36 2025 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F50F2798FA for ; Tue, 1 Jul 2025 15:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751383231; cv=none; b=BiP6dsilBNDtH04KGi5PpaDXKBq85aOErTJXs4zMPF4RexaVGN+2neWgjkWvvE8xnAfj1IOlhXJtsaTNxIDOM+v4S858YCQwPBww/ObMyix4bRylkCbnMSvpU6oRcK231NL7zAA81YkFaD54EutuhO2+x9dDqMYrCklp9G6EYWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751383231; c=relaxed/simple; bh=0LZPlTOzhDgN4M2JFCpvyuUvtX08QaSuKLicDKE1N5E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=F9LyN7L5fTwvaoABYqGW5vKVscurDGidrOeoqX19JO7eEToUDPCQ4oUIN1mABMzrXDQZ20zSa9Jx5t6vJQ8qImg8YCNNeydAxFYlSk8KPCeOc1U+vjxpfbq4J8dfwXgSkaGzbzfFlLI0zSWlXLDzc/h5bS+pTSyLNyCr/c2XuJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--gprocida.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aPwe4tPY; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--gprocida.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aPwe4tPY" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-452ff9e054eso27846855e9.2 for ; Tue, 01 Jul 2025 08:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1751383228; x=1751988028; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yQj2YyKGGYHlLV8Kxk75PVsyeBZE5VokyKievIbbY3k=; b=aPwe4tPYb+sNoUnlRggdhJTYu+HaWZ+bC4Pfe9ufJbdjneviNvrQ/gJYWRJsGoiYUN velH5B2s2JcmE/5aiP/e3m3DhoCNnuEgqqM6P0Ctywz65b3QRuEWSf+GeWf0zDF3vRCv khvJez74+gRM4E/cD3rPwyxuyWYD7epxT+ZStHaZDENMMsFvX3Tz2wdUmTwGq34wloCp PxMvaN5MhMrXe+nFwEkF38jHx96jKUAJoyBqdQxhvxDlwvQjq54jBHXUDoqgodHSx+QN 8ZAYnfz3XfCTthXvLxVEJFfFFdE+FFv/vfgp4rj1Cx7e77g2bDHgdk/0hiDyMJX/aWDO Csyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751383228; x=1751988028; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yQj2YyKGGYHlLV8Kxk75PVsyeBZE5VokyKievIbbY3k=; b=Wfp/KhX42fibThbbDydHO5BEuIoxhSiWidRpGgmkMxWwxpLoR6DA62uZe0S1xDCh3T SXhUg06SrmG/BU2aREHzXPctOcK66TjVyVbTNn/pc4TVYzI1Z5EN1OUWZqge/TtZawo0 8LSTq3sUa3sMUNkD1VQfYLTI6KbbiVub6Sw393h84KSe8vKkiKL574n+rYBQHoIP3/7q KCKnVx91b0cSY0ymuPznhJit6aMcJQekH3AGlqutYNjxDdyPdEEYOLVW4VxlqXK21TAj tWeko04U4VgatOCRz2Mgf3IUwdLnHrTEdd0Ae6OU27d8uVdGunU5PoVOZeJ77lZUVfV7 K6PA== X-Forwarded-Encrypted: i=1; AJvYcCX9COXcsbEz6gnKUQNYuU0Jg7Wbpo1G94nM2kDbQ24otQRy8C8DEj1JsihqBzZkHbDJzbBR2egOk1HsssM=@vger.kernel.org X-Gm-Message-State: AOJu0YyyPQK7XDCK48o5lyHTi4RKb/fZbQVaNjklnXyW/zzh32dxN0Uj B9SqDYk4v5DB9Nl1MBc9QhBohxX6EMexcMgjFdBdX7kEVQ4kKkD2TwVxiZdoy2Iv/d+IHl0lxyU tmyalZq4mJhZJ4A== X-Google-Smtp-Source: AGHT+IElh3PYpbuoTAc35/xRfrNx9S2QQcNvE6QJPF2din6i4y4W48x8gXxZ/sqDfxdlN+vEmIzdSckX/yxw2w== X-Received: from wmte15.prod.google.com ([2002:a05:600c:8b2f:b0:44f:f406:f4f2]) (user=gprocida job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3ba6:b0:442:d5dd:5b4b with SMTP id 5b1f17b1804b1-4538eeac21fmr192770235e9.31.1751383227988; Tue, 01 Jul 2025 08:20:27 -0700 (PDT) Date: Tue, 1 Jul 2025 16:19:11 +0100 In-Reply-To: <20250701152000.2477659-1-gprocida@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250701152000.2477659-1-gprocida@google.com> X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250701152000.2477659-3-gprocida@google.com> Subject: [PATCH v2 2/2] gendwarfksyms: order -T symtypes output by name From: Giuliano Procida To: Masahiro Yamada , Sami Tolvanen , Greg Kroah-Hartman Cc: Giuliano Procida , linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When writing symtypes information, we iterate through the entire hash table containing type expansions. The key order varies unpredictably as new entries are added, making it harder to compare symtypes between builds. Resolve this by sorting the type expansions by name before output. Signed-off-by: Giuliano Procida Acked-by: Greg Kroah-Hartman Reviewed-by: Sami Tolvanen --- scripts/gendwarfksyms/types.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/scripts/gendwarfksyms/types.c b/scripts/gendwarfksyms/types.c index 5344c7b9a9ce..9c3b053bf061 100644 --- a/scripts/gendwarfksyms/types.c +++ b/scripts/gendwarfksyms/types.c @@ -6,6 +6,8 @@ #define _GNU_SOURCE #include #include +#include +#include #include =20 #include "gendwarfksyms.h" @@ -179,20 +181,41 @@ static int type_map_get(const char *name, struct type= _expansion **res) return -1; } =20 +static int cmp_expansion_name(const void *p1, const void *p2) +{ + struct type_expansion *const *e1 =3D p1; + struct type_expansion *const *e2 =3D p2; + + return strcmp((*e1)->name, (*e2)->name); +} + static void type_map_write(FILE *file) { struct type_expansion *e; struct hlist_node *tmp; + struct type_expansion **es; + size_t count =3D 0; + size_t i =3D 0; =20 if (!file) return; =20 - hash_for_each_safe(type_map, e, tmp, hash) { - checkp(fputs(e->name, file)); + hash_for_each_safe(type_map, e, tmp, hash) + ++count; + es =3D xmalloc(count * sizeof(*es)); + hash_for_each_safe(type_map, e, tmp, hash) + es[i++] =3D e; + + qsort(es, count, sizeof(*es), cmp_expansion_name); + + for (i =3D 0; i < count; ++i) { + checkp(fputs(es[i]->name, file)); checkp(fputs(" ", file)); - type_list_write(&e->expanded, file); + type_list_write(&es[i]->expanded, file); checkp(fputs("\n", file)); } + + free(es); } =20 static void type_map_free(void) --=20 2.50.0.727.gbf7dc18ff4-goog