From nobody Tue Nov 21 15:54:30 2023 X-Original-To: questions@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 4SZTTc0TZZz51qvD for ; Tue, 21 Nov 2023 15:54:44 +0000 (UTC) (envelope-from 4250.82.1d5060005b7245c.5478f7b2b943b967fe6307ea52029e14@email-od.com) Received: from s1-b0c6.socketlabs.email-od.com (s1-b0c6.socketlabs.email-od.com [142.0.176.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4SZTTb1MRwz4QrT for ; Tue, 21 Nov 2023 15:54:43 +0000 (UTC) (envelope-from 4250.82.1d5060005b7245c.5478f7b2b943b967fe6307ea52029e14@email-od.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=email-od.com header.s=dkim header.b=ejztiVby; spf=pass (mx1.freebsd.org: domain of 4250.82.1d5060005b7245c.5478f7b2b943b967fe6307ea52029e14@email-od.com designates 142.0.176.198 as permitted sender) smtp.mailfrom=4250.82.1d5060005b7245c.5478f7b2b943b967fe6307ea52029e14@email-od.com; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; d=email-od.com;i=@email-od.com;s=dkim; c=relaxed/relaxed; q=dns/txt; t=1700582083; x=1703174083; h=content-transfer-encoding:content-type:mime-version:references:in-reply-to:message-id:subject:to:from:date:x-thread-info:subject:to:from:cc:reply-to; bh=EMUId/NDNQV2xBxt75cb/9nXAwJ7FPqqeRAYnB8MvuU=; b=ejztiVbyPmT9c0WzhKj20GQz4X9s4hO2pvklcdvtpb/rua5BmKsqNXn0KbqoZUmNGJ294Ot2AD2jYJD6NOCFEuKOczfC7oL+CczDNtGjRdfGYxLVfLbdTbhO3U7pDgEE1ubT2r77sa2B4B3MTpqRD9iENyBSjXFg/ZJGcB04/UU= X-Thread-Info: NDI1MC4xMi4xZDUwNjAwMDViNzI0NWMucXVlc3Rpb25zPWZyZWVic2Qub3Jn Received: from r1.us-east-1.aws.in.socketlabs.com (r1.us-east-1.aws.in.socketlabs.com [142.0.191.1]) by mxsg2.email-od.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Tue, 21 Nov 2023 10:54:32 -0500 Received: from smtp.lan.sohara.org (EMTPY [185.202.17.215]) by r1.us-east-1.aws.in.socketlabs.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Tue, 21 Nov 2023 10:54:31 -0500 Received: from [192.168.63.1] (helo=steve.lan.sohara.org) by smtp.lan.sohara.org with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1r5T54-000O0D-P3 for questions@freebsd.org; Tue, 21 Nov 2023 15:54:30 +0000 Date: Tue, 21 Nov 2023 15:54:30 +0000 From: Steve O'Hara-Smith To: questions@freebsd.org Subject: Re: What are __dead2 and __unused in the source code? Message-Id: <20231121155430.cd97ea3907173a80c7655e14@sohara.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd13.1) X-Clacks-Overhead: "GNU Terry Pratchett" List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-1.70 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; FORGED_SENDER(0.30)[steve@sohara.org,4250.82.1d5060005b7245c.5478f7b2b943b967fe6307ea52029e14@email-od.com]; R_SPF_ALLOW(-0.20)[+ip4:142.0.176.0/20]; R_DKIM_ALLOW(-0.20)[email-od.com:s=dkim]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[142.0.191.1:received]; DMARC_NA(0.00)[sohara.org]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DWL_DNSWL_NONE(0.00)[email-od.com:dkim]; MLMMJ_DEST(0.00)[questions@freebsd.org]; DKIM_TRACE(0.00)[email-od.com:+]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:7381, ipnet:142.0.176.0/22, country:US]; FROM_NEQ_ENVFROM(0.00)[steve@sohara.org,4250.82.1d5060005b7245c.5478f7b2b943b967fe6307ea52029e14@email-od.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[142.0.176.198:from] X-Rspamd-Queue-Id: 4SZTTb1MRwz4QrT X-Spamd-Bar: - On Tue, 21 Nov 2023 15:12:51 +0100 Mehdi Khawari wrote: > Hi, everyone! > > I'm just learning by studying the source code of some basic tools > included in the base and I had a question. These macros are defined in /usr/include/sys/cdefs.h, they're hints to the compiler to prevent warnings that would otherwise occur and break the build with --Wall which turns all warnings into errors. > Why is __dead2 applied to some function like usage? > static void usage(void) __dead2; __dead2 hints that the function is not expected to return. > What is the reason that __unused is applied to the function argument like > here: __unused lets the compiler know that this parameter is not used intentionally. > static void > siginfo_handler(int sig __unused) > { > siginfo = 1; > } > These snippets are from /bin/chmod/chmod.c. Where can I find more > information on this? In each case without the hint the compiler would throw a warning, which the default --Wall option would turn into an error. There's a NetBSD manpage which covers similar constructs, but there doesn't seem to be a FreeBSD version of it. https://man.netbsd.org/NetBSD-6.1/__dead.3 -- Steve O'Hara-Smith