Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbWHPRs7 (ORCPT ); Wed, 16 Aug 2006 13:48:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751231AbWHPRs7 (ORCPT ); Wed, 16 Aug 2006 13:48:59 -0400 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:49633 "EHLO ebiederm.dsl.xmission.com") by vger.kernel.org with ESMTP id S1751230AbWHPRs6 (ORCPT ); Wed, 16 Aug 2006 13:48:58 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Jan Engelhardt Cc: Dave Hansen , Andrew Morton , linux-kernel@vger.kernel.org, containers@lists.osdl.org, Oleg Nesterov Subject: Re: [PATCH 5/7] pid: Implement pid_nr References: <1155666193751-git-send-email-ebiederm@xmission.com> <1155667063.12700.56.camel@localhost.localdomain> Date: Wed, 16 Aug 2006 11:48:25 -0600 In-Reply-To: (Jan Engelhardt's message of "Wed, 16 Aug 2006 18:27:18 +0200 (MEST)") Message-ID: User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) 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: 1097 Lines: 32 Jan Engelhardt writes: >>> +static inline pid_t pid_nr(struct pid *pid) >>> +{ >>> + pid_t nr = 0; >>> + if (pid) >>> + nr = pid->nr; >>> + return nr; >>> +} >> >>When is it valid to be passing around a NULL 'struct pid *'? > > Is 0 even the right thing to return in the rare case that pid == NULL? > -1 maybe? I believe 0 is what we have used elsewhere. A negative value for a pid is likely to be taken as the group of all processes, or -EPERM, and it does really confusing things when fed through the current f_getown implementation, with PIDTYPE_PGRP. The only other possible interpretations of 0 are the idle process and yourself. There is still some potential there, but largely 0 is much less likely to be confused than -1. Especially as it doesn't change when you negate it. Eric - 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/