Thread (14 messages) flat view 14 messages, 4 authors, 2010-10-15

Re: [PATCH 2/3 v4] P4080/mtd: Only make elbc nand driver detect nand flash partitions

From: Scott Wood <hidden>
Date: 2010-10-14 16:24:11

On Wed, 13 Oct 2010 20:09:02 -0700
"Zang Roy-R61911" [off-list ref] wrote:
quoted
quoted
quoted
quoted
+	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = NULL;
No need for = NULL.
Any harm? Or just personal habit or style? Can you explain about
why?
quoted
Besides not wanting superfluous code on general principle, it could
hide a bug if in the future the real initialization is missing on some
code path.  It would become a runtime NULL dereference rather than a
compiler warning.
Not exactly.
Per my understand, if the pointer will definitely be assigned in code
path,
it is not necessary to init it when define. for example,

char c;
char b;
char *a;
if (condition)
	a = &c;
else
	a = &b;
...

for other case, if the path will not ensure the pointer assignment, it
will be inited
when define to avoid warning. for example,

char c;
char *a = NULL;
if (condition)
	a = &c;
...
Yes, but this patch looks like the former case, not the
latter.  Is GCC giving a warning without the initializer?

-Scott
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help