Skip to contentSkip to conversation

Error in get_swap_page? (2.5.44)

DISCUSSION Rasmus Andersen 3 participants 5 messages Oct 20, 2002

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

commence Rasmus Andersen quotation:

Quoted 2 lines

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?

Quoted 16 lines

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;
}
Signature · 4 lines
 /                          |
[|] Sean Neakums            |  Questions are a burden to others;
[|] <[email protected]>     |      answers a prison for oneself.
 \                          |
#2 lore raw
Quoted 7 lines · Sean Neakums

commence Rasmus Andersen quotation:

Quoted 2 lines

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

#3 lore raw
In reply to Rasmus Andersen
Quoted 2 lines · Rasmus Andersen

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

Signature · 2 lines
http://www.PowerDNS.com          Versatile DNS Software & Services
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO
#4 lore raw
Quoted 7 lines · bert hubert
Quoted 2 lines · Rasmus Andersen

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