linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kbuild] drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable]
@ 2022-05-27  8:57 Dan Carpenter
  2022-05-30  9:04 ` Cristian Marussi
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2022-05-27  8:57 UTC (permalink / raw)
  To: kbuild, Cristian Marussi; +Cc: lkp, kbuild-all, linux-kernel, Sudeep Holla

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master
head:   7e284070abe53d448517b80493863595af4ab5f0
commit: 7bc7caafe6b1e5b882255a42bc1bf112fa87b69b firmware: arm_scmi: Use common iterators in the clock protocol
compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 7bc7caafe6b1e5b882255a42bc1bf112fa87b69b
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable]
    struct scmi_msg_clock_describe_rates *msg;
                                          ^

vim +/msg +242 drivers/firmware/arm_scmi/clock.c

7bc7caafe6b1e5 Cristian Marussi 2022-03-30  235  static int
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  236  scmi_clock_describe_rates_get(const struct scmi_protocol_handle *ph, u32 clk_id,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  237  			      struct scmi_clock_info *clk)
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  238  {
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  239  	int ret;
5f6c6430e904d2 Sudeep Holla     2017-06-06  240  

Please delete the blank line.

7bc7caafe6b1e5 Cristian Marussi 2022-03-30  241  	void *iter;
7bc7caafe6b1e5 Cristian Marussi 2022-03-30 @242  	struct scmi_msg_clock_describe_rates *msg;

I was so surprised that GCC doesn't warn about this but "msg" is only
used to calculate the sizeof(*msg).

7bc7caafe6b1e5 Cristian Marussi 2022-03-30  243  	struct scmi_iterator_ops ops = {
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  244  		.prepare_message = iter_clk_describe_prepare_message,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  245  		.update_state = iter_clk_describe_update_state,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  246  		.process_response = iter_clk_describe_process_response,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  247  	};
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  248  	struct scmi_clk_ipriv cpriv = {
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  249  		.clk_id = clk_id,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  250  		.clk = clk,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  251  	};
5f6c6430e904d2 Sudeep Holla     2017-06-06  252  
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  253  	iter = ph->hops->iter_response_init(ph, &ops, SCMI_MAX_NUM_RATES,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  254  					    CLOCK_DESCRIBE_RATES,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  255  					    sizeof(*msg), &cpriv);
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  256  	if (IS_ERR(iter))
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  257  		return PTR_ERR(iter);
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  258  
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  259  	ret = ph->hops->iter_response_run(iter);
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  260  	if (ret)
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  261  		return ret;
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  262  
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  263  	if (!clk->rate_discrete) {
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  264  		dev_dbg(ph->dev, "Min %llu Max %llu Step %llu Hz\n",
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  265  			clk->range.min_rate, clk->range.max_rate,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  266  			clk->range.step_size);
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  267  	} else if (clk->list.num_rates) {
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  268  		sort(clk->list.rates, clk->list.num_rates,
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  269  		     sizeof(clk->list.rates[0]), rate_cmp_func, NULL);
7bc7caafe6b1e5 Cristian Marussi 2022-03-30  270  	}
c0759b9b5d411a Peng Fan         2019-05-22  271  
5f6c6430e904d2 Sudeep Holla     2017-06-06  272  	return ret;
5f6c6430e904d2 Sudeep Holla     2017-06-06  273  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp 
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kbuild] drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable]
  2022-05-27  8:57 [kbuild] drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable] Dan Carpenter
@ 2022-05-30  9:04 ` Cristian Marussi
  2022-05-30 10:08   ` Cristian Marussi
  0 siblings, 1 reply; 3+ messages in thread
From: Cristian Marussi @ 2022-05-30  9:04 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kbuild, lkp, kbuild-all, linux-kernel, Sudeep Holla

On Fri, May 27, 2022 at 11:57:29AM +0300, Dan Carpenter wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master
> head:   7e284070abe53d448517b80493863595af4ab5f0
> commit: 7bc7caafe6b1e5b882255a42bc1bf112fa87b69b firmware: arm_scmi: Use common iterators in the clock protocol
> compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
> reproduce (cppcheck warning):
>         # apt-get install cppcheck
>         git checkout 7bc7caafe6b1e5b882255a42bc1bf112fa87b69b
>         cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 

Hi Dan,

thanks for the report.

> cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
> 
> >> drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable]
>     struct scmi_msg_clock_describe_rates *msg;
>                                           ^
> 
> vim +/msg +242 drivers/firmware/arm_scmi/clock.c
> 
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  235  static int
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  236  scmi_clock_describe_rates_get(const struct scmi_protocol_handle *ph, u32 clk_id,
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  237  			      struct scmi_clock_info *clk)
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  238  {
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  239  	int ret;
> 5f6c6430e904d2 Sudeep Holla     2017-06-06  240  
> 
> Please delete the blank line.

I'll do.

> 
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  241  	void *iter;
> 7bc7caafe6b1e5 Cristian Marussi 2022-03-30 @242  	struct scmi_msg_clock_describe_rates *msg;
> 
> I was so surprised that GCC doesn't warn about this but "msg" is only
> used to calculate the sizeof(*msg).
> 

Probably a leftover from a previous version of the series where msg was
usaed not only for sizeof()....I'll send a fix anyway to silence the
bot.

Thanks,
Cristian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kbuild] drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable]
  2022-05-30  9:04 ` Cristian Marussi
