From patchwork Wed Apr 23 12:05:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 883599 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp2883485wrs; Wed, 23 Apr 2025 05:07:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXs5aXS4rooeVguZKXFbbxHvFktxAFhT+pmSly2YDkkV/4FM6nH7OiZNJqaklL/jHR82/BD9w==@linaro.org X-Google-Smtp-Source: AGHT+IGf77Z0oQ7X9GsjR1BxvT66J0n3rLSMi+0ggRtvWeE+rgp7cRQPu30Y2eGPt+ek38lNu17g X-Received: by 2002:a05:620a:1928:b0:7c7:a4b8:5753 with SMTP id af79cd13be357-7c927fae870mr3312606685a.30.1745410039675; Wed, 23 Apr 2025 05:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745410039; cv=none; d=google.com; s=arc-20240605; b=YC4RpwDWAyvY/WC6n+0nFDtJXU8ilzfNFURO63RXOhY0u5s7aVkuxXchSp3Xte/9xL 5I6v7G2i0rVxLwkRBQBOCuMbRfkx+dVg+aam3FRvGH6UZEco5mO9dE6g5RCgusE2hy55 sRJS25CCZC876wOJ5cYwBnRabfuuqUGF67ekpevGzvcOCO7DwkOL0ncwK8pCFq5OYdCh omYBzQs/WPIWGwhDuKVni4DUxfStBWmiliFE7OUEv57nerJNDwCPhHxq8J4fh2DGajpG JYpPz6PgDf3NHWMVCJJ7vCBlRnazv3YMhK88/InrltlJ87x7WT0+uzw23OB2fehz7SbV XOSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=4ABcmb67Z+D6NBbWU+MI+QxoFhkrlR/XebxVhtqvxp0=; fh=ov6E9jv+IlFJItozijhXcEY/Sz8MhL08kZIfrNK655c=; b=dZRmHmCproVQ71/Y/5+/Cm6nH2vtavscnFaVA/KwLthb1upcRTxMH1XxQdlSyhWJN/ ks5z3gRFm3BiPAoBVi6wyiwzaq9CksXZkJAzw6gA0QW5WT/wANRJj2XQ42dcAN9QwdBc aceSUVS9ypgE+/8IfnVuhn2wnqCjuEwJ4M9XdJPllUuQ9lYtgkkEDFcGlIN2BfaBGjqd xD9elZlbC9kPYyi0tmg5CQ414zppO097wosQd3vlbKjpS+g1L4Q/3GEX6x+zn2OC8bs+ iwt8Xlaz0+KQXgod8o4jgaovUABqS7ffRgjR1SaxmDTvOCkFq63BmCznc/CKnYkp9vZ8 jrEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MUI2qZVW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c925b81830si1280918385a.265.2025.04.23.05.07.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Apr 2025 05:07:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MUI2qZVW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u7YsS-0006tR-TU; Wed, 23 Apr 2025 08:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u7Yrc-0006bt-Gx for qemu-devel@nongnu.org; Wed, 23 Apr 2025 08:06:07 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u7YrZ-0000Ri-Bx for qemu-devel@nongnu.org; Wed, 23 Apr 2025 08:06:02 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43ea40a6e98so57327805e9.1 for ; Wed, 23 Apr 2025 05:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745409958; x=1746014758; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4ABcmb67Z+D6NBbWU+MI+QxoFhkrlR/XebxVhtqvxp0=; b=MUI2qZVW0LzgYtXyaUh/TDsidn5b3hvnTnPs2Kf84Cq/Qx60bwvopJZQsuLRv/xtF5 tdA8dTDvlJzOwowwCR3njhQlgN3MDo9t22mVPOOvXhCAANHPZQaZcYkAdvNiaSazdRB2 u5FCggAyuyvcDK7U45ngcB3TbSAc+zQng+achX6KYxMQEnFCdMkfrqzJ8yi+v8hl3WzB 8SPDS4bjidg/NouoEMKEXylPaGGqfT/rffC9UQX4fXHfHJXcHpcOcXH9JU+2EyKEU4gJ clSZk/GOskH1QDQqKUhKSnsLPFNS6zTV3wVdht8EtjHofshdsyZyV8prq8qbTuDPomft DlvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745409958; x=1746014758; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4ABcmb67Z+D6NBbWU+MI+QxoFhkrlR/XebxVhtqvxp0=; b=cst+QVTn9FFjmisEctHi/ocaYM8exX+4K6OfaUvTKV3liIpM6U5S9trdPFNII0xrSe 6BYWSZEDCXuM+bsMbjLBNbvlzc9Wj9S36qDSTWPHDajSMY5hAqzOn8UQn2U7HdJ1gaYZ KYR4R2p0uPGPgPogJJ7xbbao23NdkzjTR7i5K1L6bv81HXJMOun1wEgnRBJBQo5CJtGX hkYexzfwaX+wSHOOLFv8IDisaII0MYBgLiTBxmem5sFNC67xU7+9BhDbalwN1WtSlTLl 2d0lwQ4evbfrf1w+9e7TyNgohrI6norvznnp3Oz7iSnufTm4D98GIp0bssUyWwgwbNHd ry1A== X-Gm-Message-State: AOJu0YziEjAi7/8mhKUCQf6LU/BV+Etqj9Dq90/6xOu6i2XIF1rZYi0Q BzkYQj2/Z+GmGDVukA+ou1vWD4aiMpUbaqGeETZkpahJgB9jcvtlHMwcVP6S8eZccnfg5YQdNnA a X-Gm-Gg: ASbGnctQZAF3r+w7RU9yD3mKHSCZTXdprqfEn2XSLXSHPnogL3yzICN5lu8PELsaALf yWDbhIwXqrWMgBNfsr5DrCIQlqs1/IX3gP1sG8fm4qWFPmRZeUm5EdVzloC3HAY/W949tkSXpYd Agcb7yIi6amPw3bVgUuEdkKHyCz3xnAWLGXdWq0LO3mPaGnKJ3DOm+qzgpwgF5IGzk3A7iexort ECi2YQ+ns3uxgitGEi53UuHxqflAnlj7stDcDji6s0f5Wu/0hZHUG49sGb1sYlLae3lcZtPICCD 2ClV6knHojP47Z8ZRZzbhZW9xpi69E7fODga7oKxn4+1kVc0AM/zYI1KVy4iWnIJ9dE7+WRdBDi 4yf6wEh6G69rALuw= X-Received: by 2002:a05:600c:1c8f:b0:43c:f332:7038 with SMTP id 5b1f17b1804b1-4406ac1fe30mr130247675e9.21.1745409958553; Wed, 23 Apr 2025 05:05:58 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-44092d3ed88sm23733565e9.35.2025.04.23.05.05.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Apr 2025 05:05:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Troy Lee , Jamin Lin , Peter Maydell , Joel Stanley , qemu-arm@nongnu.org, Steven Lee , Andrew Jeffery , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH] hw/i2c/aspeed_i2c: Make AspeedI2CClass::gap an plain unsigned type Date: Wed, 23 Apr 2025 14:05:55 +0200 Message-ID: <20250423120555.21318-1-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert AspeedI2CClass::gap to plain unsigned, using '0' as "no gap" to avoid the followin UBSan warnings: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../hw/i2c/aspeed_i2c.c:1559:16 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../hw/i2c/aspeed_i2c.c:1583:16 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../hw/i2c/aspeed_i2c.c:1608:16 hw/i2c/aspeed_i2c.c:1608:16: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'uint8_t' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned) Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- include/hw/i2c/aspeed_i2c.h | 2 +- hw/i2c/aspeed_i2c.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h index 2c4c81bd209..098356e5bac 100644 --- a/include/hw/i2c/aspeed_i2c.h +++ b/include/hw/i2c/aspeed_i2c.h @@ -290,7 +290,7 @@ struct AspeedI2CClass { uint8_t num_busses; uint8_t reg_size; uint32_t reg_gap_size; - uint8_t gap; + unsigned gap; qemu_irq (*bus_get_irq)(AspeedI2CBus *); uint64_t pool_size; diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index a8fbb9f44a1..a45a4fd6cb7 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -1215,7 +1215,7 @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp) for (i = 0; i < aic->num_busses; i++) { Object *bus = OBJECT(&s->busses[i]); - int offset = i < aic->gap ? 1 : 5; + unsigned offset = i < aic->gap ? 1 : 5; if (!object_property_set_link(bus, "controller", OBJECT(s), errp)) { return; @@ -1556,7 +1556,6 @@ static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) aic->num_busses = 16; aic->reg_size = 0x80; - aic->gap = -1; /* no gap */ aic->bus_get_irq = aspeed_2600_i2c_bus_get_irq; aic->pool_size = 0x20; aic->pool_base = 0xC00; @@ -1580,7 +1579,6 @@ static void aspeed_1030_i2c_class_init(ObjectClass *klass, void *data) aic->num_busses = 14; aic->reg_size = 0x80; - aic->gap = -1; /* no gap */ aic->bus_get_irq = aspeed_2600_i2c_bus_get_irq; aic->pool_size = 0x20; aic->pool_base = 0xC00; @@ -1605,7 +1603,6 @@ static void aspeed_2700_i2c_class_init(ObjectClass *klass, void *data) aic->num_busses = 16; aic->reg_size = 0x80; aic->reg_gap_size = 0x80; - aic->gap = -1; /* no gap */ aic->bus_get_irq = aspeed_2600_i2c_bus_get_irq; aic->pool_size = 0x20; aic->pool_gap_size = 0xe0;