Skip to content

Redundant/Unnecessary return keyword in castVote public function in GovernorAlpha.sol contract #274

Description

@0xebby

### Redundant/Unnecessary return keyword in castVote public function in GovernorAlpha.sol contract

POC:

Internal _castVote function: Doesn't return anything - void

`function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);

    if (support) {
        proposal.forVotes = add256(proposal.forVotes, votes);
    } else {
        proposal.againstVotes = add256(proposal.againstVotes, votes);
    }

    receipt.hasVoted = true;
    receipt.support = support;
    receipt.votes = votes;

    emit VoteCast(voter, proposalId, support, votes);
}`

Public castVote function: also doesn't return anything void but the implementation here has a return keyword

function castVote(uint proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); }

Recommendation

  • remove redundant return keyword

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions