From nobody Thu May 29 05:16:45 2025 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4b7F3g2vrcz5xm9w for ; Thu, 29 May 2025 05:17:03 +0000 (UTC) (envelope-from theron.tarigo@gmail.com) Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b7F3f6NXkz3nXM for ; Thu, 29 May 2025 05:17:02 +0000 (UTC) (envelope-from theron.tarigo@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-2c873231e7bso384144fac.3 for ; Wed, 28 May 2025 22:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748495821; x=1749100621; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=mDfNMmBGzhbihxgseDZiXDTa3pZbX+u7129pIKSmcNs=; b=MsblBIWYfJT8zWsx5mYeK1NZlzyiMKpggSdC5gZ2HBoYgLHv/oJddblF4wAMJYr19u wmftJk0VfWVO097/XEwy39mRqGkcXLPW0SuVlrld0XOv/jZ5i1KpphcVa3i0RWN3C7PN 6PQ8kIdIr45/jIJMGmfY7dKMXXY72JxNvt+ak/uApCujGZELmfrvlbR4Pd5ytnQHS/Ml YCFjKbpLgcXJocWVVd5w2V1tmu2HPRpIg/xOya3JOJaSFiGx9flQxXuitt+LW5t/CxmG yt08ofarY30D/GJutCvF56ecUPWXW5rqp4j+a+KRrhCFAUBO9F+I6pqLvRR9QTXD4ZES k5Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748495821; x=1749100621; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mDfNMmBGzhbihxgseDZiXDTa3pZbX+u7129pIKSmcNs=; b=di+3DSsElQePrqIS++ruUtC25+NYIogq3abJvGHeWH03t1+8Tjd4g6Pwvnkgmh5JZy 208wGsd/SH9pXFQ+FR0oKrB+koToeNK7gbNvc1IAJsyWTkshA8QXxrjdNcFdpcWWYTAU fAtgzCU+gXfi+w7orbP+TGzVJYu2QIktSK62q5VpfzhHkeWy5OEjhdGKjtC3NwjDK5LS sjAkf9ekX/BWr6nfOwgyMh+1wy5TDHYkrXCtAXxm+h5Mjk7vaD6VOuC5nOLYwLSgWJS0 CJe2NYEpkEnhxOigaMD9eVjvzNbhXWsFm94p0DohXDEOv99ZjIEcDVS5vVaeYqnekfv6 Mhvg== X-Gm-Message-State: AOJu0YzUJ76lcG+gtXo+Cu5K93/gdGP9GRgG6WSBq3iXvVu9qwShnAAl sFA69ODEIgDhH2Ee6cmlREqTr1iT9BKq7+jZQf63fS9EidSL7Rdw9xAuuhavHQ== X-Gm-Gg: ASbGncvJUJHSXGZD0a+ULOUxU9qyCeAeSdCjDxwJfbnkXSTb2bhoyeezn310bLS1h0h XjfNln0rFWC8gszMrMtLj/21jj1W0daquIxJN1o+dCtXB6pJM3esGJzlkQNlkE/C4hK9g7Peu7v meUymMCYU0R5EsVsVJkQ49VPxbbMadNe3buLP6ynaNdSBImqhkNnqVPZHTbfpdqBLBkIGvHiwse BEJr+qC3NmM0ynYo72tSWWlZEXVV1W9AeNO83PxF0aoBsC/OTM6sOsPrfKPUicQJIS0s5rXX+bW 0rvPZCKypH5ZLWCylDAwrO7pvfEk1bIgC6zhd7hGxi1al+MnwTnEKCIn X-Google-Smtp-Source: AGHT+IGLAHQtrtNwENEWv6IfQ4dKGC02J0QP7L4dB7cp3CzOIzWgIz3Choph1HCB0Pg5ZSbd4gElIA== X-Received: by 2002:a05:620a:1a87:b0:7c7:bb3f:fd40 with SMTP id af79cd13be357-7ceecbb269dmr2851431785a.5.1748495811144; Wed, 28 May 2025 22:16:51 -0700 (PDT) Received: from [192.168.2.32] ([71.181.93.185]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d09a195c67sm51652985a.75.2025.05.28.22.16.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 May 2025 22:16:50 -0700 (PDT) Message-ID: <477cc25e-3c97-4982-b3e2-f3935dd47944@gmail.com> Date: Thu, 29 May 2025 07:16:45 +0200 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Self assigning variable, ie x = x To: Farhan Khan Cc: FreeBSD Hackers References: <2528E3FE-A09D-45D6-9BBD-147EB5364B79@FreeBSD.org> <1a7daaac-a53a-40d2-bda6-1b401f5a6321@app.fastmail.com> Content-Language: en-US From: Theron In-Reply-To: <1a7daaac-a53a-40d2-bda6-1b401f5a6321@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2001:4860:4864::/48, country:US] X-Rspamd-Queue-Id: 4b7F3f6NXkz3nXM X-Spamd-Bar: ---- On 5/29/25 00:39, Farhan Khan wrote: > In my experience, compilers do not complain about an unused variable passed to a function, but they complain if you initialized the variable in the function and then didn't use it. At least in clang there are separate warning flags for each case: -Wunused-variable, -Wunused-parameter, -Wunused-but-set-variable, -Wunused-but-set-parameter. Of these, only those for variables are included in -Wall. Note that under -Wall, the assignments you have found are themselves a warning -Wself-assign. > That example was from contrib, but there are other instances that are not upstream, such as in the `pms` driver. sys/dev/pms/RefTisa/... get away with it because despite the many warning flags, they are also compiled with -w. Clearly these self-assignments were done to please a different compiler than the one we have now.