All of lore.kernel.org
 help / color / mirror / Atom feed
* Variables defined, (sometimes) assigned, and never used
@ 2021-04-09 20:09 Fabio M. De Francesco
  2021-04-09 20:14 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio M. De Francesco @ 2021-04-09 20:09 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, julia.lawall

When compiling with flag W=1 a lot of warnings about variables defined but 
never used show up. If one read the source sometimes it's clear that the 
original author placed them there because she/he wants to use the variable 
for doing something in a future release of the driver. I've also seen a 
comment like /* TODO */ near some unused variables. 

I thought to delete a couple of variables that are declared, may be also 
assigned as a result of some expression, but neither  used within a 
function or returned to the caller.

What to do with those (currently) unnecessary variables? Should we remove 
them or let everything as is?

Thanks,

Fabio
 

  




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

* Re: Variables defined, (sometimes) assigned, and never used
  2021-04-09 20:09 Variables defined, (sometimes) assigned, and never used Fabio M. De Francesco
@ 2021-04-09 20:14 ` Julia Lawall
  2021-04-09 20:26   ` Fabio M. De Francesco
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2021-04-09 20:14 UTC (permalink / raw)
  To: Fabio M. De Francesco; +Cc: outreachy-kernel, gregkh



On Fri, 9 Apr 2021, Fabio M. De Francesco wrote:

> When compiling with flag W=1 a lot of warnings about variables defined but
> never used show up. If one read the source sometimes it's clear that the
> original author placed them there because she/he wants to use the variable
> for doing something in a future release of the driver. I've also seen a
> comment like /* TODO */ near some unused variables.
>
> I thought to delete a couple of variables that are declared, may be also
> assigned as a result of some expression, but neither  used within a
> function or returned to the caller.
>
> What to do with those (currently) unnecessary variables? Should we remove
> them or let everything as is?

Generally, code that is not used is not wanted.  But use some common
sense.

Be sure to compile the code.  It can happen that the variable is only used
by a macro.  Not very nice, but it can happen.

julia


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

* Re: Variables defined, (sometimes) assigned, and never used
  2021-04-09 20:14 ` Julia Lawall
@ 2021-04-09 20:26   ` Fabio M. De Francesco
  0 siblings, 0 replies; 3+ messages in thread
From: Fabio M. De Francesco @ 2021-04-09 20:26 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel, gregkh

On Friday, April 9, 2021 10:14:09 PM CEST Julia Lawall wrote:
> On Fri, 9 Apr 2021, Fabio M. De Francesco wrote:
> > When compiling with flag W=1 a lot of warnings about variables defined
> > but never used show up. If one read the source sometimes it's clear
> > that the original author placed them there because she/he wants to use
> > the variable for doing something in a future release of the driver.
> > I've also seen a comment like /* TODO */ near some unused variables.
> > 
> > I thought to delete a couple of variables that are declared, may be
> > also
> > assigned as a result of some expression, but neither  used within a
> > function or returned to the caller.
> > 
> > What to do with those (currently) unnecessary variables? Should we
> > remove them or let everything as is?
> 
> Generally, code that is not used is not wanted.  But use some common
> sense.
> 
> Be sure to compile the code.  It can happen that the variable is only
> used by a macro.  Not very nice, but it can happen.
> 
> julia

I'll check carefully that the resulting code can still work. I'm a bit 
tired of removing camelcase and the like :(

Thanks,

Fabio





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

end of thread, other threads:[~2021-04-09 20:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-09 20:09 Variables defined, (sometimes) assigned, and never used Fabio M. De Francesco
2021-04-09 20:14 ` Julia Lawall
2021-04-09 20:26   ` Fabio M. De Francesco

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.