warning about missing format string annotations

Поиск
Список
Период
Сортировка
От Andres Freund
Тема warning about missing format string annotations
Дата
Msg-id 20220916015438.6z62qowmuqnrpzmj@awork3.anarazel.de
обсуждение исходный текст
Список pgsql-hackers
Hi,

On 2022-09-15 21:18:03 +0000, Tom Lane wrote:
> We're so used to having the compiler check this stuff for us that
> a printf-like function without pg_attribute_printf is a land mine.
> I wonder if there is a way to detect such omissions.

gcc has -Wsuggest-attribute=format - but unfortunately its heuristics appear
to be too simplistic to catch many omission. It doesn't catch this one, for
example. But it may still be worth trying out in a few more cases.

           -Wsuggest-attribute=format
           -Wmissing-format-attribute
               Warn about function pointers that might be candidates for "format" attributes.  Note these are only
possiblecandidates, not absolute ones.
 
               GCC guesses that function pointers with "format" attributes that are used in assignment, initialization,
parameterpassing or return
 
               statements should have a corresponding "format" attribute in the resulting type.  I.e. the left-hand
sideof the assignment or
 
               initialization, the type of the parameter variable, or the return type of the containing function
respectivelyshould also have a "format"
 
               attribute to avoid the warning.

               GCC also warns about function definitions that might be candidates for "format" attributes.  Again,
theseare only possible candidates.  GCC
 
               guesses that "format" attributes might be appropriate for any function that calls a function like
"vprintf"or "vscanf", but this might not
 
               always be the case, and some functions for which "format" attributes are appropriate may not be
detected.

Greetings,

Andres Freund



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

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Assertion failure in WaitForWALToBecomeAvailable state machine
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Improve description of XLOG_RUNNING_XACTS