@ 2022-05-30 10:08   ` Cristian Marussi
  0 siblings, 0 replies; 3+ messages in thread
From: Cristian Marussi @ 2022-05-30 10:08 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kbuild, lkp, kbuild-all, linux-kernel, Sudeep Holla

On Mon, May 30, 2022 at 10:04:55AM +0100, Cristian Marussi wrote:
> On Fri, May 27, 2022 at 11:57:29AM +0300, Dan Carpenter wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master
> > head:   7e284070abe53d448517b80493863595af4ab5f0
> > commit: 7bc7caafe6b1e5b882255a42bc1bf112fa87b69b firmware: arm_scmi: Use common iterators in the clock protocol
> > compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
> > reproduce (cppcheck warning):
> >         # apt-get install cppcheck
> >         git checkout 7bc7caafe6b1e5b882255a42bc1bf112fa87b69b
> >         cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
> > 
> > If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <lkp@intel.com>
> > 
> 
> Hi Dan,
> 
> thanks for the report.
> 
> > cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
> > 
> > >> drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable]
> >     struct scmi_msg_clock_describe_rates *msg;
> >                                           ^
> > 
> > vim +/msg +242 drivers/firmware/arm_scmi/clock.c
> > 
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  235  static int
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  236  scmi_clock_describe_rates_get(const struct scmi_protocol_handle *ph, u32 clk_id,
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  237  			      struct scmi_clock_info *clk)
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  238  {
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  239  	int ret;
> > 5f6c6430e904d2 Sudeep Holla     2017-06-06  240  
> > 
> > Please delete the blank line.
> 
> I'll do.
> 
> > 
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30  241  	void *iter;
> > 7bc7caafe6b1e5 Cristian Marussi 2022-03-30 @242  	struct scmi_msg_clock_describe_rates *msg;
> > 
> > I was so surprised that GCC doesn't warn about this but "msg" is only
> > used to calculate the sizeof(*msg).
> > 
> 
> Probably a leftover from a previous version of the series where msg was
> usaed not only for sizeof()....I'll send a fix anyway to silence the
> bot.

... and btw there are a bunch of similar other sizeof(*msg) in a few
other SCMI protocols when calling the same response_init() helper...
..even though innocuos...I'll fix all of these to avoid needless stuff
on the stack.

Thanks,
Cristian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-30 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27  8:57 [kbuild] drivers/firmware/arm_scmi/clock.c:242:40: warning: Variable 'msg' is not assigned a value. [unassignedVariable] Dan Carpenter
2022-05-30  9:04 ` Cristian Marussi
2022-05-30 10:08   ` Cristian Marussi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).