Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S270409AbTGMV1S (ORCPT ); Sun, 13 Jul 2003 17:27:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S270411AbTGMV1S (ORCPT ); Sun, 13 Jul 2003 17:27:18 -0400 Received: from netrider.rowland.org ([192.131.102.5]:12817 "HELO netrider.rowland.org") by vger.kernel.org with SMTP id S270409AbTGMV1R (ORCPT ); Sun, 13 Jul 2003 17:27:17 -0400 Date: Sun, 13 Jul 2003 17:42:03 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Horst von Brand cc: Linux Kernel Mailing List Subject: Re: Style question: Should one check for NULL pointers? In-Reply-To: <200307121840.h6CIeKIj004212@eeyore.valparaiso.cl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1085 Lines: 33 On Sat, 12 Jul 2003, Horst von Brand wrote: > Alan Stern said: > > [...] > > > But if you look very far through the kernel sources you will see many > > occurrences of code similar to this: > > > > static void release(struct xxx *ptr) > > { > > if (!ptr) > > return; > > ... > > > > I can't see any reason for keeping something like that. > > Just like free(3) NO! Not just like free(). The documentation for free() explicitly states that NULL pointers are valid input and result in no action. A release()-type function, by contrast, is called back from core system code that guarantees it will always pass a pointer to the currently-registered owner of the corresponding resource. If the owner were NULL, the release() function wouldn't have been called in the first place. Alan Stern - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/