From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: Re: [PATCH 2/5] um: port: Delete three error messages for a failed memory allocation References: <651ecf90-9c68-aec1-58d7-d11e7671ed4c@users.sourceforge.net> <20170119000748.GB12052@parts.user-mode-linux.org> From: SF Markus Elfring Message-ID: <11675f60-3f56-d3a7-e8f8-1544c7a8567d@users.sourceforge.net> Date: Thu, 19 Jan 2017 10:38:37 +0100 MIME-Version: 1.0 In-Reply-To: <20170119000748.GB12052@parts.user-mode-linux.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org To: Jeff Dike , user-mode-linux-devel@lists.sourceforge.net Cc: 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 List-ID: >> +++ 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. The suggested change affects three coding style issues at this place. * Repetition of an out-of-memory message See also: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf * Unwanted splitting of a message string * Usage of a specific preprocessor symbol > !x is something you use with something that is conceptually a Boolean. Pointers can be also treated in this way, can't they? Regards, Markus