def end_entry(self):
        """Finish a previously started config database entry.

        This commits the currently in progress entry.  The expected flow is
        that start_entry() is called followed by 1 or more calls to add_data()
        followed by a single call to end_entry().

        Returns:
            int: An error code
        """

        # Matching current firmware behavior
        if self.in_progress is None:
            return Error.NO_ERROR

        # Make sure there was actually data stored
        if self.in_progress.data_space() == 2:
            return Error.INPUT_BUFFER_WRONG_SIZE

        # Invalidate all previous copies of this config variable so we
        # can properly compact.
        for entry in self.entries:
            if entry.target == self.in_progress.target and entry.var_id == self.in_progress.var_id:
                entry.valid = False

        self.entries.append(self.in_progress)
        self.data_index += self.in_progress.data_space() - 2  # Add in the rest of the entry size (we added two bytes at start_entry())
        self.in_progress = None

        return Error.NO_ERROR
Finish a previously started config database entry.

        This commits the currently in progress entry.  The expected flow is
        that start_entry() is called followed by 1 or more calls to add_data()
        followed by a single call to end_entry().

        Returns:
            int: An error code