From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753017AbcHOPiy (ORCPT ); Mon, 15 Aug 2016 11:38:54 -0400 Received: from mout.web.de ([217.72.192.78]:61070 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752748AbcHOPiw (ORCPT ); Mon, 15 Aug 2016 11:38:52 -0400 Subject: Re: CodingStyle: Clarify and complete chapter 7 To: Mark D Rustad References: <20160725142906.003bfe06@endymion> <20160814123024.79c2082a@lwn.net> Cc: Jonathan Corbet , Jean Delvare , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org From: SF Markus Elfring Message-ID: <633ca313-25b3-a9fe-bbed-883ca0273905@users.sourceforge.net> Date: Mon, 15 Aug 2016 17:38:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:Wlz3Xv/7IphZeOe6asl6xjbqyCxay8ZYRe7XznbmG2MVc0gmPTk rfRXxAym6IQHFUA7x5CrDi1YwQKsPyORhkCm3JCMz+0Ey42T9YQWwYJWGBP3tEK9dbq4OIO 7267zt1IFiySpbthztNEKrY/RgOMJ0WuHcQDJBVGGOAeGsG2hGxPdgQFGjfcpQvW481rRHG eCCGm6/FOXQcNBnWmgESw== X-UI-Out-Filterresults: notjunk:1;V01:K0:hPV1cveB5cw=:H/cu+TQAI8ZbQ5/vMJEl9k hB7lqg5ZMIPnDiU8tt1lMIWejTbrJIFYO1hp6YOI4O2bWON/CRBc2EsB7amsBR4/U1CzQr/9g xs5tTD4VEq2oXaZst7KKJOSK77P09N9aCp18NKELbsDQKwLsptW51a+L8tjWZK0qN/M92A7ad /tnrXGZfkogUyEBJGku0jqV2zkjfSoBNSJZRersgT3Ao7IybXnJjS7pUpK4KXX8PPB0bdExis xxgOWl4tfRsKtWSzHVLKxfpUpJBjpZ6bTUSesmMO6M6ZHOevYTmj0TuGGe6ZQJtT5PyXPsNOj 8XpQdbA7jxct1H6uz7SfKYOi7kV7i/VaJ19IAsNPX8VgpWg0TwGm7og+Y47bzx7fJ3f7yAd3V gM0n3jmIe/KnTkkFXGEhcIvU78pEaGTrGTWxY7Bl/sJfkNlyoEUhnUgMcBmtEdEuiTJ9ZLr8p PZFZLFRDtlqYxZ9eVydifvpLoup5qjgX1EDWzBWk08pXu1TMU1QV+r2o851HGGiIAxCpGkrRJ DPo/giq7PscGMDUflddvslLxJuRVPycRzdXWmiq0bvOS/lbipU3uWmS3pJBo/I3wQGFVLtWUZ GFYu711vX6yQbK0wOgI3CzWc6sm3Lmz8xesF9aFN3azpb6H/V1PwPNXb8FFdPNwrWfnKXDiiD DQ1dZJ1jG4P5X/zJ9z4hRwJX3WK8PgRdA6G1BsHfdyVg7FQKjdqv6E15CCttsRSErzotQF/da fjTCEOP2yVMVTJf20olpiGZWvVrDmoSaUcACRfoOxc23NyM5as9yFPXcIkeqSqJe3P99f07F9 +PvdiKq Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> A common type of bug to be aware of is "one err bugs" which look like this: >>> >>> - err: >>> + err: >>> kfree(foo->bar); >>> kfree(foo); >>> return ret; >>> >>> The bug in this code is that on some exit paths "foo" is NULL. Normally the >> >> ...except that kfree() can handle null pointers just fine, so this isn't >> actually a bug, right? Someday when somebody has time it would be good to >> come up with a better example. > > But if foo is NULL, An important condition … > foo->bar is not NULL I wonder about this information. Which run-time environment will provide this behaviour? > and so kfree will have a problem with it. I find that the parameter evaluation will result in side effects (because of a null pointer access) which are usually unwanted. So the execution of this function call will eventually not start. > So this is a bug. How do you think about further software development possibilities to improve corresponding exception handling? How much can the selection of jump labels influence the software design? Regards, Markus