WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] [PATCH] Pointer should be checked before use

To: "Ian Jackson" <Ian.Jackson@xxxxxxxxxxxxx>, "Keir Fraser" <Keir.Fraser@xxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH] Pointer should be checked before use
From: "Yang, Xiaowei" <xiaowei.yang@xxxxxxxxx>
Date: Wed, 9 Jan 2008 22:37:58 +0800
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 09 Jan 2008 06:49:42 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <18308.40274.237473.690256@xxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <8C834404208B254EAD4E532C948598690135D10D@xxxxxxxxxxxxxxxxxxxxxxxxxxxx><C3AA3877.11E13%Keir.Fraser@xxxxxxxxxxxx> <18308.40274.237473.690256@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AchSqBMe0N8LPWUHQ4O0216Gxsy9xAAIcC1Q
Thread-topic: [Xen-devel] [PATCH] Pointer should be checked before use
>Callers should not pass null pointers.  If they do it is better for
>the program to explode sooner than later; that makes tracking the
>fault much easier.
>
>So this kind of check, turning incoming null pointers into error
>returns, is a bad idea.
>

That may be better for debug tracking to let the caller process
segfault:). However, IMO as a function it's almost always a good
practice to check the parameters' validation before using it. Returning
an error if the caller passes invalid arguments is a more normal
behavior than directly letting the process be killed due to no argument
check. It may be too strict.

Regards,
Xiaowei

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel