Re: Newbie idiotic questions.

2001-06-18 Thread Alexander Viro
On Mon, 18 Jun 2001, Roman Zippel wrote: > > I wouldn't call it "rather popular". > > You should also grep for '__typeof__'. :-) Yeeeccchhh. OK, there is more of that. However, the main user of that beast is, AFAICS, get_user()/put_user() and their ilk in include/asm-* The rest looks very

Re: Newbie idiotic questions.

2001-06-18 Thread Roman Zippel
Hi, On Sun, 17 Jun 2001, Alexander Viro wrote: > > typeof? It's rather popular in the kernel already. Besides, who is going to > > Really? 5 instances in PPC arch-specific code, 1 (absolutely gratitious) > in drivers/mtd, 2 - in m68k (also useless), 4 - in drivers/video, 2 - > in AFFS and 1 -

Re: Newbie idiotic questions.

2001-06-18 Thread Roman Zippel
Hi, On Sun, 17 Jun 2001, Alexander Viro wrote: typeof? It's rather popular in the kernel already. Besides, who is going to Really? 5 instances in PPC arch-specific code, 1 (absolutely gratitious) in drivers/mtd, 2 - in m68k (also useless), 4 - in drivers/video, 2 - in AFFS and 1 - in

Re: Newbie idiotic questions.

2001-06-18 Thread Alexander Viro
On Mon, 18 Jun 2001, Roman Zippel wrote: I wouldn't call it rather popular. You should also grep for '__typeof__'. :-) Yeeeccchhh. OK, there is more of that. However, the main user of that beast is, AFAICS, get_user()/put_user() and their ilk in include/asm-* The rest looks very bogus...

Re: Newbie idiotic questions.

2001-06-17 Thread Alexander Viro
On Sun, 17 Jun 2001, Daniel Phillips wrote: > typeof? It's rather popular in the kernel already. Besides, who is going to Really? 5 instances in PPC arch-specific code, 1 (absolutely gratitious) in drivers/mtd, 2 - in m68k (also useless), 4 - in drivers/video, 2 - in AFFS and 1 - in

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 22:37, Alexander Viro wrote: > On Sun, 17 Jun 2001, Daniel Phillips wrote: > > Well, since we are still beating this one to death, I'd written a "knew" > > macro as well, and put it aside. It does the assignment for you too: > > > >#define knew(p) ((p) = (typeof(p))

Re: Newbie idiotic questions.

2001-06-17 Thread Bill Pringlemeir
> "Jeff" == Jeff Garzik <[EMAIL PROTECTED]> writes: [snip] Jeff> It's the preference of the maintainer. It's a tossup: using Jeff> the type in the kmalloc makes the type being allocated obvious. Jeff> But using sizeof(*var) is a tiny bit more resistant to change. Ok, thanks. I was

Re: Newbie idiotic questions.

