On 3/21/2024 1:20 PM, Julia Lawall wrote:
Does one prefer an initialization of null at the top of the function
or an initialization to a meaningful value in the middle of the
function ?
I think the latter.
There was a related patch explaining the direction, from Dan posted here:
https://lore.kernel.org/all/171097196970.1011049.9726486429680041876.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx/
We had been having some internal discussions about use of __free(kfree)
in the ice driver.
The gist of it is that we should instead be using inline declarations,
which I also agree is a reasonable style for this. It more clearly shows
the __free(kfree) and the allocation (kzalloc, kcalloc, etc) on the same
(or virtually the same) line of code.
I'm curious if Jakub would dislike this less? Accept?
as an example:
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c
b/drivers/net/ethernet/intel/ice/ice_common.c
index 88c86de82e09..822628d25b2f 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1003,8 +1003,6 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
*/
int ice_init_hw(struct ice_hw *hw)
{
- struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
void *mac_buf __free(kfree) = NULL;
u16 mac_buf_len;
int status;
@@ -1083,7 +1081,8 @@ int ice_init_hw(struct ice_hw *hw)
if (status)
goto err_unroll_sched;
- pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
+ struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) =
+ kzalloc(sizeof(*pcaps), GFP_KERNEL);
if (!pcaps) {
status = -ENOMEM;
goto err_unroll_sched;
Any thoughts?