Skip to content

Commit 136209e

Browse files
krzkalexandrebelloni
authored andcommitted
i3c: adi: Fix confusing cleanup.h syntax
Initializing automatic __free variables to NULL without need (e.g. branches with different allocations), followed by actual allocation is in contrary to explicit coding rules guiding cleanup.h: "Given that the "__free(...) = NULL" pattern for variables defined at the top of the function poses this potential interdependency problem the recommendation is to always define and assign variables in one statement and not group variable definitions at the top of the function when __free() is used." Code does not have a bug, but is less readable and uses discouraged coding practice, so fix that by moving declaration to the place of assignment. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20251208020750.4727-4-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent cc3b18f commit 136209e

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

drivers/i3c/master/adi-i3c-master.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,9 @@ static int adi_i3c_master_send_ccc_cmd(struct i3c_master_controller *m,
332332
struct i3c_ccc_cmd *cmd)
333333
{
334334
struct adi_i3c_master *master = to_adi_i3c_master(m);
335-
struct adi_i3c_xfer *xfer __free(kfree) = NULL;
336335
struct adi_i3c_cmd *ccmd;
337336

338-
xfer = adi_i3c_master_alloc_xfer(master, 1);
337+
struct adi_i3c_xfer *xfer __free(kfree) = adi_i3c_master_alloc_xfer(master, 1);
339338
if (!xfer)
340339
return -ENOMEM;
341340

@@ -371,13 +370,12 @@ static int adi_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
371370
{
372371
struct i3c_master_controller *m = i3c_dev_get_master(dev);
373372
struct adi_i3c_master *master = to_adi_i3c_master(m);
374-
struct adi_i3c_xfer *xfer __free(kfree) = NULL;
375373
int i, ret;
376374

377375
if (!nxfers)
378376
return 0;
379377

380-
xfer = adi_i3c_master_alloc_xfer(master, nxfers);
378+
struct adi_i3c_xfer *xfer __free(kfree) = adi_i3c_master_alloc_xfer(master, nxfers);
381379
if (!xfer)
382380
return -ENOMEM;
383381

@@ -777,7 +775,6 @@ static int adi_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
777775
{
778776
struct i3c_master_controller *m = i2c_dev_get_master(dev);
779777
struct adi_i3c_master *master = to_adi_i3c_master(m);
780-
struct adi_i3c_xfer *xfer __free(kfree) = NULL;
781778
int i;
782779

783780
if (!nxfers)
@@ -786,7 +783,8 @@ static int adi_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
786783
if (xfers[i].flags & I2C_M_TEN)
787784
return -EOPNOTSUPP;
788785
}
789-
xfer = adi_i3c_master_alloc_xfer(master, nxfers);
786+
787+
struct adi_i3c_xfer *xfer __free(kfree) = adi_i3c_master_alloc_xfer(master, nxfers);
790788
if (!xfer)
791789
return -ENOMEM;
792790

0 commit comments

Comments
 (0)