From nobody Wed Oct 8 20:01:58 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 06FCD263C90 for ; Tue, 24 Jun 2025 23:19:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750807174; cv=none; b=oc8J8sNjGZ3uM0BuOF+gfZrBZv7cReYlWeXp/7NXvlmH8oFX3IV6FbuJ5yPM9n8YRCZqM5qBAYYabjxy/lIzaCOrCi6okmJ66HjyGeMPogiGGA/umGEzdMdV6jQPBeOQqIfiDbhoRomxw67N6PwcAXNkmPtqrNgQ/5vF6inNhl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750807174; c=relaxed/simple; bh=OxLNyC//bkj0XORJ9A66+tceeOcN6KoRszvC1wPGHZw=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=buaPZf7DqEUj8dfxGAI8AZ3yHKc+CoS57OFn9fC3xzQIAeQj5vKRIwxtalxmbI5iUJZUI2cHY4AtROCEHf6+NrCgelmk83425lIeAMQYGwPdldbVM5p6kHN8WY1qgWdnLVfv6DO0jKNs5Ww36kC8VlheKgYuh0UDpWkvhN5DiKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fqbWlrV+; arc=none smtp.client-ip=209.85.215.202 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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fqbWlrV+" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b2eea1c2e97so674182a12.2 for ; Tue, 24 Jun 2025 16:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1750807172; x=1751411972; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=p1zI7Q0nLPv1eQnNCYffc5pUolE0Wqa7/b4IWfH+ITo=; b=fqbWlrV+F0FCcq0/AKTkDqMkBAiv5TfiJ1Qx4xewT5qKZPg6k4KX8XAIp6FQzxEjOA pHIctwRSeuy+wo6/FYpsxcCd90jjNII36KLNF/smc56sOqXVqOkIl/KNSQ9sCzpCIGry yx4HbuyvI2J1mcKgiCsC5+6xm+PbIIOLmRuKOhfT9b3WN/Cer/1cpKpYlpW7DmW3Lsv0 dIlv/gNYdx54uWBsyZX2Fk9OqlNTcvOWnVGcMV5HpuwKI83M+2vMuhLpEKaES+Vm//Yj o0EJ7qbicXnxo6kD88fEd5WnPT4YChSDSEHQsd2Zovs3EkUTSYhHxvtTqkMmVEDZBGFx Ws2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750807172; x=1751411972; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p1zI7Q0nLPv1eQnNCYffc5pUolE0Wqa7/b4IWfH+ITo=; b=Ylh1W/wTRjG+cQ1A08gR4kwIAtQd9sXI1c1vxh/AMp/d2ISAkSs45Se8BNOlDRw+lJ 4TIb4H/dYHJKjKGWVzUh9j8rdHQSlJvGnB1/ns0eXEyonnUWyXKtNtSKO+ttxiekRFUl AMy4oz96nuDlL49r0tiNNNkAK317mbFeH8q0k/o3zjxv0b2L4377ky0ZHJZ8ThZ24tcY z4seX7MVjKAz92ycwQ/SBdgheTxaLFDRvulhFG+i0KzSput3O5QCeog/3Q0KswvsTPhR JE0I1mCqGzIQnVO7VJdqOisBTMm3GtdfrUM1q/V6FcsNQQGnwj9fhwUHkt5gNIwVlHNR R91A== X-Forwarded-Encrypted: i=1; AJvYcCUNrzoFZTYwD44XIYzthlJJsIFW8LGb7gKAIfjn3Ml6+V8gasROunBab9v6FYrmrjty8qE5+WJiFGkgJTg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1addauMxklCwrlyei6yp4hgIVHDTyp4iiU78P0nBhG5FlI4VR +3j9xPlFKPY3VGv/QSyHhCNx+iN0PSyyx+TqQTIQ/VW0kfAb6hGjZ474FNBxNS/v33j3hkCfXyg 5awb4+g== X-Google-Smtp-Source: AGHT+IE23nOiBQ3/n1/Gt0pA9demZ4Iii2r83PTmEqXZz+eFfW86Nbh+5GyodHjhmYDzoXwsG8jf3L55akY= X-Received: from pgcp27.prod.google.com ([2002:a63:741b:0:b0:b2f:64e5:602a]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7350:b0:21c:faa4:9ab8 with SMTP id adf61e73a8af0-2207f1ba673mr1146817637.10.1750807172381; Tue, 24 Jun 2025 16:19:32 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 24 Jun 2025 16:19:30 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.50.0.714.g196bf9f422-goog Message-ID: <20250624231930.583689-1-seanjc@google.com> Subject: [PATCH] selftests: harness: Rework is_signed_type() to avoid collision with overflow.h From: Sean Christopherson To: Kees Cook , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Mailhol , Arnaldo Carvalho de Melo , Sean Christopherson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename is_signed_type() to is_signed_var() to avoid colliding with a macro of the same name defined by linux/overflow.h. Note, overflow.h's version takes a type as the input, whereas the harness's version takes a variable! This fixes warnings (and presumably potential test failures) in tests that utilize the selftests harness and happen to (indirectly) include overflow.h. In file included from tools/include/linux/bits.h:34, from tools/include/linux/bitops.h:14, from tools/include/linux/hashtable.h:13, from include/kvm_util.h:11, from x86/userspace_msr_exit_test.c:11: tools/include/linux/overflow.h:31:9: error: "is_signed_type" redefined [-= Werror] 31 | #define is_signed_type(type) (((type)(-1)) < (type)1) | ^~~~~~~~~~~~~~ In file included from include/kvm_test_harness.h:11, from x86/userspace_msr_exit_test.c:9: ../kselftest_harness.h:754:9: note: this is the location of the previous = definition 754 | #define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (= __typeof__(var))1)) | ^~~~~~~~~~~~~~ Opportunistically use is_signed_type() to implement is_signed_var() so that the relationship and differences are obvious. Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kern= el sources") Cc: Vincent Mailhol Cc: Arnaldo Carvalho de Melo Signed-off-by: Sean Christopherson Reviewed-by: Vincent Mailhol --- This is probably compile-tested only, I don't think any of the KVM selftests utilize the harness's EXPECT macros. tools/testing/selftests/kselftest_harness.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/se= lftests/kselftest_harness.h index 2925e47db995..f3e7a46345db 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -751,7 +752,7 @@ for (; _metadata->trigger; _metadata->trigger =3D \ __bail(_assert, _metadata)) =20 -#define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof_= _(var))1)) +#define is_signed_var(var) is_signed_type(__typeof__(var)) =20 #define __EXPECT(_expected, _expected_str, _seen, _seen_str, _t, _assert) = do { \ /* Avoid multiple evaluation of the cases */ \ @@ -759,7 +760,7 @@ __typeof__(_seen) __seen =3D (_seen); \ if (!(__exp _t __seen)) { \ /* Report with actual signedness to avoid weird output. */ \ - switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \ + switch (is_signed_var(__exp) * 2 + is_signed_var(__seen)) { \ case 0: { \ uintmax_t __exp_print =3D (uintmax_t)__exp; \ uintmax_t __seen_print =3D (uintmax_t)__seen; \ base-commit: 78f4e737a53e1163ded2687a922fce138aee73f5 --=20 2.50.0.714.g196bf9f422-goog