Re: Basic C question

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

 



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.

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


[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