"michael" <mj***@mail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I found follow function in the Linux kernel (kernel/resource.c)
static int r_show(struct seq_file *m, void *v)
{
struct resource *root = m->private;
struct resource *r = v, *p;
int width = root->end < 0x10000 ? 4 : 8;
int depth;
for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p =
p->parent)
if (p->parent == root)
break;
seq_printf(m, "%*s%0*lx-%0*lx : %s\n",
depth * 2, "",
width, r->start,
width, r->end,
r->name ? r->name : "<BAD>");
return 0;
}
What's mean of ---> " struct resource *r = v, *p; "
Thanks.
Horrible and confusing statement!
It's declaring two pointers, one being initialized
from the function argument.
They should be on separate lines.
It's probably fair to say you should always (at least
99.44% of the time)keep your declarations on separate lines.
That v,*P (to me anyway) can be easily confused with (v,*p), which
means evaluate v, then evaluate *p and return the value of *p. This
may be disallowed in initializers, though.
To further convince you to use separate lines, consider the following:
#define intpointer_t int*
intpointer_t a,b,c;
Will not give you 3 pointers to int, but one pointer to int (a)
while b and c are simple integers.
typedef int* intpointer_t;
intpointer_t a,b,c;
Will work as expected, but that doesn't make it a Good Thing.
Rufus