Skip to content

mod.ccontrol: two pieces of dead code (an unused per-quit string, an unreachable else) #94

Description

@MrIron-no

Two small pieces of dead code in mod.ccontrol/ccontrol.cc, both harmless but both misleading to read.

1. A string built on every quit and kill, never read.

In the EVT_QUIT/EVT_KILL case (ccontrol.cc:1065):

        string tIP = xIP(tmpUser->getIP()).GetNumericIP(true);

tIP is not read anywhere in that case body. It is scoped to the case, so nothing outside can use it either. The cost is a numeric-IP conversion and a std::string construction for every client leaving the network, network-wide.

2. An else that an earlier return makes unreachable.

In the EVT_GLINE case, the handler returns early when gline saving is off (ccontrol.cc:1204):

        if (!saveGlines) {
            return;
        }

Further down the same case it tests the same flag again and provides an else branch:

        if (saveGlines) { ... } else { newGline->setId("-1"); }

Control can only reach that point with saveGlines true, so the else never executes and setId("-1") is dead. Either the early return or the else is redundant; which one depends on what was intended for the saving-disabled case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions