From owner-freebsd-hackers@FreeBSD.ORG Sun Nov 30 19:41:54 2008 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 D76A6106564A for ; Sun, 30 Nov 2008 19:41:54 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from kientzle.com (kientzle.com [66.166.149.50]) by mx1.freebsd.org (Postfix) with ESMTP id B20528FC14 for ; Sun, 30 Nov 2008 19:41:54 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from [10.123.2.178] (p53.kientzle.com [66.166.149.53]) by kientzle.com (8.12.9/8.12.9) with ESMTP id mAUJfZtv095340; Sun, 30 Nov 2008 11:41:35 -0800 (PST) (envelope-from kientzle@freebsd.org) Message-ID: <4932EC6A.1070205@freebsd.org> Date: Sun, 30 Nov 2008 11:41:30 -0800 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060422 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Eitan Adler References: <49320FF7.4040901@gmail.com> <4932122A.8070209@delphij.net> <493214DC.2080904@gmail.com> In-Reply-To: <493214DC.2080904@gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, d@delphij.net Subject: Re: change to ee.c 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: Sun, 30 Nov 2008 19:41:54 -0000 Eitan Adler wrote: > Xin LI wrote: >>Tanks for interested in this but I'm afraid that your patch is >>incorrect. mkstemp returns a file descriptor rather than a string >>pointer, therefore, the subsequent open() would have undefined behavior. >> It looks like that we actually want fd = mkstemp() here. > > Thanks. If this is the case how come gcc did not return any warnings? Try to think of compiler warnings as a luxury. For a variety of reasons (some having to do with the somewhat permissive nature of the C language), it's extremely hard for the compiler to detect anything other than the most blatant screw-ups. Whenever using a new function, pay very careful attention to the man pages: man mkstemp clearly says that mkstemp returns a file descriptor: "The mkstemp() function ... creates the template file, mode 0600, returning a file descriptor opened for reading and writing." Tim