https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10980

Alejandro Colomar <colomar.6.4.3 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |colomar.6.4.3 at gmail dot com

--- Comment #13 from Alejandro Colomar <colomar.6.4.3 at gmail dot com> ---
static inline void TELL(const char *fmt, ...)
__attribute__((format(printf, 1, 2), always_inline));

static inline void TELL(const char *fmt, ...)
{
        va_list ap;

        va_start(ap,fmt);
        vsyslog(LOG_NOTICE,_(fmt),ap);
        va_end(ap);
}


The compiler should be able to see that it is a varargs
function with printf-like format, and that the only reason
for `va_list` to exist is to pass the varargs and not to use
them.

It is trivial to see that an inlined version would be
simplified to a call to `syslog`.

Example:

void foo(void)
{
        char *world = "world";
        char newline = '\n';

        TELL("Hello %s%c%c", world, '!', newline);
}

could be inlined to the following code:

void foo(void)
{
        char *world = "world";
        char newline = '\n';

        syslog(LOG_NOTICE, "Hello %s%c%c", world, '!', newline);
}


The same should happen with `vprintf`->`printf` and all those
families of functions.

Reply via email to