[PATCH v2 0/4] add variadic format checking

Ben Dooks <[email protected]> Mon, 22 Dec 2025 16:00:30 +0000
Newsgroups org.kernel.vger.linux-sparse
Message-ID <[email protected]>
Second version of this, I think mostly sorting the issues
identified in review.

This series (which was initially sent back in 2020) adds the
ability to deal with __attribute__((format) and checking the
arguments to formatted variadic functions.

I have been considering adding a -Wformat-linux to this as
the kernel now has a number of extra formatting options and
checking the type of these would be useful. An even nicer
extension would be some way of informing the compiler/sparse
of these at compile time (but would need to get agreement on
how to do this with the compilers too)

Ben Dooks (4):
  parse: initial parsing of __attribute__((format))
  add -Wformat
  evaluate: check variadic argument types against formatting info
  tests: add varargs printf format tests

 Makefile                               |   1 +
 builtin.c                              |   4 +-
 evaluate.c                             |  14 +-
 evaluate.h                             |  10 +-
 options.c                              |   2 +
 options.h                              |   1 +
 parse.c                                |  83 ++++-
 sparse.1                               |   8 +
 symbol.h                               |  10 +-
 validation/varargs-format-addrspace1.c |  36 ++
 validation/varargs-format-bad.c        |  18 +
 validation/varargs-format-checking.c   |  21 ++
 validation/varargs-format-position.c   |  32 ++
 validation/varargs-format-prefix.c     |  19 +
 validation/varargs-format-tests.c      |  55 +++
 validation/varargs-type-formattest.c   | 117 +++++++
 verify-format.c                        | 460 +++++++++++++++++++++++++
 verify-format.h                        |   6 +
 18 files changed, 887 insertions(+), 10 deletions(-)
 create mode 100644 validation/varargs-format-addrspace1.c
 create mode 100644 validation/varargs-format-bad.c
 create mode 100644 validation/varargs-format-checking.c
 create mode 100644 validation/varargs-format-position.c
 create mode 100644 validation/varargs-format-prefix.c
 create mode 100644 validation/varargs-format-tests.c
 create mode 100644 validation/varargs-type-formattest.c
 create mode 100644 verify-format.c
 create mode 100644 verify-format.h

-- 
2.37.2.352.g3c44437643