From nobody Sat Nov 15 12:48:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752516068; cv=none; d=zohomail.com; s=zohoarc; b=FSmO1LLBz3e5aIN0SsYOGShOH9LWVfx7I32j/0Z/63TdFEiCR/YKqSP2hTC7iuX0YIuvinwfaULYjqlTPC7Hyn5CT/3rCgNqqsRfU9iqu0tM5RONq8I6RG0b1RQBYkti9z5+cn0IJBGGvt0tsRNbi6U44RHdOHlB3tpZobnpvEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752516068; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XB8LV3wRsOBPp4JPpXFjqFOjZLlAFG+bPFbYCEIwFxs=; b=JU87j/v5OBvtCcTrlQ79P4YfjB6pwt9sqR88MqrxyA2wO2eunAzldygntGZ1Kx5j9h9jRJe3aiL++6nBR36GMm5vfcw/IYgE8yg2z6IolXF61rM1usGuyOPTesbDh2J0jm3h/1SatviyYGihivzmFWCO1WOV4mmU9o9iIzv4XbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752516068347231.89053164907375; Mon, 14 Jul 2025 11:01:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubNTj-0004DP-A1; Mon, 14 Jul 2025 14:00:40 -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 1ubMSk-0004a5-8R for qemu-devel@nongnu.org; Mon, 14 Jul 2025 12:55:34 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ubMSi-0001JP-6U for qemu-devel@nongnu.org; Mon, 14 Jul 2025 12:55:33 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-455e6fb8057so32482895e9.3 for ; Mon, 14 Jul 2025 09:55:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b5e8bd15bfsm13164665f8f.19.2025.07.14.09.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 09:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752512130; x=1753116930; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XB8LV3wRsOBPp4JPpXFjqFOjZLlAFG+bPFbYCEIwFxs=; b=Owg0guTatUlOe0bdf2ohgOheEFnIRITumbe3LrFvhDV3I+J/osTnc7UPuM+d0LygaA +w0UtvQEcBHLKytPT6jBOaLTMWnNFvF5CrvSK3GBDvBMTDJr4ACRfnDDbbAg/D5XyUcd G6B6k6IuWTho7S/lQO38gill8lNxmIT/W1rLe6rmMqRiBwPYFxo//FtPMSm0xFZkl2T3 Ajm9xIjXDqNsq6IdYHhK/UQsIOhthKBs2I5H12P+FWDxMaGbI0Tzr9a0Z5FacKDxM6QG BSrv7MQf3m+1V0tDVXvlp5QsgKiYI/58Sl5d6xQSiav/XYmc1pbGYoQvEgND5A2AG0Gn T3tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752512130; x=1753116930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XB8LV3wRsOBPp4JPpXFjqFOjZLlAFG+bPFbYCEIwFxs=; b=YcsN6FU5xKP5imgGSPPjoz3Yu/V/e1qtCsRPE3O7htGcxE6dYMmdFaHk98uaXky85S P8kX87AHZcdEU+ABYKmGofsYTv6CmKxxIn7eczvznWXwoEWvSW3pej4Kquxayk+7ZptH NUXBknRotZkKxGPoT93oi197N9f1xSNxrmQv3IIRkLKetDpiPd2W59MrBzVj02oAL/Nt ZqqujV9BPfvouRmWfMDT5k3kkhXz43QEVtkQ7iQlQEAL0aTtvnMPZhPPzL+OJISi1/OO 5VKJMxBAPi6101eG5HFrFbVPvjpVm/50Geqr1un7Q9PEAOB6CnDzxJae1skcUnZ7ItO5 uLjw== X-Forwarded-Encrypted: i=1; AJvYcCXW3qHxJLtrtuv08buaHV3S91rqbx1iq/Z88dPFtprg2Yzzf+6MTQyn6u95NbGuTloD7WmHLTdqdFC1@nongnu.org X-Gm-Message-State: AOJu0YyRpgeac2Jy2INkOVOJOgmYoDgUJEykomHuNYRFzfSjdUauLw7E hHLN7mTzgBU/l229rpgbNL8a05aeP4xsR+5rphRwnS4nu28wYxmVNtS4Bp81Ve2/hapIp+2BWOj dJ18N X-Gm-Gg: ASbGnctlwRyE6yJ8yz+Gwj4FA6v1v8uNHkb7QUr7OnwNOj+xq3YYadr437O2QQhENng qIgyhoV3FZAhkrcm72yE65nNAPVjXSE0XjAkxSHlSNnwvfn6vwZ6kcA7hI27ogIjvooDNa8qKTw vbJ9QyrofmzFRsY5H8S4f+3EBI9eX1iftYR6yw664q1Kg4uxyyvOtzuw94DAz03+BNtxMSeCi4P 8/ntM1DlgsD+j6ws1DEj8e4zgUMU2s7WdCfiRHVldLVenR9yFsCqdTDh9lLi3nKSuXH58P5QgDE //JwzVc9tD9Su/w9TsRWT2lXX1az1RfgGLRDRVy5VfdOR0Par7Pkh+nyXXa8+F0Hi+F/Uyy4Etn XKRYlqgDKzqpcBwEFpgn6/VUhxDyT X-Google-Smtp-Source: AGHT+IH+/REJ7B+DItU8aASH5jnaoFcfOBxm3LgKHunU9aheiEThUjx2kOxgBM45dgVhV+9NQZKjCg== X-Received: by 2002:a05:6000:1882:b0:3a3:6595:9209 with SMTP id ffacd0b85a97d-3b5f2dfdfdfmr11245919f8f.36.1752512130542; Mon, 14 Jul 2025 09:55:30 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Tyrone Ting , Hao Wu , Jason Wang Subject: [PATCH 4/4] hw/net/npcm_gmac.c: Drop 'buf' local variable Date: Mon, 14 Jul 2025 17:55:23 +0100 Message-ID: <20250714165523.1956235-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714165523.1956235-1-peter.maydell@linaro.org> References: <20250714165523.1956235-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1752516070784116600 Content-Type: text/plain; charset="utf-8" We use the local variable 'buf' only when we call dma_memory_read(), and it is always set to &tx_send_buffer[prev_buf_size] immediately before both of those calls. So remove the variable and pass tx_send_buffer + prev_buf_size to dma_memory_read(). This fixes in passing a place where we set buf =3D tx_send_buffer but never used that value because we always updated buf to something else later before using it. Coverity: CID 1534027 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/npcm_gmac.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/net/npcm_gmac.c b/hw/net/npcm_gmac.c index 0c17ae9b2a9..5e32cd3edf3 100644 --- a/hw/net/npcm_gmac.c +++ b/hw/net/npcm_gmac.c @@ -516,7 +516,6 @@ static void gmac_try_send_next_packet(NPCMGMACState *gm= ac) uint32_t desc_addr; struct NPCMGMACTxDesc tx_desc; uint32_t tx_buf_addr, tx_buf_len; - uint8_t *buf =3D tx_send_buffer; uint32_t prev_buf_size =3D 0; int csum =3D 0; =20 @@ -567,16 +566,15 @@ static void gmac_try_send_next_packet(NPCMGMACState *= gmac) tx_buf_addr =3D tx_desc.tdes2; gmac->regs[R_NPCM_DMA_CUR_TX_BUF_ADDR] =3D tx_buf_addr; tx_buf_len =3D TX_DESC_TDES1_BFFR1_SZ_MASK(tx_desc.tdes1); - buf =3D &tx_send_buffer[prev_buf_size]; =20 if ((prev_buf_size + tx_buf_len) > tx_buffer_size) { tx_buffer_size =3D prev_buf_size + tx_buf_len; tx_send_buffer =3D g_realloc(tx_send_buffer, tx_buffer_size); - buf =3D &tx_send_buffer[prev_buf_size]; } =20 /* step 5 */ - if (dma_memory_read(&address_space_memory, tx_buf_addr, buf, + if (dma_memory_read(&address_space_memory, tx_buf_addr, + tx_send_buffer + prev_buf_size, tx_buf_len, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read packet @ 0x= %x\n", __func__, tx_buf_addr); @@ -589,15 +587,14 @@ static void gmac_try_send_next_packet(NPCMGMACState *= gmac) tx_buf_addr =3D tx_desc.tdes3; gmac->regs[R_NPCM_DMA_CUR_TX_BUF_ADDR] =3D tx_buf_addr; tx_buf_len =3D TX_DESC_TDES1_BFFR2_SZ_MASK(tx_desc.tdes1); - buf =3D &tx_send_buffer[prev_buf_size]; =20 if ((prev_buf_size + tx_buf_len) > tx_buffer_size) { tx_buffer_size =3D prev_buf_size + tx_buf_len; tx_send_buffer =3D g_realloc(tx_send_buffer, tx_buffer_siz= e); - buf =3D &tx_send_buffer[prev_buf_size]; } =20 - if (dma_memory_read(&address_space_memory, tx_buf_addr, buf, + if (dma_memory_read(&address_space_memory, tx_buf_addr, + tx_send_buffer + prev_buf_size, tx_buf_len, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read packet @ 0x%x\n", @@ -615,7 +612,6 @@ static void gmac_try_send_next_packet(NPCMGMACState *gm= ac) net_checksum_calculate(tx_send_buffer, length, csum); qemu_send_packet(qemu_get_queue(gmac->nic), tx_send_buffer, le= ngth); trace_npcm_gmac_packet_sent(DEVICE(gmac)->canonical_path, leng= th); - buf =3D tx_send_buffer; prev_buf_size =3D 0; } =20 --=20 2.43.0