Re: LLVM / clang

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: LLVM / clang
Дата
Msg-id 28843.1276230296@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: LLVM / clang  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> [ assorted LLVM warnings ]

> dt_common.c:818:75: warning: more data arguments than '%' conversions
> [-Wformat-extra-args]
>                                 sprintf(str + strlen(str), (min != 0) ?
> "%+03d:%02d" : "%+03d", hour, min);
> ~~~~~~~        ^

> [and a few more like that]

> These are instances where a format string is an expression that results
> in a variable number of format arguments.  Not sure if that is actually
> legal in C.

I believe it's legal, but I'd be in favor of making a project policy
against it, simply because you aren't going to get any static checking
from gcc about whether the arguments match the format string.  There
isn't any good excuse not to code the above like
if (min != 0)    sprintf(str + strlen(str), "%+03d:%02d", hour, min);else    sprintf(str + strlen(str), "%+03d",
hour);

which would produce warnings if you managed to mess up the format match.

> print.c:778:22: warning: field width should have type 'int', but
> argument has type 'unsigned int' [-Wformat]
>                                 fprintf(fout, "%-*s%s\n", (width_total -
> width) / 2, "",

> Not sure about that.

That one, on the other hand, is pretty silly ...
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: Re: warning message in standby
Следующее
От: Takahiro Itagaki
Дата:
Сообщение: Re: LLVM / clang