Re: Basic C question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 3, 2008 at 5:50 PM, rahul p <rahulpyd@xxxxxxxxx> wrote:
> Manish,
>
> It all looks pretty clear to me. In the first case  the 'get_block_t'
> structure is passed as an argument to the function. In the other case the
> pointer to the structure (get_block_t*) is passed as a function argument. I
> hope you know the difference between the 2. If not the following link would
> help.

Hi Rahul,

I understand the diff between passing as argument and as pointer.
However see how it is used in the two function.

static struct bio * do_mpage_readpage(............., get_block_t get_block) {
       ...........
       ...........
       if (get_block(inode, block_in_file, map_bh, 0))
				goto confused;
       .........
confused:
       if (!PageUptodate(page))
               block_read_full_page(page, get_block);
}


int block_read_full_page(struct page *page, get_block_t *get_block)
{
      .............
      .............
      err = get_block(inode, iblock, bh, 0);
      ...........
}


Thanks -
Manish

>
> http://www2.its.strath.ac.uk/courses/c/subsection3_12_3.html#SECTION00012300000000000000
>
> -
> Rahul Pydimukkala
>
>
>
> On Sun, Aug 3, 2008 at 1:53 PM, Daniel Baluta <daniel.baluta@xxxxxxxxx>
> wrote:
>>
>> See the definition of get_block_t
>>
>> typedef int (get_block_t)(struct inode *inode, sector_t iblock,
>>                         struct buffer_head *bh_result, int create);
>>
>>
>>
>> On 8/3/08, Manish Katiyar <mkatiyar@xxxxxxxxx> wrote:
>> > ok... I know i am going to be embarrassed but I am confused by the
>> > below function. The last parameter in do_mpage_readpage() is of type
>> > get_block_t, but when passed to block_read_full_page() it gets passed
>> > as get_block_t *.
>> >
>> >
>> > static struct bio * do_mpage_readpage(............., get_block_t
>> > get_block)
>> > {
>> >        ................
>> >        ................
>> >               if (page_has_buffers(page))
>> >               goto confused;
>> >         .................
>> > confused:
>> >               if (!PageUptodate(page))
>> >               block_read_full_page(page, get_block);
>> >        .........
>> > }
>> >
>> > int block_read_full_page(struct page *page, get_block_t *get_block) {
>> >         .........
>> >        ..........
>> > }
>> >
>> >
>> > How does this work ? :-( ....... Isn't gcc supposed to catch this and
>> > flag warning unless I am missing something very obvious.
>> >
>> > Thanks -
>> > Manish
>> >
>> > --
>> > To unsubscribe from this list: send an email with
>> > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>> > Please read the FAQ at http://kernelnewbies.org/FAQ
>> >
>> >
>>
>> --
>> To unsubscribe from this list: send an email with
>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>
>
>
>
> --
> Smart data structures and dumb code works a lot better than the other way
> around. -Eric S Raymond
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux