From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752936AbbDDRV5 (ORCPT ); Sat, 4 Apr 2015 13:21:57 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:24676 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752574AbbDDRVy (ORCPT ); Sat, 4 Apr 2015 13:21:54 -0400 X-IronPort-AV: E=Sophos;i="5.11,523,1422918000"; d="scan'208";a="108355314" Date: Sat, 4 Apr 2015 19:21:51 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: Dan Carpenter cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] staging: emxx_udc: test returned value In-Reply-To: <20150404171243.GY10964@mwanda> Message-ID: References: <1428159570-19467-1-git-send-email-Julia.Lawall@lip6.fr> <1428159570-19467-3-git-send-email-Julia.Lawall@lip6.fr> <20150404160712.GA19278@kroah.com> <20150404171243.GY10964@mwanda> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 4 Apr 2015, Dan Carpenter wrote: > On Sat, Apr 04, 2015 at 06:20:53PM +0200, Julia Lawall wrote: > > Couldn't one say: > > > > x = NULL; > > y = &x->whatever; > > z = container_of(y, struct blah, whatever); > > > > and end up with z being NULL? > > That is crazy person code. It looks deliberately wrong. If we start > merging deliberate mistakes then we're already screwed. > > I have a smatch check which warns on container_of() but I should update > it to not complain if it's the first struct member. I have looked at > quite a few of these warnings and I worry that there are some places > where it relies on container_of() to be a no-op... That's also crazy > but it's the kind of crazy that people do in real life. :P OK. Should I update the patch to remove the test? I find 57 NULL tests on the result of container_of in the kernel as a whole. julia