From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 30 04:58:40 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 63A9216A407 for ; Fri, 30 Jun 2006 04:58:40 +0000 (UTC) (envelope-from hnazfoo@googlemail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by mx1.FreeBSD.org (Postfix) with ESMTP id AC76B446EB for ; Fri, 30 Jun 2006 04:58:39 +0000 (GMT) (envelope-from hnazfoo@googlemail.com) Received: by nf-out-0910.google.com with SMTP id c29so199267nfb for ; Thu, 29 Jun 2006 21:58:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:date:from:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=BrX9KAmTFUDalSAZubOQR9iFS9acksNN9oNiGZa7wMINjivVr8uoOvjGRYjO+dElYQHYlpwsbHFmr8dHxrDpgwH/keuFa3vHYndrHUZ9Z9jhu9ssdrqJM/KiSSniK6k8OUkUpP/0h4fUpE8kuyybyGX4LyZIq6STGXwXBaCpMhM= Received: by 10.48.223.17 with SMTP id v17mr257518nfg; Thu, 29 Jun 2006 21:58:38 -0700 (PDT) Received: from localhost ( [217.65.22.47]) by mx.gmail.com with ESMTP id p72sm1115736nfc.2006.06.29.21.58.36; Thu, 29 Jun 2006 21:58:37 -0700 (PDT) Date: Fri, 30 Jun 2006 06:59:37 +0200 From: Johannes Weiner To: freebsd-hackers@freebsd.org Message-ID: <20060630045937.GB97868@leiferikson.flosken.lan> Mail-Followup-To: freebsd-hackers@freebsd.org References: <20060628181045.GA54915@curry.mchp.siemens.de> <20060629054222.GA92895@leiferikson.flosken.lan> <20060629162319.GA94921@leiferikson.flosken.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: mutt-ng/devel-r804 (FreeBSD) Subject: Re: Return value of malloc(0) 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, 30 Jun 2006 04:58:40 -0000 Hi, On Thu, Jun 29, 2006 at 07:29:16PM +0200, Matthias Andree wrote: > No, sir. Operator precedence: assign first, and then compare, thus the > comparison will always be true (else you'd be comparing to undefined > values, which isn't any better). You might as well write: > > foo = malloc(0); > /* make noise */ Ok, just for having it done: if (foo == (foo = some_val)) .. would be right to check if foo stayed the same. No? > There is no way to see a 0x800 return from malloc(0) as "error". So noone should actually use malloc(0) and check the size_t argument before passing it, I guess. Hannes -- One must still have chaos in oneself to be able to give a birth to a dancing star.