From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751585AbdASAP4 (ORCPT ); Wed, 18 Jan 2017 19:15:56 -0500 Received: from u16576595.onlinehome-server.com ([74.208.238.6]:49823 "EHLO euler.addtoit.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751205AbdASAPv (ORCPT ); Wed, 18 Jan 2017 19:15:51 -0500 X-Greylist: delayed 692 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Jan 2017 19:15:51 EST Date: Wed, 18 Jan 2017 19:07:48 -0500 From: Jeff Dike To: SF Markus Elfring Cc: user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net, Anton Ivanov , Dan Williams , Hannes Reinecke , Jens Axboe , Richard Weinberger , LKML , kernel-janitors@vger.kernel.org, Wolfram Sang Subject: Re: [PATCH 2/5] um: port: Delete three error messages for a failed memory allocation Message-ID: <20170119000748.GB12052@parts.user-mode-linux.org> References: <651ecf90-9c68-aec1-58d7-d11e7671ed4c@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <651ecf90-9c68-aec1-58d7-d11e7671ed4c@users.sourceforge.net> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > --- a/arch/um/drivers/port_kern.c > +++ b/arch/um/drivers/port_kern.c > @@ -87,11 +87,8 @@ static int port_accept(struct port_list *port) > } > > conn = kmalloc(sizeof(*conn), GFP_ATOMIC); > - if (conn == NULL) { > - printk(KERN_ERR "port_accept : failed to allocate " > - "connection\n"); > + if (!conn) > goto out_close; > - } > *conn = ((struct connection) > { .list = LIST_HEAD_INIT(conn->list), > .fd = fd, I don't see how this eliminates a possible error. It should behave exactly the same. To me, this is an expressiveness issue. !x is something you use with something that is conceptually a Boolean. x == NULL is a question about a pointer, which is the case here. Jeff -- Jeff Dike AddToIt 978-254-0789 (o) 978-394-8986 (c) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Dike Date: Thu, 19 Jan 2017 00:07:48 +0000 Subject: Re: [PATCH 2/5] um: port: Delete three error messages for a failed memory allocation Message-Id: <20170119000748.GB12052@parts.user-mode-linux.org> List-Id: References: <651ecf90-9c68-aec1-58d7-d11e7671ed4c@users.sourceforge.net> In-Reply-To: <651ecf90-9c68-aec1-58d7-d11e7671ed4c@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring Cc: user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net, Anton Ivanov , Dan Williams , Hannes Reinecke , Jens Axboe , Richard Weinberger , LKML , kernel-janitors@vger.kernel.org, Wolfram Sang > --- a/arch/um/drivers/port_kern.c > +++ b/arch/um/drivers/port_kern.c > @@ -87,11 +87,8 @@ static int port_accept(struct port_list *port) > } > > conn = kmalloc(sizeof(*conn), GFP_ATOMIC); > - if (conn = NULL) { > - printk(KERN_ERR "port_accept : failed to allocate " > - "connection\n"); > + if (!conn) > goto out_close; > - } > *conn = ((struct connection) > { .list = LIST_HEAD_INIT(conn->list), > .fd = fd, I don't see how this eliminates a possible error. It should behave exactly the same. To me, this is an expressiveness issue. !x is something you use with something that is conceptually a Boolean. x = NULL is a question about a pointer, which is the case here. Jeff -- Jeff Dike AddToIt 978-254-0789 (o) 978-394-8986 (c)