From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 16 10:03:52 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D23DA106564A for ; Fri, 16 Jan 2009 10:03:52 +0000 (UTC) (envelope-from prvs=12673418ee=christian.kandeler@hob.de) Received: from mailgate.hob.de (mailgate.hob.de [212.185.199.3]) by mx1.freebsd.org (Postfix) with ESMTP id 926E98FC08 for ; Fri, 16 Jan 2009 10:03:52 +0000 (UTC) (envelope-from prvs=12673418ee=christian.kandeler@hob.de) Received: from imap.hob.de (mail2.hob.de [172.25.1.102]) by mailgate.hob.de (Postfix) with ESMTP id 6E2F1520068 for ; Fri, 16 Jan 2009 10:39:01 +0100 (CET) Received: from linux04.hob.de (linux04.hob.de [172.22.0.192]) by imap.hob.de (Postfix on SuSE eMail Server 2.0) with ESMTP id 2A530FD861 for ; Fri, 16 Jan 2009 10:38:13 +0100 (CET) From: Christian Kandeler Organization: HOB To: freebsd-hackers@freebsd.org Date: Fri, 16 Jan 2009 10:39:00 +0100 User-Agent: KMail/1.9.1 References: <7d6fde3d0901160041n55466290l55f737d274a40895@mail.gmail.com> <49704AEC.3080709@gmx.de> In-Reply-To: <49704AEC.3080709@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200901161039.00232.christian.kandeler@hob.de> Subject: Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jan 2009 10:03:53 -0000 On Friday 16 January 2009 09:53, Christoph Mallon wrote: > > int > > main() { > > > > int mib[4]; > > > > size_t len; > > > > if (sysctlnametomib("kern.ipc.shmmax", mib, &len) != 0) { > > printf("Errno: %d\n", errno); > > errx(errno, "Error: %s", strerror(errno)); > > The use of errno is wrong. printf might change errno. I don't think printf() can set errno. And even if it could, it wouldn't matter, because C has call-by-value semantics. Christian