Skip to content

src: shorten namespace for private functions and macros - #1961

Closed
vszakats wants to merge 147 commits into
libssh2:masterfrom
vszakats:ssh2
Closed

vszakats wants to merge 147 commits into
libssh2:masterfrom
vszakats:ssh2

Conversation

@vszakats

@vszakats vszakats commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

From _libssh2_* to ssh2_*, LIBSSH2_* → SSH2_*. To make the code
easier to read, write, to fit more into the maximum line width without
folding, and to avoid using reserved namespace (_*).

Namespacing after this patch:

  • libssh2_, LIBSSH2_ (rarely preceded with _): public API.
  • ssh2_, SSH2_: private API.
  • ssh2_<crypto-backend>_: non-static crypto functions.
    where <crypto-backend> is: lgcr, mbed, ossl, wcng, os400qc3
  • local macros and static functions try to be short, descriptive of
    their scope, without strict namespacing. They also avoid namespaces
    used above for clarity.

Also:

  • reflow using clang-format (and manually where necessary.)
  • merge split error strings where possible (manually).
  • shorten _libssh2_debug() to ssh2_deb().
  • shorten _libssh2_error() to ssh2_err().
  • move libssh2_* internal symbols to the ssh2_* namespace.
  • shorten local macro/enum prefixes from LIBSSH2_ to SSH2_.
  • mbedtls, wincng: move static functions to the local namespace, where
    missing.
  • drop stray no-op ssh2_init_aes_ctr() symbols (libgcrypt, mbedtls).
  • move crypto primitives to crypto-local namespace
    ssh2_(lgcr|mbed|ossl|wcng)_, where missing.
  • normalize crypo-local and crypto-static function namespace to:
    mbed_*, ssh2_mbed_,* wcng_*, ssh2_wcng_*.
  • LIBSSH2_CIPHER_T() → SSH2_CIPHER_T()
    Follow-up to 689b202 src: drop leading underscore from internal macro constants #1923
  • rename ssh2_store_bignum2_bytes() → ssh2_store_bignum_bytes().
  • drop redundant void * cast from SSH2_UNCONST() values.
  • os400qc3: drop unused static ssh2_bn_from_bn().
  • os400qc3: move static ssh2_bn_resize() off the ssh2 namespace.
  • libssh2.rpgle.in: drop private macros LIBSSH2_DH_GEX*.
  • rename ARRAY_SIZE() to SSH2_ARRAYSIZE() for uniqueness.
  • agent: drop unused/commented SSH_AGENTC_* protocol 1 macros.
  • fix stray symbol references found in comments.
  • minor whitespace fixes along the way.

Note:

Follow-up to 8c9b777 #1931
Follow-up to 689b202 #1923
Ref: #1949


https://github.com/libssh2/libssh2/pull/1961/files?w=1

@vszakats
vszakats marked this pull request as draft June 3, 2026 07:25
@vszakats
vszakats marked this pull request as ready for review June 3, 2026 13:11
@vszakats vszakats changed the title src: shorten namespace for internal functions and macros src: shorten namespace for private functions and macros Jun 3, 2026
@vszakats
vszakats requested a review from Copilot June 3, 2026 16:48

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@vszakats vszakats closed this in 076838d Jun 4, 2026
@vszakats
vszakats deleted the ssh2 branch June 4, 2026 11:27
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jun 4, 2026
The attributes have an effect on the prototype only, it's not necessary
to set in on definitions. It may have had a double duty of indicating
public functions in the source, but those are easy to spot by their
`libssh2_` prefixes after libssh2#1961.
vszakats added a commit that referenced this pull request Jun 4, 2026
The attributes have an effect on the prototype only, it's not necessary
to set it on function definitions. It may have had a role of which
functions are public, but this is easy to spot by their `libssh2_`
prefixes, esp. after #1961.

Closes #1969
vszakats added a commit that referenced this pull request Jun 4, 2026
For fewer crypto-namespaced private functions in favor or plain `ssh2_*`
ones, and to reduce macro mappings.

Also:
- move related functions/macros declarations next to each other.
- merge `#if LIBSSH2_ECDSA` blocks.
- guard some constants with `LIBSSH2_ECDSA`.
- drop orphan prototypes.
  Follow-up to 076838d #1961
  Follow-up to ec0a51d #860
- tidy-up bignum (`ssh2_bn_*`) mapping/declaration blocks.
- formatting/whitespace/unfold/fold fixes/sync along the way.

Closes #1971
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