From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 16 10:21:26 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 0D8C710656C4 for ; Fri, 16 Jan 2009 10:21:26 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 4FFE58FC29 for ; Fri, 16 Jan 2009 10:21:25 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 16 Jan 2009 10:21:23 -0000 Received: from p54A3E7DB.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.231.219] by mail.gmx.net (mp060) with SMTP; 16 Jan 2009 11:21:23 +0100 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX19KhO5QHnpKTGYJZgc8hjSdhtg+kY83+KzKPNnT8A GASGyd95RK03/e Message-ID: <49705FA2.2020605@gmx.de> Date: Fri, 16 Jan 2009 11:21:22 +0100 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Christian Kandeler References: <7d6fde3d0901160041n55466290l55f737d274a40895@mail.gmail.com> <49704AEC.3080709@gmx.de> <200901161039.00232.christian.kandeler@hob.de> In-Reply-To: <200901161039.00232.christian.kandeler@hob.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5600000000000001 Cc: freebsd-hackers@freebsd.org 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:21:27 -0000 Christian Kandeler schrieb: > 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 Of course it can. See ISO/IEC 9899:1999 (E) §7.5:3. > wouldn't matter, because C has call-by-value semantics. This has nothing to do with call-by-value. errno is read (even twice!) *after* the call to printf().