2001-06-17 Thread Alexander Viro
On Sun, 17 Jun 2001, Daniel Phillips wrote: > > macro that behaves like `new' in C++: > > | #define knew(type, flags) (type *)kmalloc(sizeof(type), (flags)) > > > > If the types in the assignment don't match, gcc will tell you. > > Well, since we are still beating this one to death, I'd

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 21:18, Geert Uytterhoeven wrote: > On Sun, 17 Jun 2001, Jeff Garzik wrote: > > David Flynn wrote: > > > > Daniel Phillips wrote: > > > > > - if ((card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) > > > > > > > > + if ((card->mpuout =

Re: Newbie idiotic questions.

2001-06-17 Thread Geert Uytterhoeven
On Sun, 17 Jun 2001, Jeff Garzik wrote: > David Flynn wrote: > > > Daniel Phillips wrote: > > > > Yep, the only thing left to resolve is whether Jeff had coffee or not. > > ;-) > > > > > > > > - if ((card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), > > GFP_KERNEL)) > > > > + if

Re: Newbie idiotic questions.

2001-06-17 Thread Jeff Garzik
David Flynn wrote: > > > Daniel Phillips wrote: > > > Yep, the only thing left to resolve is whether Jeff had coffee or not. > ;-) > > > > > > - if ((card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), > GFP_KERNEL)) > > > + if ((card->mpuout = kmalloc(sizeof(*card->mpuout),

Re: Newbie idiotic questions.

2001-06-17 Thread David Flynn
> Daniel Phillips wrote: > > Yep, the only thing left to resolve is whether Jeff had coffee or not. ;-) > > > > - if ((card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) > > + if ((card->mpuout = kmalloc(sizeof(*card->mpuout), GFP_KERNEL)) > > Yeah, this is fine.

Re: Newbie idiotic questions.

2001-06-17 Thread Jeff Garzik
Daniel Phillips wrote: > Yep, the only thing left to resolve is whether Jeff had coffee or not. ;-) > > - if ((card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) > + if ((card->mpuout = kmalloc(sizeof(*card->mpuout), GFP_KERNEL)) Yeah, this is fine. The original

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 14:27, [EMAIL PROTECTED] wrote: > Daniel Phillips wrote: > > > because then you would be allocating the size of a pointer, not the > > > size of a structure > > > > Whoops Jeff, you didn't have your coffee yet: > > Whoops yourself. The following patch brings your example

Re: Newbie idiotic questions.

2001-06-17 Thread rjd
Daniel Phillips wrote: > > > because then you would be allocating the size of a pointer, not the size > > of a structure > > Whoops Jeff, you didn't have your coffee yet: Whoops yourself. The following patch brings your example into line with the driver code. mpuout is a pointer to a structure

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 03:32, Jeff Garzik wrote: > Bill Pringlemeir wrote: > > Why is the struct type referenced for the allocation size? Why not, > > > > if ((card->mpuout = kmalloc(sizeof(card->mpuout), GFP_KERNEL)) > > because then you would be allocating the size of a pointer, not

Re: Newbie idiotic questions.

2001-06-17 Thread rjd
Hi, Bill Pringlemeir wrote: > > I have been looking at the emu10k1 driver and I had a few questions > about general idioms used there. Warning I've not looked at that particular driver and would concider myself a Linux kernel newbie. 20 years kernel hacking but only 9 months Linux with two

Re: Newbie idiotic questions.

2001-06-17 Thread rjd
Hi, Bill Pringlemeir wrote: I have been looking at the emu10k1 driver and I had a few questions about general idioms used there. Warning I've not looked at that particular driver and would concider myself a Linux kernel newbie. 20 years kernel hacking but only 9 months Linux with two

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 03:32, Jeff Garzik wrote: Bill Pringlemeir wrote: Why is the struct type referenced for the allocation size? Why not, if ((card-mpuout = kmalloc(sizeof(card-mpuout), GFP_KERNEL)) because then you would be allocating the size of a pointer, not the size of

Re: Newbie idiotic questions.

2001-06-17 Thread rjd
Daniel Phillips wrote: because then you would be allocating the size of a pointer, not the size of a structure Whoops Jeff, you didn't have your coffee yet: Whoops yourself. The following patch brings your example into line with the driver code. mpuout is a pointer to a structure not

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 14:27, [EMAIL PROTECTED] wrote: Daniel Phillips wrote: because then you would be allocating the size of a pointer, not the size of a structure Whoops Jeff, you didn't have your coffee yet: Whoops yourself. The following patch brings your example into line with

Re: Newbie idiotic questions.

2001-06-17 Thread Jeff Garzik
Daniel Phillips wrote: Yep, the only thing left to resolve is whether Jeff had coffee or not. ;-) - if ((card-mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) + if ((card-mpuout = kmalloc(sizeof(*card-mpuout), GFP_KERNEL)) Yeah, this is fine. The original posted

Re: Newbie idiotic questions.

2001-06-17 Thread David Flynn
Daniel Phillips wrote: Yep, the only thing left to resolve is whether Jeff had coffee or not. ;-) - if ((card-mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) + if ((card-mpuout = kmalloc(sizeof(*card-mpuout), GFP_KERNEL)) Yeah, this is fine. The original

Re: Newbie idiotic questions.

2001-06-17 Thread Jeff Garzik
David Flynn wrote: Daniel Phillips wrote: Yep, the only thing left to resolve is whether Jeff had coffee or not. ;-) - if ((card-mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) + if ((card-mpuout = kmalloc(sizeof(*card-mpuout), GFP_KERNEL)) Yeah,

Re: Newbie idiotic questions.

2001-06-17 Thread Geert Uytterhoeven
On Sun, 17 Jun 2001, Jeff Garzik wrote: David Flynn wrote: Daniel Phillips wrote: Yep, the only thing left to resolve is whether Jeff had coffee or not. ;-) - if ((card-mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) + if ((card-mpuout =

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 21:18, Geert Uytterhoeven wrote: On Sun, 17 Jun 2001, Jeff Garzik wrote: David Flynn wrote: Daniel Phillips wrote: - if ((card-mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) + if ((card-mpuout = kmalloc(sizeof(*card-mpuout),

Re: Newbie idiotic questions.

2001-06-17 Thread Alexander Viro
On Sun, 17 Jun 2001, Daniel Phillips wrote: macro that behaves like `new' in C++: | #define knew(type, flags) (type *)kmalloc(sizeof(type), (flags)) If the types in the assignment don't match, gcc will tell you. Well, since we are still beating this one to death, I'd written a knew

