2002-10-20 19:26:19

by Rasmus Andersen

[permalink] [raw]
Subject: Error in get_swap_page? (2.5.44)

Hi,

Unless I am mistaken, we return stuff (entry) from the local
stack in swapfile.c::get_swap_page. Am I mistaken?

Code in question:

swp_entry_t get_swap_page(void)
{
struct swap_info_struct * p;
unsigned long offset;
swp_entry_t entry;
int type, wrapped = 0;

entry.val = 0; /* Out of memory */
[...]

out:
swap_list_unlock();
return entry;
}


Regards,
Rasmus


Attachments:
(No filename) (426.00 B)
(No filename) (189.00 B)
Download all attachments

2002-10-20 19:30:44

by Sean Neakums

[permalink] [raw]
Subject: Re: Error in get_swap_page? (2.5.44)

commence Rasmus Andersen quotation:

> Unless I am mistaken, we return stuff (entry) from the local
> stack in swapfile.c::get_swap_page. Am I mistaken?

Wouldn't this only be a problem if a *pointer* to it was being
returned?

> Code in question:
>
> swp_entry_t get_swap_page(void)
> {
> struct swap_info_struct * p;
> unsigned long offset;
> swp_entry_t entry;
> int type, wrapped = 0;
>
> entry.val = 0; /* Out of memory */
> [...]
>
> out:
> swap_list_unlock();
> return entry;
> }

--
/ |
[|] Sean Neakums | Questions are a burden to others;
[|] <[email protected]> | answers a prison for oneself.
\ |

2002-10-20 19:35:11

by Rasmus Andersen

[permalink] [raw]
Subject: Re: Error in get_swap_page? (2.5.44)

On Sun, Oct 20, 2002 at 08:36:46PM +0100, Sean Neakums wrote:
> commence Rasmus Andersen quotation:
>
> > Unless I am mistaken, we return stuff (entry) from the local
> > stack in swapfile.c::get_swap_page. Am I mistaken?
>
> Wouldn't this only be a problem if a *pointer* to it was being
> returned?

Quite. Sorry about that. I'll be a good boy and go to bed now :)

Regards,
Rasmus


Attachments:
(No filename) (390.00 B)
(No filename) (189.00 B)
Download all attachments

2002-10-20 19:33:07

by Rasmus Andersen

[permalink] [raw]
Subject: Re: Error in get_swap_page? (2.5.44)

On Sun, Oct 20, 2002 at 09:36:52PM +0200, bert hubert wrote:
> On Sun, Oct 20, 2002 at 09:32:17PM +0200, Rasmus Andersen wrote:
>
> > Unless I am mistaken, we return stuff (entry) from the local
> > stack in swapfile.c::get_swap_page. Am I mistaken?
>
> Yes. This just returns a struct by value over the stack, which is frowned
> upon in some circles, but is not an error per se.

Hmm. You are right and I must be confused. -ENEEDSLEEP, apparently.

Thanks,
Rasmus


Attachments:
(No filename) (470.00 B)
(No filename) (189.00 B)
Download all attachments

2002-10-20 19:30:49

by bert hubert

[permalink] [raw]
Subject: Re: Error in get_swap_page? (2.5.44)

On Sun, Oct 20, 2002 at 09:32:17PM +0200, Rasmus Andersen wrote:

> Unless I am mistaken, we return stuff (entry) from the local
> stack in swapfile.c::get_swap_page. Am I mistaken?

Yes. This just returns a struct by value over the stack, which is frowned
upon in some circles, but is not an error per se.

Regards,

bert

--
http://www.PowerDNS.com Versatile DNS Software & Services
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO