From nobody Mon Feb 9 23:19:58 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.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 5CCC9229B18 for ; Tue, 1 Apr 2025 18:26:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743531975; cv=none; b=r6Ak8NfiWOTb7+G1RuroBUo1FANibr861XktgKMuCanwDG2C3FlxHR+FY5WxWa6H/dPcK/pKsDGQ/ThCF6lYEg3UQ4oELbExoXkpsoT/1mTOK+uzhie1mKC11Noq4wiLSTk2dppRGv8cf9+YB8ZQc3vAlIFZtu3wHNuG2/0vBLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743531975; c=relaxed/simple; bh=bRqcJNqdHpJ92JW9Ryv+Tum+BcxSVSmO0diBUAO4Zbk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=lwK7rUfw7xJPYCSC5x5vFegIy1TiNyl2HRL0kgeiKDnFdT1rH/nNm2waMKLaxRTwpsVAtPbG3ZEIkQEWlUtIDJghSOnc/aVY20uQcVqSIn2LRcnqj2m53yawsZxLcNVgIN88Z0RxsiNauOzwWmtBgXDyDGjv4mZnx//HdXbTWfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L6eEkNwL; arc=none smtp.client-ip=209.85.216.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--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L6eEkNwL" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3055f2e1486so4313833a91.0 for ; Tue, 01 Apr 2025 11:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743531972; x=1744136772; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=PSwN5ZhtSE4cdH17wQnS7beYUnk/E6AzAjOBdetWRXw=; b=L6eEkNwL7NmxnkYDv9cpBI+gDoZ3+L6GXmnOew3TaXcJB8VPfUfteQrSZR+SSKjuqT SREW1fhvW+CN8FWJq66WCBzgP1orfnhL+8AqC3Bi+a/gBCqZTVZvxcbV/2++mCR+CpXe n9y2aL7GCXAs2LzgR6bBXw8hmYObWI+2xHCSQxLdjl4emjRUgVKYCZxwXMxHLvdqnNG5 nbT0ks3pw39LmKFY6b34zBGTG4x84OuzuZZZPzbDNOSMUJUGB9XUsxGm5nE1JYJXgSfX pB51iZj4wRbkkC0HwPrKbfXGp/h2YOk09OW65o5miNoce+7U+oJUUsten2PJVbhkyLiM k4LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743531972; x=1744136772; h=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=PSwN5ZhtSE4cdH17wQnS7beYUnk/E6AzAjOBdetWRXw=; b=uUwV9j+Z66l/pPYzHxEOEquKpt/PCytMhvoq/UwAfqLXHiidWs/7zqKBreXvuk/A4g vtmLs8vWyrmzo40HgRnoC6cEHBjTZZ5lNNnf4pwzqqA4+G8BucN8K+xsCuQEz6OOYD3A onRlxxpepIGeORq1dh9nQSy+l9EN6TnCJTjzEFMbPtyHnegL70/q7ofEwz1ImsSBfOR7 YZVkhPk/7rf7Ab7njJwUEBrIwz0nGRX0Zr9DFWHNmiED+29tVRBClKZIlzXwSFEBXc7N k8wI3maEZDr4Vh2Jy1K9DxfTg3HkiHLBL+gXZ4bI1Na3Kh7D78sRxOW0JiAset4Ue3zK cEsg== X-Forwarded-Encrypted: i=1; AJvYcCVyYRob846UyPl25nOasIJTU6PMonAmS5U1Uyw6Os7OhD+heekREYeFi8Z1CkuoxjdHEEHF8+mJzPDSsEY=@vger.kernel.org X-Gm-Message-State: AOJu0YyGi+B3pRxEOnEK3DyxMIBNE5Ih0PgDqgSag9q+UIZR+vRcDHAZ 7pqDqm6DisRhYgp5ikBMgnaTqURJMhBoO9XfILZDG74MPl1VrykBqJ4GxFge8/R9trs1l0b25uZ NXiL8xg== X-Google-Smtp-Source: AGHT+IF6T2ulSDFK8OsLYwxcRIOMccUUICCNSn+TOjQB/3bOJGqM6yG07KKXmBXUDSyMBIijHO+1iE5Jy859 X-Received: from pjbsq15.prod.google.com ([2002:a17:90b:530f:b0:2ff:5344:b54]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2dc2:b0:2f9:cf97:56a6 with SMTP id 98e67ed59e1d1-30531fa18b7mr25114861a91.14.1743531971624; Tue, 01 Apr 2025 11:26:11 -0700 (PDT) Date: Tue, 1 Apr 2025 11:23:45 -0700 In-Reply-To: <20250401182347.3422199-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250401182347.3422199-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog Message-ID: <20250401182347.3422199-48-irogers@google.com> Subject: [PATCH v1 47/48] perf hashmap: Silence -Wshorten-64-to-32 warnings From: Ian Rogers To: Yury Norov , Rasmus Villemoes , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Thomas Gleixner , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Jonathan Cameron , Nathan Chancellor , Bill Wendling , Justin Stitt , Josh Poimboeuf , Al Viro , Kyle Meyer , Ben Gainey , Athira Rajeev , Kajol Jain , Aditya Gupta , Eder Zulian , Dapeng Mi , Kuan-Wei Chiu , He Zhe , Dirk Gouders , Brian Geffon , Ravi Bangoria , Howard Chu , Charlie Jenkins , Colin Ian King , Dominique Martinet , Jann Horn , Masahiro Yamada , Arnd Bergmann , Yang Jihong , Dmitry Vyukov , Andi Kleen , Graham Woodward , Ilkka Koskinen , Anshuman Khandual , Zhongqiu Han , Hao Ge , Tengda Wu , Gabriele Monaco , Chun-Tse Shao , Casey Chen , "Dr. David Alan Gilbert" , Li Huafei , "Steinar H. Gunderson" , Levi Yun , Weilin Wang , Thomas Falcon , Thomas Richter , Andrew Kreimer , "=?UTF-8?q?Krzysztof=20=C5=81opatowski?=" , Christophe Leroy , Jean-Philippe Romain , Junhao He , "Masami Hiramatsu (Google)" , Xu Yang , Steve Clevenger , Zixian Cai , Stephen Brennan , Yujie Liu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The clang warning -Wshorten-64-to-32 can be useful to catch inadvertent truncation. In some instances this truncation can lead to changing the sign of a result, for example, truncation to return an int to fit a sort routine. Silence the warning by making the implicit truncation explicit. Signed-off-by: Ian Rogers --- tools/perf/util/hashmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/hashmap.c b/tools/perf/util/hashmap.c index 140ee4055676..f2719f522b84 100644 --- a/tools/perf/util/hashmap.c +++ b/tools/perf/util/hashmap.c @@ -115,7 +115,7 @@ static int hashmap_grow(struct hashmap *map) return -ENOMEM; =20 hashmap__for_each_entry_safe(map, cur, tmp, bkt) { - h =3D hash_bits(map->hash_fn(cur->key, map->ctx), new_cap_bits); + h =3D hash_bits(map->hash_fn(cur->key, map->ctx), (int)new_cap_bits); hashmap_add_entry(&new_buckets[h], cur); } =20 @@ -164,7 +164,7 @@ int hashmap_insert(struct hashmap *map, long key, long = value, if (old_value) *old_value =3D 0; =20 - h =3D hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h =3D hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); if (strategy !=3D HASHMAP_APPEND && hashmap_find_entry(map, key, h, NULL, &entry)) { if (old_key) @@ -188,7 +188,7 @@ int hashmap_insert(struct hashmap *map, long key, long = value, err =3D hashmap_grow(map); if (err) return err; - h =3D hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h =3D hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); } =20 entry =3D malloc(sizeof(struct hashmap_entry)); @@ -208,7 +208,7 @@ bool hashmap_find(const struct hashmap *map, long key, = long *value) struct hashmap_entry *entry; size_t h; =20 - h =3D hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h =3D hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); if (!hashmap_find_entry(map, key, h, NULL, &entry)) return false; =20 @@ -223,7 +223,7 @@ bool hashmap_delete(struct hashmap *map, long key, struct hashmap_entry **pprev, *entry; size_t h; =20 - h =3D hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h =3D hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); if (!hashmap_find_entry(map, key, h, &pprev, &entry)) return false; =20 --=20 2.49.0.504.g3bcea36a83-goog