Re: Newbie idiotic questions.

2001-06-17 Thread Bill Pringlemeir
Jeff == Jeff Garzik [EMAIL PROTECTED] writes: [snip] Jeff It's the preference of the maintainer. It's a tossup: using Jeff the type in the kmalloc makes the type being allocated obvious. Jeff But using sizeof(*var) is a tiny bit more resistant to change. Ok, thanks. I was looking at fixing

Re: Newbie idiotic questions.

2001-06-17 Thread Daniel Phillips
On Sunday 17 June 2001 22:37, Alexander Viro wrote: On Sun, 17 Jun 2001, Daniel Phillips wrote: Well, since we are still beating this one to death, I'd written a knew macro as well, and put it aside. It does the assignment for you too: #define knew(p) ((p) = (typeof(p))

Re: Newbie idiotic questions.

2001-06-17 Thread Alexander Viro
On Sun, 17 Jun 2001, Daniel Phillips wrote: typeof? It's rather popular in the kernel already. Besides, who is going to Really? 5 instances in PPC arch-specific code, 1 (absolutely gratitious) in drivers/mtd, 2 - in m68k (also useless), 4 - in drivers/video, 2 - in AFFS and 1 - in

Re: Newbie idiotic questions.

2001-06-16 Thread Arnaldo Carvalho de Melo
Em Sat, Jun 16, 2001 at 09:35:34PM -0400, Richard B. Johnson escreveu: > > [main.c, line 223] > > if ((card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) > > > > Why is the struct type referenced for the allocation size? Why not, > > > > if ((card->mpuout =

Re: Newbie idiotic questions.

2001-06-16 Thread Richard B. Johnson
On 16 Jun 2001, Bill Pringlemeir wrote: > > I have been looking at the emu10k1 driver and I had a few questions > about general idioms used there. > > In a line like this, > > [main.c, line 175] > > for (count = 0; count < sizeof(card->digmix) / sizeof(card->digmix[0]); >count++) { >

Re: Newbie idiotic questions.

2001-06-16 Thread Jeff Garzik
Bill Pringlemeir wrote: > [main.c, line 175] > > for (count = 0; count < sizeof(card->digmix) / sizeof(card->digmix[0]); >count++) { > > Isn't there some sort of `ALEN' macro available, or is this > considered to muddy things by using a macro? Yes, we have array size > [main.c, line

Newbie idiotic questions.

2001-06-16 Thread Bill Pringlemeir
I have been looking at the emu10k1 driver and I had a few questions about general idioms used there. In a line like this, [main.c, line 175] for (count = 0; count < sizeof(card->digmix) / sizeof(card->digmix[0]); count++) { Isn't there some sort of `ALEN' macro available, or is this

Newbie idiotic questions.

2001-06-16 Thread Bill Pringlemeir
I have been looking at the emu10k1 driver and I had a few questions about general idioms used there. In a line like this, [main.c, line 175] for (count = 0; count sizeof(card-digmix) / sizeof(card-digmix[0]); count++) { Isn't there some sort of `ALEN' macro available, or is this

Re: Newbie idiotic questions.

2001-06-16 Thread Jeff Garzik
Bill Pringlemeir wrote: [main.c, line 175] for (count = 0; count sizeof(card-digmix) / sizeof(card-digmix[0]); count++) { Isn't there some sort of `ALEN' macro available, or is this considered to muddy things by using a macro? Yes, we have array size [main.c, line 223]

Re: Newbie idiotic questions.

2001-06-16 Thread Richard B. Johnson
On 16 Jun 2001, Bill Pringlemeir wrote: I have been looking at the emu10k1 driver and I had a few questions about general idioms used there. In a line like this, [main.c, line 175] for (count = 0; count sizeof(card-digmix) / sizeof(card-digmix[0]); count++) { Isn't there

Re: Newbie idiotic questions.

2001-06-16 Thread Arnaldo Carvalho de Melo
Em Sat, Jun 16, 2001 at 09:35:34PM -0400, Richard B. Johnson escreveu: [main.c, line 223] if ((card-mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL)) Why is the struct type referenced for the allocation size? Why not, if ((card-mpuout =