lkml.org 
[lkml]   [2012]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC/PATCH 1/1] mmc: block: Add MMC write packing statistics
On Wed, Jun 06, 2012 at 12:02:10PM +0530, Rahul Bedarkar wrote:

> > +static ssize_t mmc_wr_pack_stats_read(struct file *filp, char __user *ubuf,
> > +                               size_t cnt, loff_t *ppos)
> > +{
> > +       struct mmc_card *card = filp->private_data;
> > +       struct mmc_wr_pack_stats *pack_stats;
> > +       int i;

> Best practice is to initialize variables at the time of declaration,
> even if you initialize it before using. Many times we forget to do
> that and there could be logical errors.

gcc will often emit a warning if a variable is used before
initialization. There seems to be a trend amongst kernel developers
to eschew redundant initializations, since they do actually generate
code. In fact, there is a macro 'uninitialized_var(x)' to suppress
the warning from the compiler when it is incorrect, so that a variable
doesn't have to be initialized when not really needed.

Outside of the kernel, though, I would otherwise agree with you.

David

--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-06-06 19:41    [W:0.046 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site