From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 5726D229B15 for ; Tue, 1 Apr 2025 18:26:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743531974; cv=none; b=PpvjCOZ7rWVoldWEb8nnp9GDBGWkKWverf9HU6ehMTyJ2Z+bzSdrQx+l81S+ZbgIRBTZK99wd9AnfldrhSXlON5uh4V+0X3gdVU/veIny6xbaQOSH6NRHKO/rz5QkxZjQ3p0hw9nY0+1WaQtAAdZWg+H7A3oYYjq8j7CPn/tJDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743531974; c=relaxed/simple; bh=bRqcJNqdHpJ92JW9Ryv+Tum+BcxSVSmO0diBUAO4Zbk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=W6vNk2oY1FttHgflMeny+G2cursyRPnW5B251mDZqfYqurRWGvvx6l5ElOgu9N/q/J/nbRKa1LF6ROIekn7K65TzJFSwEQDTHN1oE5h2f66kaDpqv4AZj4578g/hJBaFsgCdXqYLsAv73nezAriia65y4yV0tXNZa0hRWZlgZjM= 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.73 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-f73.google.com with SMTP id 98e67ed59e1d1-2ff78dd28ecso11075198a91.1 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=YZ0qhLQjQIFdrpqdtKpldS86dqxO6jPeyVtj5mhO/yXNNpc57sw9oBKiL6voruuseH R8Bl3jCIibXZ4juv89KRjnB8Ho0+qnch6181RYrT+0W2KvQM/7o+fi5M0ffbQKr79t/n Sbrpzndl5Tzcc7E9G18FVVXBEA1cIdd+lW4MP9VSEbq4aGNcXmzxVeDzwUlimuxcTaVm W/6Qkgzzq+0oSmE2iY2NMOaDYCXq1Gf/VWtTrdyJ21VvrhqIP2KM8dva/AhfnWBo9Uo2 L12DCWYq1Ja3kOM2GhsQIp1hfanLqePeWocQQv8KOmpoEEK1CbbU0FqNBzpCYh1NrDbP P1Bw== X-Forwarded-Encrypted: i=1; AJvYcCWK9EwAByTH9l4WfDinAux6cnb4vFZ+89ywuWTeT6/j5vJXf1jeKPeaDSrkBSaPZD/tS9DSr5pRTgt6bG8tRHTY@vger.kernel.org X-Gm-Message-State: AOJu0Yw4Mf6cm/raDJY3FuDzJ6CNdlQUenikrRXoxwYN2YMeEP0MVuYz xk2LPpzeVdUuWiuTXfcE+6PdHHYtVwSpZoZ0GjxygJrTeiIEH4Hfy6ue4gXCGtSLzbgI1yRY2ag UAtciPQ== 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-perf-users@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-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; hashmap__for_each_entry_safe(map, cur, tmp, bkt) { - h = hash_bits(map->hash_fn(cur->key, map->ctx), new_cap_bits); + h = hash_bits(map->hash_fn(cur->key, map->ctx), (int)new_cap_bits); hashmap_add_entry(&new_buckets[h], cur); } @@ -164,7 +164,7 @@ int hashmap_insert(struct hashmap *map, long key, long value, if (old_value) *old_value = 0; - h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h = hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); if (strategy != 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 = hashmap_grow(map); if (err) return err; - h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h = hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); } entry = 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; - h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h = hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); if (!hashmap_find_entry(map, key, h, NULL, &entry)) return false; @@ -223,7 +223,7 @@ bool hashmap_delete(struct hashmap *map, long key, struct hashmap_entry **pprev, *entry; size_t h; - h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits); + h = hash_bits(map->hash_fn(key, map->ctx), (int)map->cap_bits); if (!hashmap_find_entry(map, key, h, &pprev, &entry)) return false; -- 2.49.0.504.g3bcea36a83-goog