-
-
Notifications
You must be signed in to change notification settings - Fork 275
Annotate zero-terminated string arguments. #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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`.
There was a problem hiding this 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) andPQXX_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 |
Uses a gcc-specific attribute,
null_terminated_string_arg, to markchar *,char const *,char[], andchar 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.