From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbbLLVXO (ORCPT ); Sat, 12 Dec 2015 16:23:14 -0500 Received: from mout.web.de ([212.227.17.11]:51223 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751867AbbLLVXL (ORCPT ); Sat, 12 Dec 2015 16:23:11 -0500 Subject: Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly To: Dan Carpenter References: <566ABCD9.1060404@users.sourceforge.net> <566C2F7B.6030704@users.sourceforge.net> <566C308A.6000109@users.sourceforge.net> <20151212194939.GQ5284@mwanda> Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, "Nicholas A. Bellinger" , LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring X-Enigmail-Draft-Status: N1110 Message-ID: <566C902F.8070802@users.sourceforge.net> Date: Sat, 12 Dec 2015 22:22:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151212194939.GQ5284@mwanda> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:I33igcgcITGs6a5GvujndC9kHSwX5QeZLfslPbNpszAf3AEn+j1 ZRkW6LkUJ0Kgv1o3yCW2vJYjB9ALNwrXTSlYe22mjq9IwNO60/GtZS08xs+VoWl7K0bPlRk WBB2wUcD4ArFLlRKeOBMcgtmuLxnZoL6oihsrL4TlVYRnKEsQHLvWpq/vxyGM8FZOi0nBxc 7aVeIe02DnXX3aQ+psozw== X-UI-Out-Filterresults: notjunk:1;V01:K0:gppNzBKDMoE=:+1bI6vwFOBAYggnIoQ9Joj svn/14J+Dt4RVNaSQAr+ac/ObZ/qsVulDH/0CK2dbIMiLcDbDwlo63zD/BacWnKZZD9PCv5a0 s8NT8Xki+V4e3+RMu62x4fv6RlDR4Am0DGl7ZIvYHIuOMEcmaxUWjqkeeMsEfw9rPWDJpz7wV STyLHVy3LcLKgzZfwrt6XuVGc/ub7SPCtMZRsxMBxm5zUS8yv+M3BVHNGU2OVTq5nrgHv2hnM aBGHrxEltJdzzWW5hdYnxxWijOPKTRRyhLXqysp0/Rg+TFwqYyfBu6h892XrrQkJW47ilGJ46 OePWd7SYJZhUHxALwF16b8EAREuCxmVAqbdMva7OlQKmRV4WXhMi3re/WYPOtndovUf72h85w APbrfB8uGcp9w2o5oHLBuD72Np3VEngpEyPlouhd+vUNIjD1OKc5fa7zVPjPEPIEokn6c9I7f YLGqLomLejGvhTxIAtr2uTXtewZvcKBy1ip73pebsq8RBuoa7kGDsXrNUSZvBMhRh53NZj+OJ hb0h8oHlorCd8ikaY1dziAvya9wngFfzICn8mUyesud94Dd0kLkUMz1+L+tHRzYxGQ+2Rs/AE nnIgv32GPkW2SMjaLjSo3MN3pzb3CnuzR+tHxZuOvNH9+oi8jaJVOrCPH8jEOAl5YzU8nhNSL Mxk0sVp1hunRhDiNeydmXPW4FAhifiJQmofFIF3Gx3arkp7obq7z7b5Xofaos4a8IcIBNsAjz cICi9Z099F7ziM7Ns2rl0PLj9lkiJByRBbhGw8aPHW/ri2yxTJIqubYiXGQ1BhhX3YcK3+FhO jHLYZ4w Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> @@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para >> char *name, char *value, u8 phase, u8 scope, u8 sender, >> u16 type_range, u8 use) >> { >> - struct iscsi_param *param = NULL; >> + struct iscsi_param *param = kzalloc(sizeof(*param), GFP_KERNEL); >> >> - param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL); >> if (!param) { >> pr_err("Unable to allocate memory for parameter.\n"); >> goto out; > > It's better to just get rid of the initialization but leave the > kzalloc() as-is for two reasons. > > 1) Initializer code normally contains more bugs per line than other > code. I am thinking about dereferencing pointers before checking > for NULL or not checking the allocation for failure. I can follow your concerns a bit. > 2) It puts a blank line between the allocation and the check for failure. Is there a target conflict between "convenient" variable initialisation in the declaration section and the function outline that seems to be checked by the script "checkpatch.pl" to some degree while corresponding preferences or recommendations are not mentioned in the document "CodingStyle"? > It's like a new paragraph. I do not see the separation in a strict way so far. > The allocation and the check should be next to each other. I find that these actions are still close enough in the discussed use case. Regards, Markus