From mboxrd@z Thu Jan 1 00:00:00 1970 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 5A821229B16 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=1743531974; cv=none; b=fv1EABmyH+cAxE1VmRC/jaNgiA7nuMDp3U1SuQPNI3pQ5wtZB3KozdIafUBc7ICc+jDV8IwLNdtvSO6N66E57O7wUJERVN8soEm9LijWZyMk4hbFWG9oT8fmiHZ1+JnYDf2jEHsK/SVow8dbtlA74WRam9uAeh0gqYXtlyJWmQU= 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=djhj0iAD; 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="djhj0iAD" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ff78dd28ecso11075195a91.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=lists.linux.dev; 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=djhj0iADyrslN3hkyw3Wv3JrgEDH9SC6O0s/NVcv7zlQ0+QzXwxLXA5pFcEknZhkpd Cu+x4WUhKxsxgCqe3+EVNL0r7XJM5aymZvQCh5OebVg8TFFnRXMZNIYp0rwq2kxy/ZmE vhqx9fsH9d+6ULnd47tIBGsWiwoZkO+6O82dk1ztdD0KykPVPAqFt1zpBh6yJDHrE+y/ /kQhkMHQzyWspEWQm+6jqaenXglCJNqDD4X6Bw8Yc7txFYZTSRXTa04c1cREkeEQlHka YwK8m44jNsDhhojqHLpRXDpBaklm2shAIqMqYOA7Mu23QwwrBXyK0qyR7tY+cSe79HG3 xKIg== 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=wifE1S+cXcAifk0aRfTLzfPd57W+E+fUETMLODhlvb+sF5Z1+IHpJtyMmDt3iwylxA NJ3ud0KwNLodwDKVKYmWQ0sWmIbGO+SKzVk6su1Uk0IfyGFsr0G0z6sfH6cvfeUFPYeJ RdC4mqIOQ/ynrGYZyngNIa0pC3mqRjJhPzn0VbyFWfSoiqbdQTNXLdQVpIgTApbepDiT JduQvi9G1arakM/p2T10emPMbORscwPXjExhxv0x6pQu0MWt2KwrQbYrCWI2U9PCybsa xXUNMqeqnIZga4i3Q3YZ/8oLZT7F8RTc1+RQSDrrBDgBfbFO4O10qHFkLjOvGrtXHGvu o0EQ== X-Forwarded-Encrypted: i=1; AJvYcCUST27DQktrlJNVTPRhk+WewNDGde9vM+mO2qnV+gBYuYGO92JO5gFgWLaiNgkYYtGS1sWF@lists.linux.dev X-Gm-Message-State: AOJu0YxH3eXDi75sapM+wNq4pi1dWW/U8bm4gnc8NyGnCb7urANm4W7v JgwT8wyDc+v2xVR6s86pc0T49/0nF7IIVEcjDgvXXBB/8yGhh4fE5A4g7PTkoYNdhCyjLEN5Y1d imfvA1A== 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: llvm@lists.linux.dev 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