Skip to contentSkip to conversation

clk: keystone: sci-clk: fix application of sizeof to pointer

PATCH In review [email protected] 2 participants 2 messages Jul 21, 2023 – Aug 22, 2023 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 clk: keystone: sci-clk: fix application of sizeof to pointer

./drivers/clk/keystone/sci-clk.c:390:8-14: ERROR: application of sizeof to pointer

---
 drivers/clk/keystone/sci-clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/keystone/sci-clk.c +1 -1
index 6c1df4f11536..2c68c1e09d1f 100644
@@ -389,7 +389,7 @@ static struct clk_hw *sci_clk_get(struct of_phandle_args *clkspec, void *data)
 	key.clk_id = clkspec->args[1];
 
 	clk = bsearch(&key, provider->clocks, provider->num_clocks,
-		      sizeof(clk), _cmp_sci_clk);
+		      sizeof(**clk), _cmp_sci_clk);
 
 	if (!clk)
 		return ERR_PTR(-ENODEV);
maintainer
#2 lore raw

Quoting [email protected] (2023-07-20 18:14:19)

Quoted 14 lines

./drivers/clk/keystone/sci-clk.c:390:8-14: ERROR: application of sizeof to pointer

---
  drivers/clk/keystone/sci-clk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/keystone/sci-clk.c +0 -0
index 6c1df4f11536..2c68c1e09d1f 100644

drivers/clk/keystone/sci-clk.c static struct clk_hw *sci_clk_get(struct · line 392

Quoted 4 lines
drivers/clk/keystone/sci-clk.c +0 -0
@@ -389,7 +389,7 @@ static struct clk_hw *sci_clk_get(struct 
 of_phandle_args *clkspec, void *data)
        key.clk_id = clkspec->args[1];
 
        clk = bsearch(&key, provider->clocks, provider->num_clocks,

Huh? I see 'provider->clocks' is struct sci_clk_provider::clocks which is of type 'struct sci_clk **'. It looks like each element in the array is a 'struct sci_clk *', so if we want to silence the coccinelle warning perhaps this should change to sizeof(*clk). Certainly we don't want to change it to be the sizeof(struct sci_clk) though. Does changing the sizeof() to deref the pointer work to silence the error?

Quoted 2 lines
drivers/clk/keystone/sci-clk.c +1 -1
-                     sizeof(clk), _cmp_sci_clk);
+                     sizeof(**clk), _cmp_sci_clk);