Skip to content

Conversation

@jtv
Copy link
Owner

@jtv jtv commented Dec 22, 2025

Uses a gcc-specific attribute, null_terminated_string_arg, to mark char *, char const *, char[], and char const[] parameters that are zero-terminated.

I don't think this does anything for optimisation, but it makes debug builds take a closer look.

Does seem to slow the build down. :-/ But better safe than sorry, especially with zview.

Uses a gcc-specific attribute, `null_terminated_string_arg`, to mark
`char *`, `char const *`, `char[]`, and `char const[]` parameters that
are zero-terminated.

I don't think this does anything for optimisation, but it makes debug
builds take a closer look.

Does seem to slow the build down.  :-/  But better safe than sorry,
especially with `zview`.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds gcc-specific null_terminated_string_arg attribute annotations to functions that accept zero-terminated C-style string parameters. The annotations are wrapped in PQXX_ZARGS and PQXX_ZARG(n) macros that expand to the attribute on supporting compilers and to nothing otherwise.

Key changes:

  • Introduces PQXX_ZARGS (for functions where all C-string parameters are null-terminated) and PQXX_ZARG(n) (for annotating specific parameter n) macros
  • Applies annotations to constructors, functions, and member functions throughout the codebase that accept char const[], char const *, or similar C-string parameters
  • Fixes spelling errors in comments ("instea dof" → "instead of")

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
include/pqxx/internal/header-pre.hxx Defines PQXX_ZARGS and PQXX_ZARG(n) macros with conditional compilation based on attribute availability
include/pqxx/types.hxx Adds PQXX_ZARGS to demangle_type_name function declaration
include/pqxx/zview.hxx Annotates zview constructors and operators that take C-string parameters
include/pqxx/util.hxx Annotates make_strerror_rs_result helper function
include/pqxx/transaction_base.hxx Annotates esc, unesc_bin, and process_notice member functions
include/pqxx/strconv.hxx Adds PQXX_ZARG(2) to deprecated to_buf function
include/pqxx/internal/gates/connection-sql_cursor.hxx Annotates exec gate function
include/pqxx/internal/gates/connection-pipeline.hxx Annotates start_exec gate function
include/pqxx/internal/encodings.hxx Annotates error-throwing functions that take encoding name parameters
include/pqxx/internal/conversions.hxx Annotates string trait functions and adds constexpr/noexcept qualifiers to some functions
include/pqxx/field.hxx Removes unsafe to<char const *> specialization
include/pqxx/except.hxx Annotates exception constructors that accept sqlstate C-string parameters
include/pqxx/errorhandler.hxx Annotates virtual operator() for error message handling
include/pqxx/connection.hxx Annotates connection constructor, encoding functions, password encryption, prepared statements, and escaping functions
src/types.cxx Adds PQXX_ZARGS to demangle_type_name implementation and includes C++26 reflection comment
src/strconv.cxx Fixes spelling errors in comments
src/result.cxx Annotates internal equal C-string comparison function
src/encodings.cxx Annotates encoding error-throwing functions
src/connection.cxx Annotates pqxx_notice_processor callback and set_client_encoding implementation

@jtv jtv marked this pull request as ready for review December 23, 2025 10:39
@jtv jtv merged commit b5d33eb into start-8 Dec 23, 2025
45 checks passed
@jtv jtv deleted the zargs branch December 23, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant