From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753162AbbDDRNE (ORCPT ); Sat, 4 Apr 2015 13:13:04 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:48573 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753128AbbDDRNB (ORCPT ); Sat, 4 Apr 2015 13:13:01 -0400 Date: Sat, 4 Apr 2015 20:12:43 +0300 From: Dan Carpenter To: Julia Lawall 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 Message-ID: <20150404171243.GY10964@mwanda> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 regards, dan carpenter