Skip to content

lib: use const in vty-is-shell apis - #21094

Merged
donaldsharp merged 1 commit into
FRRouting:masterfrom
mjstapp:vty_shell_const
Mar 11, 2026
Merged

lib: use const in vty-is-shell apis#21094
donaldsharp merged 1 commit into
FRRouting:masterfrom
mjstapp:vty_shell_const

Conversation

@mjstapp

@mjstapp mjstapp commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Use const and clarify name of a couple of vty object accessors (we noticed this when looking at another PR, so just trying to offer it before... we forget about it)

Use const and clarify name of a couple of vty object accessors

Signed-off-by: Mark Stapp <mjs@cisco.com>
@greptile-apps

greptile-apps Bot commented Mar 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR performs a straightforward API rename and const-correctness improvement for two VTY accessor functions in FRR's lib/ layer: vty_shell() β†’ vty_is_shell() and vty_shell_serv() β†’ vty_is_shell_serv(), with the struct vty * parameter becoming const struct vty * in both cases.

  • lib/vty.h: Header declarations updated with new names and const-qualified pointer parameters.
  • lib/vty.c: Implementations renamed; const added to the parameter; function bodies are unchanged.
  • lib/command.c: All four call sites (in root_on_exit, no_config_password, and no_config_enable_password) updated to the new names.
  • lib/routemap.c: Single call site in route_map_lookup_warn_noexist updated to the new name.
  • A codebase-wide search confirms no remaining uses of the old vty_shell or vty_shell_serv names β€” the rename is complete and consistent.
  • No logic changes whatsoever; this is a pure refactor improving naming clarity and const-correctness.

Confidence Score: 5/5

  • This PR is safe to merge β€” it is a pure rename and const-correctness refactor with no logic changes.
  • All call sites across the repository have been updated, the old function names are fully removed, and the function bodies are identical to before. The only change is improved naming and a const qualifier on the pointer parameter, which is strictly more correct.
  • No files require special attention.

Important Files Changed

Filename Overview
lib/vty.h Declaration of vty_shell / vty_shell_serv updated to vty_is_shell / vty_is_shell_serv with const-qualified pointer parameter β€” straightforward header update, no issues.
lib/vty.c Implementations renamed and const qualifier added to the vty pointer; function bodies are unchanged and correct.
lib/command.c Four call sites updated from vty_shell / vty_shell_serv to vty_is_shell / vty_is_shell_serv; no logic changes.
lib/routemap.c Single call site updated from vty_shell_serv to vty_is_shell_serv; no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["root_on_exit()\nlib/command.c"] -->|"vty_is_shell(vty)"| E
    B["no_config_password()\nlib/command.c"] -->|"vty_is_shell_serv(vty)"| F
    C["no_config_enable_password()\nlib/command.c"] -->|"vty_is_shell_serv(vty)"| F
    D["route_map_lookup_warn_noexist()\nlib/routemap.c"] -->|"vty_is_shell_serv(vty)"| F

    E["vty_is_shell(const struct vty *)\nlib/vty.c\n→ vty->type == VTY_SHELL"]
    F["vty_is_shell_serv(const struct vty *)\nlib/vty.c\n→ vty->type == VTY_SHELL_SERV"]

    style E fill:#d4edda,stroke:#28a745
    style F fill:#d4edda,stroke:#28a745
Loading

Last reviewed commit: 061d637

@frrbot frrbot Bot added the libfrr label Mar 11, 2026
@donaldsharp
donaldsharp merged commit 7b4ffef into FRRouting:master Mar 11, 2026
23 checks passed
@mjstapp
mjstapp deleted the vty_shell_const branch May 5, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants