From owner-freebsd-stable@FreeBSD.ORG Tue May 27 08:02:18 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B144106564A for ; Tue, 27 May 2008 08:02:18 +0000 (UTC) (envelope-from z@zlo.nu) Received: from mzh.zlo.nu (ns0.zlo.nu [85.17.141.90]) by mx1.freebsd.org (Postfix) with ESMTP id 248998FC2F for ; Tue, 27 May 2008 08:02:17 +0000 (UTC) (envelope-from z@zlo.nu) Received: by mzh.zlo.nu (Postfix, from userid 1000) id 6D8A314232; Tue, 27 May 2008 09:45:18 +0200 (CEST) Date: Tue, 27 May 2008 09:45:18 +0200 From: Marc Olzheim To: Krassimir Slavchev Message-ID: <20080527074518.GA2593@zlo.nu> References: <483AEFFE.8080302@bulinfo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <483AEFFE.8080302@bulinfo.net> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: FreeBSD Subject: Re: shmat() return values? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 May 2008 08:02:18 -0000 On Mon, May 26, 2008 at 08:14:38PM +0300, Krassimir Slavchev wrote: > Hello, > > When I try: > > if ((*shm = shmat(shmid, NULL, 0)) == -1) > > The gcc complains with: > warning: comparison between pointer and integer > > shmat() is declared in shm.h as: > void *shmat(int, const void *, int); > > but 'man 4 shmat; > > RETURN VALUES > Upon success, shmat() returns the address where the segment is > attached; > otherwise, -1 is returned and errno is set to indicate the error. > > > What is the correct return value on failure, -1 or NULL? > I think it should be NULL? The return value is a void pointer, with value equivalent to -1, so (void *)-1 So you can replace it with: if ((*shm = shmat(shmid, NULL, 0)) == (void*)-1) Marc