From nobody Fri Dec 19 17:27:01 2025 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 ACF3C279325 for ; Wed, 30 Apr 2025 17:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746035553; cv=none; b=jHcYFw58Cwn9XDS4uG6i/1H0gEfdzqmurMCt9CH0MaQJsm4JoOo+3UoSxDl1Rtt7YrRj2Nch4XqWEATE/66UBmPrADOm8rM/QWvX0L1KKvy7utYygIFia3BaJI8XEtUwi86VN0Ryx7MZtip1jtvwGAW4DZnBGjyeDXATD3GLsCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746035553; c=relaxed/simple; bh=kyIAaqYv5feUAAH9a7cG4X9qbJk9e6Q/D00eURyg8ms=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=k3r0qY5FkvZp02cEWp3HmiubMGILHOT+7tb3vS8VWnbct1bMigCGdX7MfvYM+pnKu/zA11rAoUWNk6kKMZkczs2ucfxp93jHgV40DTnEg+0WVl36lUzzoBaddHORkRI9bB7Xm2kkLZFc+Xiecma1tEHPcT11mCoxw6aAfZxSpEk= 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=xXBDZnhc; arc=none smtp.client-ip=209.85.215.201 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="xXBDZnhc" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b1d9f278aecso51472a12.2 for ; Wed, 30 Apr 2025 10:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746035551; x=1746640351; 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=Xcg6wjMvXME6KKvdjmH0neAjL3wA1v7P5CrDBAB/BDc=; b=xXBDZnhce4huloB8X/qdRUg+eWHumjVOohdujdH5z7FMRUtNqFX3iw4XgSDCJG8QmE /o3iScg+Mzag8VtG6wZG7g6gOBgC+QQH/4H8wPihIPfqnLuE6gl1qc73ZLKIHqyaQst2 YVGpahC9EIBHrTxxGO5gBikjbubwPIXdpcosWdW0RcEzEdCqBrKa1ClZb6lBg46tW/9n 0cAZTKfTO8VUcT3rXP+aqHSiVj0cPR7I6S21+ntiCKN2vD9d2KmOtQAl3ZXnqORQeBTL /tg8sBqOVPNkZWZWNdNN9SqUKed/Aacor+rD3Kt/bD30B4Un40QFESSdPdzla8P5aH5F nr4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746035551; x=1746640351; 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=Xcg6wjMvXME6KKvdjmH0neAjL3wA1v7P5CrDBAB/BDc=; b=jZWfPqUPSZRMQcnanu2UnlCjRZ+ZGvu4gqp+VwlWOPwo36DJ5TIFOGXO96jPvG47GV 10zjdnWDsv+aOosXnbRVJXCs3tSUqgkM/MU2wA59NQmd+nMgWAxZKRJ29AJJrpTGqtCC X0k2NYaUmgJOpP5l00DYgnzu8iYxQmIqHSGEdjaJQ4uSPzo84nAcTKCu5bbdxpVvPmKB pegRpaIdcMsqTDsY3dDe/hGbDcIuFk8GJ/+rNXKFaeaEexEMAGKN4oyVx2cPbtiw3DW0 8gcuetwF2AjWtuP/6egobVkKAvPekhQp6++lGbQM/QQ9Za3YJ3+OYWowpvP+aMLSjXe1 RkgQ== X-Forwarded-Encrypted: i=1; AJvYcCV0Daz1iZOaPENEodpNeblWIzJtL1xIqQMZRRPWK/i4PuCDXa5fVWOUx83zO0T+chPlGMyLB0XfRmuQW4Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyFdhKGpZsxXL53hs5EOzPh9rF2AyrGHoX/0v9qi9e1WX2du50V te4HJD9fnC+zYsbfAJcDNRCXN0ckK9KbJjIQH7yRWOR+esm8/JItRFprU3pTnm7q3PDkXPQpTJR DP7dzVQ== X-Google-Smtp-Source: AGHT+IEKyz0de2SDHs2Wi3XD69kNX3qSVqi0GA9WwmSWKDFlmr/T24Ck2MF0lTbNZtV+tulQOwG0zYD0Vjfx X-Received: from pgkb21.prod.google.com ([2002:a63:eb55:0:b0:b1f:857e:2198]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:118a:b0:1f5:93cd:59b5 with SMTP id adf61e73a8af0-20aa41839ccmr5344128637.28.1746035551081; Wed, 30 Apr 2025 10:52:31 -0700 (PDT) Date: Wed, 30 Apr 2025 10:50:34 -0700 In-Reply-To: <20250430175036.184610-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: <20250430175036.184610-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.906.g1f30a19c02-goog Message-ID: <20250430175036.184610-47-irogers@google.com> Subject: [PATCH v2 46/47] perf hashmap: Silence -Wshorten-64-to-32 warnings From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yury Norov , Rasmus Villemoes , 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 Cc: Ian Rogers 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.906.g1f30a19c02-goog