[Top][All Lists]

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

Re: [avr-libc-dev] Usage of 'FILE *' in base put/get seems doubtful

From: Wojtek Kaniewski
Subject: Re: [avr-libc-dev] Usage of 'FILE *' in base put/get seems doubtful
Date: Sun, 11 Sep 2005 23:13:01 +0200
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050716)

[I forgot to reply to the list earlier, so here's a repost.]

Dmitry K. wrote:
Whether can somebody result a simple example, where the new parameter
('FILE *') would be really useful?

int uart_put(char c, FILE *f)
    return uartX_put(c, (int) fdev_get_udata(f));

int uart_get(FILE *f)
    return uartX_get((int) fdev_get_udata(f));

FILE *uart_open(char i)
    FILE *res;

    res = fdevopen(uart_put, uart_get);
    fdev_set_udata(res, (void*) i);

    return res;

uart0_stream = uart_open(0);
uart1_stream = uart_open(1);

   On the other hand, transfer 'FILE *' in function of more low level,
than library 'stdio', seems illogical.

Handling UART is a poor example of the new API's usability. Think of a
filesystem -- put() function should be able to find out if the file is
opened for read too to invalidate caches etc.

And in general, whether is though one function with parameter 'FILE *'
which is safe for using in this case? Actually, transferring 'FILE *'
unknown function, the library 'stdio' loses the control over the
integrity.  ('const FILE *' - it would be better).

Making the pointer "const" would also cause any call to stdio functions
inside put() or get() to issue a warning about passing const parameter
as a non-const argument.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]