Skip to content

transport: avoid CRYPT_FLAG_*() doing symbol concatenation - #2495

Closed
vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:crypt-macro-tidy
Closed

vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:crypt-macro-tidy

Conversation

@vszakats

@vszakats vszakats commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

To make the SSH2_CRYPT_FLAG_* macros greppable and easier to
recognize.

Slight downside that it makes these macros longer to type. If it becomes
an issue, the flag symbols could be shortened.

Also: move these macro from global internal header to the only source
where they are used, transport.c.

Follow-up to 3c953c0 #797

Copilot AI left a comment

Copy link
Copy Markdown

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 refactors the internal CRYPT_FLAG_* convenience macros to avoid token-pasting (SSH2_CRYPT_FLAG_##flag), making crypto-flag usage easier to grep and recognize, and scopes the helper macros to transport.c where they’re actually used.

Changes:

  • Moved CRYPT_FLAG_L() / CRYPT_FLAG_R() macro definitions from src/libssh2_priv.h into src/transport.c.
  • Replaced token-concatenated flag references (e.g., PKTLEN_AAD) with explicit SSH2_CRYPT_FLAG_* symbols throughout transport.c.
  • Removed the now-unused CRYPT_FLAG_* macros from the internal global header.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/transport.c Adds local CRYPT_FLAG_L/R helpers and updates all call sites to pass explicit SSH2_CRYPT_FLAG_* constants.
src/libssh2_priv.h Removes the token-pasting CRYPT_FLAG_* macros, leaving only the SSH2_CRYPT_FLAG_* definitions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats closed this in 10af31d Aug 3, 2026
@vszakats
vszakats deleted the crypt-macro-tidy branch August 3, 2026 02:21
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.

2 participants